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
#define MAX_LIGHTS 10 // Re-written on the fly | |
/** | |
* @file | |
* Fragment shader for lighting. | |
* Per-pixel point light lighting is done in this shader. | |
* | |
* @author me | |
* @addtogroup Shaders | |
* @{ |
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
// IronClad vertex buffer object wrapper. | |
#include "VertexBuffer.hpp" | |
// IronClad custom mesh loader. | |
#include "Mesh.hpp" | |
class CMeshInstance | |
{ | |
public: | |
/** |
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 CScene::Render() | |
// Model-view matrix. | |
static math::matrix4x4_t MVMatrix = math::IDENTITY; | |
// Offload vertex data onto the GPU if it has not been done yet. | |
if(!m_GeometryVBO.Finalized()) m_GeometryVBO.FinalizeBuffer(); | |
// Bind VBO that contains the mesh vertex data. | |
m_GeometryVBO.Bind(); |
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 CScene::Render() | |
{ | |
// Model-view identity matrix, to be loaded later. | |
static math::matrix4x4_t MVMatrix = math::IDENTITY; | |
// Offload vertex data onto the GPU if it has not been done yet. | |
if(!m_GeometryVBO.Finalized()) m_GeometryVBO.FinalizeBuffer(); | |
// Bind VBO that contains the mesh vertex data. | |
m_GeometryVBO.Bind(); |
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 | |
// Input from program: vertex, texture coordinates, | |
// and color. | |
// | |
// In IronClad, these are part of a vertex2_t struct | |
// that is passed to the VBO after being loaded with | |
// mesh data. | |
smooth in vec2 vs_vertex; | |
smooth in vec2 vs_texc; |
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. |
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
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
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
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. |