SFML community forums

Help => Graphics => Topic started by: lol123 on November 30, 2013, 04:24:25 pm

Title: resetGLStates() problem
Post by: lol123 on November 30, 2013, 04:24:25 pm
Could somebody give me an example how to use resetGLStates() function to mix direct OpenGL drawing with RenderTarget.draw() function without using pushGLStates() and popGLStates? Docs (http://www.sfml-dev.org/documentation/2.1/classsf_1_1RenderTarget.php#aac7504990d27dada4bfe3c7866920765) don't help  :( Just a code snippet like that:

window.draw();
//magic
glRectf();
//magic
window.draw()
//magic
glRectf();
Title: Re: resetGLStates() problem
Post by: eXpl0it3r on November 30, 2013, 06:19:28 pm
Tutorials are great! :)

http://www.sfml-dev.org/tutorials/2.1/window-opengl.php#using-opengl-together-with-the-graphics-module
Title: Re: resetGLStates() problem
Post by: lol123 on November 30, 2013, 06:48:11 pm
I know, but the example doesn't work
Title: Re: resetGLStates() problem
Post by: Nexus on November 30, 2013, 06:51:47 pm
Why don't you tell us what doesn't work? ???
Title: Re: resetGLStates() problem
Post by: lol123 on November 30, 2013, 07:06:31 pm
Well, I want to mix OpenGL draw functions and window.draw() function. Now I surround every OpenGL functions block with popGLStates() and pushGLStates():
window.draw();

popGLStates();
glRectf();
pushGLStates();

window.draw();

popGLStates();
glRectf();
pushGLStates();

window.draw();

but that doesn't work. What am I doing wrong?
Title: Re: resetGLStates() problem
Post by: eXpl0it3r on November 30, 2013, 07:58:58 pm
I don't have experience with OpenGL, but I don't think you can switch between states multiple times for one frame. So you can just either draw OpenGL stuff first and then SFML or the other way around - not sure though.

Anyways you still haven't said what happens that let's you say "it doesn't work". Does it crash? Do you get an error? Is the drawing odd?
Title: Re: resetGLStates() problem
Post by: lol123 on November 30, 2013, 08:01:06 pm
It just doesn't draw what I draw with OpenGL calls

Thanks, I will try that
Title: Re: resetGLStates() problem
Post by: lol123 on November 30, 2013, 08:08:21 pm
No that didn't help
Title: Re: resetGLStates() problem
Post by: Laurent on November 30, 2013, 08:51:41 pm
Quote
now I surround every OpenGL functions block with popGLStates() and pushGLStates():
This is not the correct usage. Please read the tutorial one more time.