SFML community forums

Help => Graphics => Topic started by: tom_burman on April 21, 2013, 04:10:44 pm

Title: PushGLstates not working correctly
Post by: tom_burman on April 21, 2013, 04:10:44 pm
Hi guys, im trying to make a gui for my game using SFML so have been advised to use glpush and pop states. and enter my commands to draw the gui in between the push and pop. So this is what i have :

void Engine::run()
{
        while (App.isOpen())
        {
                while (c_FPSClock.getElapsedTime().asSeconds() < 1.f/60)
                {
                }


               

                // Set the active window before using OpenGL commands
                // It's useless here because active window is always the same,
                // but don't forget it if you use multiple windows or controls
                App.setActive();
               
               

                App.pushGLStates();
        App.draw(text);
        App.popGLStates();

                // Clear color and depth buffer
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                glMatrixMode(GL_MODELVIEW);
                glLoadIdentity();

               

                getInput();
                update();
                render();

                App.display();
        }
}

But this is making my game mess up pretty bad:

all i want to do is draw some text to display health and a rectangle at the bottom of the screen! haha.

I am also getting these errors in the console

Quote
An internal OpenGL call failed in RenderTarget.cpp <255> : GL_INVALID_OPPERATION,the specified opertaion is not allowed in the current state.

The game is built with C++ OpenGL and SFML to render the window and gui

Any help will be appreciated thanks