summaryrefslogtreecommitdiff
path: root/frontend/shared_cpp
diff options
context:
space:
mode:
authorMatthew Kosarek <mattkae@protonmail.com>2021-03-27 21:12:42 -0400
committerMatthew Kosarek <mattkae@protonmail.com>2021-03-27 21:13:04 -0400
commitb17c518155fae64083eb5b56b78b9eec57603ac0 (patch)
tree0e8013b557a284b6d17491f9cf805634de9a11ff /frontend/shared_cpp
parentcc05fdc7396532b329f30decde5583853da92a44 (diff)
Drawing pretty line segments in easter colors
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