diff options
Diffstat (limited to 'frontend/shared_cpp/OrthographicRenderer.cpp')
-rw-r--r-- | frontend/shared_cpp/OrthographicRenderer.cpp | 45 |
1 files changed, 8 insertions, 37 deletions
diff --git a/frontend/shared_cpp/OrthographicRenderer.cpp b/frontend/shared_cpp/OrthographicRenderer.cpp index 9dc9892..d160ecc 100644 --- a/frontend/shared_cpp/OrthographicRenderer.cpp +++ b/frontend/shared_cpp/OrthographicRenderer.cpp @@ -19,7 +19,7 @@ const char* orthographicFragment = "}"; void OrthographicRenderer::load() { - printf("Compiling orthographic...\n"); + printf("Compiling orthographic shader...\n"); shader = loadShader(orthographicVertex, orthographicFragment); useShader(shader); @@ -28,10 +28,16 @@ void OrthographicRenderer::load() { uniforms.projection = getShaderUniform(shader, "projection"); uniforms.model = getShaderUniform(shader, "model"); - printf("Orthographic compiled.\n"); + 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); } @@ -39,38 +45,3 @@ void OrthographicRenderer::render() { void OrthographicRenderer::unload() { glDeleteProgram(shader); } - -template <uint32 N> -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 <uint32 N> -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); -} |