This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rect_t CFont::RenderText(const std::string& text, const vector2_t& Pos) | |
{ | |
// VAO and buffers that will contain our text vertex data. | |
uint32_t vao = 0, vbo = 0, ibo = 0; | |
// Track total text size. | |
rect_t Size(Pos.x, Pos.y, 0, 0); | |
if(!m_loaded || !CFont::s_loaded || text.empty()) return Size; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 330 core | |
// Our texture | |
uniform sampler2D texture; | |
// Incoming attributes from the vertex shader | |
smooth in vec2 fs_texc; | |
smooth in vec4 fs_color; | |
// Output color |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef ANIMATION_HPP | |
#define ANIMATION_HPP | |
// Framebuffer object | |
#include "Graphics/Framebuffer.hpp" | |
// Animation inherits rigid body entity | |
#include "Entity/RigidBody.hpp" | |
// For the timer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Entity/Animation.hpp" | |
bool CAnimation::LoadFromFile(const std::string& filename, | |
gfx::CVertexBuffer& VBO) | |
{ | |
// Open the .icanim file. | |
std::ifstream anim(filename, std::ios::binary); | |
CAnimation::AnimationHeader& header = m_SheetDetails; | |
memset(&header, NULL, sizeof header); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 330 core | |
uniform sampler2D texture; | |
// Individual sprite dimensions expressed in the proper texcoord range. | |
// For example, a 32x32 sprite would be <0.03125, 0.03125> | |
// This would then be interpolated from [0, 0.03125], properly rendering | |
// all of the texels in the desired sprite. | |
uniform vec2 tc_offset; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 330 core | |
uniform sampler2D texture; | |
uniform vec2 tc_offset; | |
uniform vec2 tc_start; | |
smooth in vec2 fs_texc; | |
smooth in vec4 fs_color; | |
out vec4 out_color; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool CAnimation::NextSprite() | |
{ | |
// Stay within bounds! | |
if(++m_active >= this->GetAnimationCount()) | |
{ | |
++m_loops_done; | |
m_active = 0; | |
} | |
// Adjust for current texture |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void CAnimation::SwapSpriteSheet(const AnimationHeader& Header) | |
{ | |
// New texture for the renderer and new dimensions for the shader. | |
m_Mesh.GetSurfaces()[0]->pMaterial->pTexture = Header.pTexture; | |
m_TexcDim = math::vector2_t(1.f / Header.columns, 1.f / Header.rows); | |
m_SheetDetails = Header; | |
m_loops_done = 0; | |
// Adjust shader for new texture dimensions. | |
gfx::CShaderPair* pShader = m_Mesh.GetSurfaces()[0]->pMaterial->pShader; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <list> | |
#include <cstdint> | |
// A generic object class (supporting collision) that is within the nodes. | |
// See here: https://github.com/Ruskiy69/IronClad/blob/master/Source/include/Entity/RigidBody.hpp | |
// For a real definition of the objects I use. | |
class CQuadTree; | |
class CEntity; | |
// This is a rectangle representation containing x, y position, and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See this here: https://gist.github.com/Ruskiy69/5257421 | |
#include "gists/QTreeNode.hpp" | |
class CQuadTree | |
{ | |
public: | |
// Provide the starting dimensions to the root node. | |
// This will likely be something like Window::GetWidth() | |
// and Window::GetHeight() in a game. | |
CQuadTree(const uint16_t w, const uint16_t h); |