#include "OrthographicRenderer.h" const char* orthographicVertex = "attribute vec2 position; \n" "attribute vec4 color; \n" "uniform mat4 projection; \n" "uniform mat4 model; \n" "varying lowp vec4 VertexColor; \n" "void main() { \n" " vec4 fragmentPosition = projection * model * vec4(position, 1, 1); \n" " gl_Position = fragmentPosition; \n" " VertexColor = color; \n" "}"; const char* orthographicFragment = "varying lowp vec4 VertexColor; \n" "void main() { \n" " gl_FragColor = VertexColor; \n" "}"; void OrthographicRenderer::load() { printf("Compiling orthographic shader...\n"); shader = loadShader(orthographicVertex, orthographicFragment); useShader(shader); attributes.position = getShaderAttribute(shader, "position"); attributes.color = getShaderAttribute(shader, "color"); uniforms.projection = getShaderUniform(shader, "projection"); uniforms.model = getShaderUniform(shader, "model"); printf("Orthographic shader compiled.\n"); } void OrthographicRenderer::render() { glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glDepthMask(GL_TRUE); glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); useShader(shader); setShaderMat4(uniforms.projection, projection); } void OrthographicRenderer::unload() { glDeleteProgram(shader); }