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
#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
#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
#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
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
bool CFont::LoadFromFile(const std::string& filename, const uint16_t size) | |
{ | |
// Make sure everything is ready. | |
if(!m_ready || !CFont::s_loaded) return false; | |
// Create a new font face. | |
if(FT_New_Face(s_Library, filename.c_str(), 0, &m_FontFace) != 0) | |
return false; | |
// Set the size of the font face. |
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 CFont::Initialize() | |
{ | |
if(s_loaded) return true; | |
if(FT_Init_FreeType(&s_Library) != 0) return false; | |
return (s_loaded = true); | |
} |
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
CFont::CFont() : m_ready(false), m_loaded(false) | |
{ | |
// Initialize FreeType. | |
if(!CFont::Initialize()) return; | |
// Load the shader. | |
if(!m_FontRender.LoadFromFile("Default.vs", "FontRender.fs")) | |
return; | |
// Give the font shader an identity matrix for the model-view |
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
// Font class header. | |
#ifndef FONT_HPP | |
#define FONT_HPP | |
// Storing {char:glyph} pairs. | |
#include <map> | |
// Include files for FreeType 2. | |
#include "ft2build.h" | |
#include "freetype/freetype.h" |
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
/// Various data structures for simplifying font handling. | |
#ifndef TYPES_HPP | |
#define TYPES_HPP | |
/// Represents a point in 2D rectangular-coordinate space. | |
struct vector2_t | |
{ | |
float x, y; | |
/// Default constructor that sets components to 0. |