Lost on why my rendered image is covered up with TGUI widgets?

Started by Mars_999, 26 August 2015, 22:47:35

Mars_999

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!



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


Mars_999

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

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.

Mars_999

Probably should add that to the example on the website then? save the headaches :)


texus

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.