In my
graphics application I use OpenGL calls, vertex buffers and shaders for rendering a scene. Onto that scene I want to draw text using SFML's graphics capabilities. (I use the last SFML 2.0 snapshot and
SFML's internaly used GLEW.)
Since SFML internally uses OpenGL for drawing, I need to store the OpenGL state before, reset it for SFML, and restore it afterwards. I know that there is a function called "
RenderTarget::pushGLStates()" which first stores the current OpenGL state and resets it to the SFML defaults. But I figured out that this function isn't enough.
Using just the function mentioned above there is no text displayed even if I comment out the draw calls for the scene. (By the way, font loading is successful.)
// draw scene using OpenGL
// ...
// store the state
window.pushGLStates();
// draw text using SFML
Text text("Hello World", font, 15);
window.draw(text);
// restore the state
window.popGLStates();
// display and swap buffers
// ...
Still not drawing scene objects, added the following calls for resetting the OpenGL state, the text is displayed.
// draw scene using OpenGL
// ...
// store the state
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
window.pushGLStates();
// draw text using SFML
Text text("Hello World", font, 15);
window.draw(text);
// restore the state
window.popGLStates();
// display and swap buffers
// ...
But when I enable the scene drawing again, no text is displayed. What of the OpenGL state do I have to reset by myself for displaying text using SFML? Do I have to care about shader uniforms I set for rendering the scene?