From 4ce0f0d2f4c033a03748aef824fb12490cc1a409 Mon Sep 17 00:00:00 2001 From: Archie Hilton Date: Tue, 14 May 2024 21:13:18 +0100 Subject: [PATCH] Add vector of quads instead of just one --- src/main.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main.cc b/src/main.cc index 14cb350..f741095 100644 --- a/src/main.cc +++ b/src/main.cc @@ -92,6 +92,8 @@ static const GLuint vertex_data_position = 0; static Quad *o1; +static std::vector quads = {}; + static std::array verts({ // Tri 2 {0.0f, 0.0f}, @@ -103,6 +105,17 @@ static std::array verts({ {0.0f, 0.5f}, }); +static std::array verts2({ + // Tri 2 + {1.0f, 0.0f}, + {1.5f, 0.0f}, + {1.5f, 0.5f}, + // Tri 1 + {1.0f, 0.0f}, + {1.5f, 0.5f}, + {1.0f, 0.5f}, +}); + // Do the work of initialising opengl so we can draw stuff static void init_opengl() { dbg_log("Initialising opengl"); @@ -116,7 +129,8 @@ static void init_opengl() { init_shaders(); - o1 = new Quad(std::span(verts), (Uniform){.world_pos = translate_unif, .rotation = rotate_unif}); + quads.push_back(new Quad(std::span(verts), (Uniform){.world_pos = translate_unif, .rotation = rotate_unif})); + quads.push_back(new Quad(std::span(verts2), (Uniform){.world_pos = translate_unif, .rotation = rotate_unif})); } int main() { @@ -150,7 +164,9 @@ int main() { while(!glfwWindowShouldClose(w)) { glClear(GL_COLOR_BUFFER_BIT); - o1->draw(); + for(auto q : quads) { + q->draw(); + } glfwSwapBuffers(w); glfwPollEvents();