Hi there,
In my persuit of solving problems combining sfml2d and own opengl 3d I started working through the sources of sfml.
I checked the Graphics Rendertarget and stumbled over the folowing that I do not understand: The order of push/pop in pushGLStates and PopGLStates. I pasted the code below.
I would expect the order of the pop to be the reverse of the push, but that is not happening. Could anybody explain why this is not so? (I'm probable overlooking something here
)
push: ( clientattrib, attrib,) modelview, projection, texture
pop: projection, modelview, texture, ( clientattrib, attrib,)
I would expect: pop: texture, projection, modelview, ( attrib, clientattrib)
Thanks in advance
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
void RenderTarget::pushGLStates()
{
if (activate(true))
{
#ifdef SFML_DEBUG
// make sure that the user didn't leave an unchecked OpenGL error
GLenum error = glGetError();
if (error != GL_NO_ERROR)
{
err() << "OpenGL error (" << error << ") detected in user code, "
<< "you should check for errors with glGetError()"
<< std::endl;
}
#endif
#ifndef SFML_OPENGL_ES
glCheck(glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS));
glCheck(glPushAttrib(GL_ALL_ATTRIB_BITS));
#endif
glCheck(glMatrixMode(GL_MODELVIEW));
glCheck(glPushMatrix());
glCheck(glMatrixMode(GL_PROJECTION));
glCheck(glPushMatrix());
glCheck(glMatrixMode(GL_TEXTURE));
glCheck(glPushMatrix());
}
resetGLStates();
}
////////////////////////////////////////////////////////////
void RenderTarget::popGLStates()
{
if (activate(true))
{
glCheck(glMatrixMode(GL_PROJECTION));
glCheck(glPopMatrix());
glCheck(glMatrixMode(GL_MODELVIEW));
glCheck(glPopMatrix());
glCheck(glMatrixMode(GL_TEXTURE));
glCheck(glPopMatrix());
#ifndef SFML_OPENGL_ES
glCheck(glPopClientAttrib());
glCheck(glPopAttrib());
#endif
}
}