SFML community forums

Help => Graphics => Topic started by: charliesnike on November 24, 2014, 01:45:41 pm

Title: PushGLstates not working correctly
Post by: charliesnike on November 24, 2014, 01:45:41 pm
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:

    The input isn't working like before at all
    The player is rendering below the map


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
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
Title: Re: PushGLstates not working correctly
Post by: Nexus on November 24, 2014, 02:19:23 pm
As you're just beginning to use SFML, I think it's a really bad idea to mix it with OpenGL... Why not make your game working with SFML, and once you have that and are familiar with the library, you can still consider to delve into raw OpenGL? Although this usually only makes sense if you do stuff that SFML can't do, or you simply want to experiment.

Furthermore, read this thread (http://en.sfml-dev.org/forums/index.php?topic=5559), it helps you get more answers in the future.