diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index fcc5f1694..ad08ebe04 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -217,7 +217,7 @@ void Graphics::setViewportSize(int width, int height) gl.setViewport({0, 0, width, height}, false); // Set up the projection matrix - gl.matrices.projection.back() = Matrix4::ortho(0.0, (float) width, (float) height, 0.0); + gl.matrices.projection = Matrix4::ortho(0.0, (float) width, (float) height, 0.0); } } @@ -442,7 +442,7 @@ void Graphics::beginPass(PassInfo::BeginAction beginAction, Colorf clearColor) // The projection matrix is flipped compared to rendering to a canvas, due // to OpenGL considering (0,0) bottom-left instead of top-left. - gl.matrices.projection.back() = Matrix4::ortho(0.0, (float) width, (float) height, 0.0); + gl.matrices.projection = Matrix4::ortho(0.0, (float) width, (float) height, 0.0); if (GLAD_VERSION_1_0 || GLAD_EXT_sRGB_write_control) { @@ -523,7 +523,7 @@ void Graphics::beginPass(const PassInfo &info) int h = firstcanvas->getHeight(); gl.setViewport({0, 0, w, h}, true); - gl.matrices.projection.back() = Matrix4::ortho(0.0, (float) w, 0.0, (float) h); + gl.matrices.projection = Matrix4::ortho(0.0, (float) w, 0.0, (float) h); // Make sure the correct sRGB setting is used when drawing to the canvases. if (GLAD_VERSION_1_0 || GLAD_EXT_sRGB_write_control) diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index 37615272d..3749829af 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -74,7 +74,6 @@ OpenGL::OpenGL() , state() { matrices.transform.reserve(10); - matrices.projection.reserve(2); } bool OpenGL::initContext() @@ -307,10 +306,9 @@ void OpenGL::initMaxValues() void OpenGL::initMatrices() { matrices.transform.clear(); - matrices.projection.clear(); matrices.transform.push_back(Matrix4()); - matrices.projection.push_back(Matrix4()); + matrices.projection = Matrix4(); } void OpenGL::createDefaultTexture() @@ -364,7 +362,7 @@ void OpenGL::prepareDraw() // because uniform uploads can be significantly slower than glLoadMatrix. if (GLAD_VERSION_1_0) { - const Matrix4 &curproj = matrices.projection.back(); + const Matrix4 &curproj = matrices.projection; const Matrix4 &curxform = matrices.transform.back(); const Matrix4 &lastproj = state.lastProjectionMatrix; @@ -377,7 +375,7 @@ void OpenGL::prepareDraw() glLoadMatrixf(curproj.getElements()); glMatrixMode(GL_MODELVIEW); - state.lastProjectionMatrix = matrices.projection.back(); + state.lastProjectionMatrix = matrices.projection; } // Same with the transform matrix. diff --git a/src/modules/graphics/opengl/OpenGL.h b/src/modules/graphics/opengl/OpenGL.h index ce186e607..c740c35e6 100644 --- a/src/modules/graphics/opengl/OpenGL.h +++ b/src/modules/graphics/opengl/OpenGL.h @@ -126,7 +126,7 @@ public: struct { std::vector transform; - std::vector projection; + Matrix4 projection; } matrices; class TempTransform diff --git a/src/modules/graphics/opengl/Shader.cpp b/src/modules/graphics/opengl/Shader.cpp index 6bdff33e1..0900a94f9 100644 --- a/src/modules/graphics/opengl/Shader.cpp +++ b/src/modules/graphics/opengl/Shader.cpp @@ -753,7 +753,7 @@ void Shader::checkSetBuiltinUniforms() checkSetPointSize(gl.getPointSize()); const Matrix4 &curxform = gl.matrices.transform.back(); - const Matrix4 &curproj = gl.matrices.projection.back(); + const Matrix4 &curproj = gl.matrices.projection; TemporaryAttacher attacher(this);