mirror of
https://github.com/SFML/SFML.git
synced 2025-01-19 15:55:13 +08:00
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:
parent
e2b5268504
commit
2840618c70
@ -159,19 +159,6 @@ public :
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void SetProjection(const Matrix3& matrix);
|
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
|
/// \brief Set the current global color
|
||||||
///
|
///
|
||||||
@ -362,8 +349,6 @@ private :
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
States myStatesStack[64]; ///< Stack of render states
|
States myStatesStack[64]; ///< Stack of render states
|
||||||
States* myStates; ///< Current set 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 Image* myTexture; ///< Current texture
|
||||||
const Shader* myShader; ///< Current pixel shader
|
const Shader* myShader; ///< Current pixel shader
|
||||||
Blend::Mode myBlendMode; ///< Current blending mode
|
Blend::Mode myBlendMode; ///< Current blending mode
|
||||||
|
@ -78,7 +78,6 @@ void Renderer::SaveGLStates()
|
|||||||
{
|
{
|
||||||
// Save render states
|
// Save render states
|
||||||
GLCheck(glPushAttrib(GL_ALL_ATTRIB_BITS));
|
GLCheck(glPushAttrib(GL_ALL_ATTRIB_BITS));
|
||||||
//GLCheck(glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS));
|
|
||||||
|
|
||||||
// Save matrices
|
// Save matrices
|
||||||
GLCheck(glMatrixMode(GL_MODELVIEW));
|
GLCheck(glMatrixMode(GL_MODELVIEW));
|
||||||
@ -93,7 +92,6 @@ void Renderer::RestoreGLStates()
|
|||||||
{
|
{
|
||||||
// Restore render states
|
// Restore render states
|
||||||
GLCheck(glPopAttrib());
|
GLCheck(glPopAttrib());
|
||||||
//GLCheck(glPopClientAttrib());
|
|
||||||
|
|
||||||
// Restore matrices
|
// Restore matrices
|
||||||
GLCheck(glMatrixMode(GL_PROJECTION));
|
GLCheck(glMatrixMode(GL_PROJECTION));
|
||||||
@ -143,14 +141,9 @@ void Renderer::ApplyModelView(const Matrix3& matrix)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Renderer::SetProjection(const Matrix3& matrix)
|
void Renderer::SetProjection(const Matrix3& matrix)
|
||||||
{
|
{
|
||||||
myProjection = matrix;
|
// Apply it immediately (this one is not critical for performances)
|
||||||
}
|
GLCheck(glMatrixMode(GL_PROJECTION));
|
||||||
|
GLCheck(glLoadMatrixf(matrix.Get4x4Elements()));
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
void Renderer::ApplyProjection(const Matrix3& matrix)
|
|
||||||
{
|
|
||||||
myProjection *= matrix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -276,9 +269,6 @@ void Renderer::SetShader(const Shader* shader)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Renderer::Begin(PrimitiveType type)
|
void Renderer::Begin(PrimitiveType type)
|
||||||
{
|
{
|
||||||
// Update the combined transform matrix
|
|
||||||
myTransform = myProjection * myStates->modelView;
|
|
||||||
|
|
||||||
// Begin rendering
|
// Begin rendering
|
||||||
switch (type)
|
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)
|
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
|
// Transform the vertex position by the current model-view matrix
|
||||||
Vector2f position = myTransform.Transform(Vector2f(x, y));
|
Vector2f position = myStates->modelView.Transform(Vector2f(x, y));
|
||||||
|
|
||||||
// Modulate the vertex color with the current global color
|
// Modulate the vertex color with the current global color
|
||||||
r *= myStates->r;
|
r *= myStates->r;
|
||||||
|
Loading…
Reference in New Issue
Block a user