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
This commit is contained in:
LaurentGom 2010-02-04 19:25:00 +00:00
parent e2b5268504
commit 2840618c70
2 changed files with 5 additions and 30 deletions

View File

@ -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

View File

@ -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;