From c36d05d5aed2f8f7c6342b174692146e2d11c386 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Mon, 22 Mar 2021 20:54:51 -0400 Subject: Refactored frontend, beginnings of general cpp layer, and beginning roadmap --- frontend/_shared/OrthographicRenderer.cpp | 76 ------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 frontend/_shared/OrthographicRenderer.cpp (limited to 'frontend/_shared/OrthographicRenderer.cpp') diff --git a/frontend/_shared/OrthographicRenderer.cpp b/frontend/_shared/OrthographicRenderer.cpp deleted file mode 100644 index 9dc9892..0000000 --- a/frontend/_shared/OrthographicRenderer.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#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...\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 compiled.\n"); -} - -void OrthographicRenderer::render() { - useShader(shader); - setShaderMat4(uniforms.projection, projection); -} - -void OrthographicRenderer::unload() { - glDeleteProgram(shader); -} - -template -void OrthographicShape::load(OrthographicRenderer* renderer) { - useShader(renderer->shader); - - glGenVertexArrays(1, &vao); - glBindVertexArray(vao); - - glGenBuffeloadrs(1, &vbo); - glBindBuffer(GL_ARRAY_BUFFER, vbo); - glBufferData(GL_ARRAY_BUFFER, N * sizeof(OrthographicVertex), &vertices[0], GL_STATIC_DRAW); - - glEnableVerloadtexAttribArray(renderer->attributes.position); - glVertexAttribPointer(attributes.position, 2, GL_FLOAT, GL_FALSE, sizeof(OrthographicVertex), (GLvoid *)0); - - glEnableVertexAttribArray(renderer->attributes.color); - glVertexAttribPointer(attributes.color, 4, GL_FLOAT, GL_FALSE, sizeof(OrthographicVertex), (GLvoid *)offsetof(OrthographicVertex, color)); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(0); -} - -template -void OrthographicShape::render(OrthographicRenderer* renderer) { - setShaderMat4(renderer->uniforms.model, model); - - glBindVertexArray(vao); - glDrawArrays(GL_TRIANGLES, 0, 3); - glBindVertexArray(0); -} - -void OrthographicShape::unload() { - glDeleteVertexArrays(1, &vao); - gDeleteBuffers(1, &vbo); -} -- cgit v1.2.1