I am getting back into coding after many years of being gone... but I can't remember why my final image I render is being replaced or covered up with the gui.draw()?

What am i doing wrong?

Thanks!

Code: [Select]

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glPushMatrix();
glLoadIdentity();//load identity matrix

glTranslatef(4.0f, 4.0f, -4.0f);//move forward 4 units

glColor3f(0.0f, 0.0f, 1.0f); //blue color

glBegin(GL_LINE_LOOP);//start drawing a line loop
glVertex3f(-1.0f, 0.0f, 0.0f);//left of window
glVertex3f(0.0f, -1.0f, 0.0f);//bottom of window
glVertex3f(1.0f, 0.0f, 0.0f);//right of window
glVertex3f(0.0f, 1.0f, 0.0f);//top of window
glEnd();//end drawing of line loop
glPopMatrix();

gui.draw();
window.display();

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Lost on why my rendered image is covered up with TGUI widgets?
« Reply #1 on: 26 August 2015, 22:49:58 »
Since TGUI just renders with SFML I guess the problem would be that you are not saving the gl states: http://www.sfml-dev.org/tutorials/2.3/window-opengl.php#using-opengl-together-with-the-graphics-module

Re: Lost on why my rendered image is covered up with TGUI widgets?
« Reply #2 on: 26 August 2015, 22:56:01 »
Yeah I just tried this

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

         glPushMatrix();
         glLoadIdentity();//load identity matrix

         glTranslatef(.0f, .0f, -4.0f);//move forward 4 units

         glColor3f(0.0f, 0.0f, 1.0f); //blue color

         glBegin(GL_LINE_LOOP);//start drawing a line loop
         glVertex3f(-1.0f, 0.0f, 0.0f);//left of window
         glVertex3f(0.0f, -1.0f, 0.0f);//bottom of window
         glVertex3f(1.0f, 0.0f, 0.0f);//right of window
         glVertex3f(0.0f, 1.0f, 0.0f);//top of window
         glEnd();//end drawing of line loop
         glPopMatrix();

         window.pushGLStates();
         gui.draw();
         window.popGLStates();

         window.display();

works...

anyway around not push/pop states?


*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Lost on why my rendered image is covered up with TGUI widgets?
« Reply #3 on: 26 August 2015, 22:57:58 »
There is no way around it. SFML uses opengl itself and to not make it interfere with your custom opengl code you need the push and pop.

Re: Lost on why my rendered image is covered up with TGUI widgets?
« Reply #4 on: 26 August 2015, 23:05:36 »
Probably should add that to the example on the website then? save the headaches :)


*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Lost on why my rendered image is covered up with TGUI widgets?
« Reply #5 on: 26 August 2015, 23:08:33 »
This is only needed when using opengl directly and all examples use only sfml, that is why it is never mentioned.

I guess I can add an opengl example, I'm currently reorganizing the site anyway.
But as the SFML tuturial says, in more complex situations you need more than just the push/pop from sfml, so it is hard to document what you need to do exactly.