Add vector of quads instead of just one
This commit is contained in:
parent
1b9b0d85e6
commit
4ce0f0d2f4
20
src/main.cc
20
src/main.cc
|
@ -92,6 +92,8 @@ static const GLuint vertex_data_position = 0;
|
|||
|
||||
static Quad *o1;
|
||||
|
||||
static std::vector<Quad *> quads = {};
|
||||
|
||||
static std::array<glm::vec2, 6> verts({
|
||||
// Tri 2
|
||||
{0.0f, 0.0f},
|
||||
|
@ -103,6 +105,17 @@ static std::array<glm::vec2, 6> verts({
|
|||
{0.0f, 0.5f},
|
||||
});
|
||||
|
||||
static std::array<glm::vec2, 6> 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<glm::vec2>(verts), (Uniform){.world_pos = translate_unif, .rotation = rotate_unif}));
|
||||
quads.push_back(new Quad(std::span<glm::vec2>(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();
|
||||
|
|
Loading…
Reference in New Issue