summaryrefslogtreecommitdiff
path: root/frontend/shared_cpp
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/shared_cpp')
-rw-r--r--frontend/shared_cpp/OrthographicRenderer.cpp13
-rw-r--r--frontend/shared_cpp/OrthographicRenderer.h3
2 files changed, 4 insertions, 12 deletions
diff --git a/frontend/shared_cpp/OrthographicRenderer.cpp b/frontend/shared_cpp/OrthographicRenderer.cpp
index 1d62c04..21c13a1 100644
--- a/frontend/shared_cpp/OrthographicRenderer.cpp
+++ b/frontend/shared_cpp/OrthographicRenderer.cpp
@@ -53,7 +53,6 @@ void OrthographicRenderer::unload() {
void OrthographicShape::load(OrthographicVertex* inVertices, uint32 inNumVertices, OrthographicRenderer* renderer) {
- vertices = inVertices;
numVertices = inNumVertices;
useShader(renderer->shader);
@@ -62,7 +61,7 @@ void OrthographicShape::load(OrthographicVertex* inVertices, uint32 inNumVertice
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
- glBufferData(GL_ARRAY_BUFFER, inNumVertices * sizeof(OrthographicVertex), &vertices[0], GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, inNumVertices * sizeof(OrthographicVertex), &inVertices[0], GL_STATIC_DRAW);
glEnableVertexAttribArray(renderer->attributes.position);
glVertexAttribPointer(renderer->attributes.position, 2, GL_FLOAT, GL_FALSE, sizeof(OrthographicVertex), (GLvoid *)0);
@@ -74,21 +73,15 @@ void OrthographicShape::load(OrthographicVertex* inVertices, uint32 inNumVertice
glBindVertexArray(0);
}
-void OrthographicShape::render(OrthographicRenderer* renderer) {
+void OrthographicShape::render(OrthographicRenderer* renderer, GLenum drawType) {
setShaderMat4(renderer->uniforms.model, model);
glBindVertexArray(vao);
- glDrawArrays(GL_TRIANGLES, 0, numVertices);
+ glDrawArrays(drawType, 0, numVertices);
glBindVertexArray(0);
}
void OrthographicShape::unload() {
glDeleteVertexArrays(1, &vao);
glDeleteBuffers(1, &vbo);
-
- if (vertices != NULL) {
- delete vertices;
- }
-
- vertices = NULL;
} \ No newline at end of file
diff --git a/frontend/shared_cpp/OrthographicRenderer.h b/frontend/shared_cpp/OrthographicRenderer.h
index 0cdfc78..cef5305 100644
--- a/frontend/shared_cpp/OrthographicRenderer.h
+++ b/frontend/shared_cpp/OrthographicRenderer.h
@@ -35,10 +35,9 @@ struct OrthographicShape {
uint32 vao;
uint32 vbo;
uint32 numVertices = 0;
- OrthographicVertex* vertices = NULL;
Mat4x4 model;
void load(OrthographicVertex* vertices, uint32 numVertices, OrthographicRenderer* renderer);
- void render(OrthographicRenderer* renderer);
+ void render(OrthographicRenderer* renderer, GLenum drawType = GL_TRIANGLES);
void unload();
}; \ No newline at end of file