From 2840618c70d4642d9a61897597f6f6a5c83d30db Mon Sep 17 00:00:00 2001 From: LaurentGom Date: Thu, 4 Feb 2010 19:25:00 +0000 Subject: [PATCH] The projection matrix is now handled more efficiently in sf::Renderer git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1392 4e206d99-4929-0410-ac5d-dfc041789085 --- include/SFML/Graphics/Renderer.hpp | 15 --------------- src/SFML/Graphics/Renderer.cpp | 20 +++++--------------- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/include/SFML/Graphics/Renderer.hpp b/include/SFML/Graphics/Renderer.hpp index 8b550f08..b703fe99 100644 --- a/include/SFML/Graphics/Renderer.hpp +++ b/include/SFML/Graphics/Renderer.hpp @@ -159,19 +159,6 @@ public : //////////////////////////////////////////////////////////// void SetProjection(const Matrix3& matrix); - //////////////////////////////////////////////////////////// - /// \brief Combine a new projection matrix with the current one - /// - /// Note: any call to this function after a call to BeginBatch - /// will be ignored, and delayed until BeginBatch is called again. - /// - /// \param matrix Model-view matrix to combine - /// - /// \see SetProjection - /// - //////////////////////////////////////////////////////////// - void ApplyProjection(const Matrix3& matrix); - //////////////////////////////////////////////////////////// /// \brief Set the current global color /// @@ -362,8 +349,6 @@ private : //////////////////////////////////////////////////////////// States myStatesStack[64]; ///< Stack of render states States* myStates; ///< Current set of render states - Matrix3 myTransform; ///< Current combined projection-model-view matrix - Matrix3 myProjection; ///< Current projection matrix const Image* myTexture; ///< Current texture const Shader* myShader; ///< Current pixel shader Blend::Mode myBlendMode; ///< Current blending mode diff --git a/src/SFML/Graphics/Renderer.cpp b/src/SFML/Graphics/Renderer.cpp index 29e7b7e1..b82fd793 100644 --- a/src/SFML/Graphics/Renderer.cpp +++ b/src/SFML/Graphics/Renderer.cpp @@ -78,7 +78,6 @@ void Renderer::SaveGLStates() { // Save render states GLCheck(glPushAttrib(GL_ALL_ATTRIB_BITS)); - //GLCheck(glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS)); // Save matrices GLCheck(glMatrixMode(GL_MODELVIEW)); @@ -93,7 +92,6 @@ void Renderer::RestoreGLStates() { // Restore render states GLCheck(glPopAttrib()); - //GLCheck(glPopClientAttrib()); // Restore matrices GLCheck(glMatrixMode(GL_PROJECTION)); @@ -143,14 +141,9 @@ void Renderer::ApplyModelView(const Matrix3& matrix) //////////////////////////////////////////////////////////// void Renderer::SetProjection(const Matrix3& matrix) { - myProjection = matrix; -} - - -//////////////////////////////////////////////////////////// -void Renderer::ApplyProjection(const Matrix3& matrix) -{ - myProjection *= matrix; + // Apply it immediately (this one is not critical for performances) + GLCheck(glMatrixMode(GL_PROJECTION)); + GLCheck(glLoadMatrixf(matrix.Get4x4Elements())); } @@ -276,9 +269,6 @@ void Renderer::SetShader(const Shader* shader) //////////////////////////////////////////////////////////// void Renderer::Begin(PrimitiveType type) { - // Update the combined transform matrix - myTransform = myProjection * myStates->modelView; - // Begin rendering switch (type) { @@ -330,8 +320,8 @@ void Renderer::AddVertex(float x, float y, float u, float v, const Color& color) //////////////////////////////////////////////////////////// void Renderer::ProcessVertex(float x, float y, float u, float v, float r, float g, float b, float a) { - // Transform the vertex position by the current model-view-projection matrix - Vector2f position = myTransform.Transform(Vector2f(x, y)); + // Transform the vertex position by the current model-view matrix + Vector2f position = myStates->modelView.Transform(Vector2f(x, y)); // Modulate the vertex color with the current global color r *= myStates->r;