From 2f52a4985634f4142396f995e3c1647afe921416 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 2 Jan 2023 17:28:10 +0000 Subject: Use VertexArrayObject for SceneRenderer --- gfx/gl/sceneRenderer.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'gfx') diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp index 8b299ad..ee2b1ee 100644 --- a/gfx/gl/sceneRenderer.cpp +++ b/gfx/gl/sceneRenderer.cpp @@ -1,28 +1,24 @@ #include "sceneRenderer.h" #include "maths.h" +#include "vertexArrayObject.hpp" #include #include #include #include -static constexpr std::array displayVAOdata {{ +static constexpr const std::array displayVAOdata {{ // positions(x,y) texture coords(z,w) - {-1.0f, 1.0f, 0.0f, 1.0f}, - {-1.0f, -1.0f, 0.0f, 0.0f}, - {1.0f, 1.0f, 1.0f, 1.0f}, - {1.0f, -1.0f, 1.0f, 0.0f}, + {-1, 1, 0, 1}, + {-1, -1, 0, 0}, + {1, 1, 1, 1}, + {1, -1, 1, 0}, }}; SceneRenderer::SceneRenderer(glm::ivec2 s, GLuint o) : camera {{-1250.0F, -1250.0F, 35.0F}, quarter_pi, ratio(s), 0.1F, 10000.0F}, size {s}, output {o}, lighting {lightingShader_vs, lightingShader_fs}, shadowMapper {{2048, 2048}} { shader.setViewPort({0, 0, size.x, size.y}); - glBindVertexArray(displayVAO); - glBindBuffer(GL_ARRAY_BUFFER, displayVBO); - glBufferData(GL_ARRAY_BUFFER, sizeof(displayVAOdata), nullptr, GL_STATIC_DRAW); - glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(displayVAOdata), glm::value_ptr(displayVAOdata.front())); - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(glm::vec4), nullptr); + VertexArrayObject::configure(displayVAO, displayVBO, displayVAOdata); glBindFramebuffer(GL_FRAMEBUFFER, gBuffer); const auto configuregdata -- cgit v1.2.3