SFML community forums

Help => Graphics => Topic started by: gonrogon on June 14, 2012, 05:32:39 pm

Title: Maybe a issue in rendering with SFML mixed with OpenGL.
Post by: gonrogon on June 14, 2012, 05:32:39 pm
Hi,

In recent days, I've been trying to mix SFML with me graphic engine and I have found a possible bug. The point is that when I active the face culling the SFML text disappears.

Here is a test code:
int main(int argc, char** argv)
{
    sf::RenderWindow window(sf::VideoMode(640, 480, 32), "Test window");
    sf::Text         text;
    // Setup the text.
    text.SetString  ("Test text!");
    text.SetPosition(10.0f, 10.0f);
    // Main loop.
    while (window.IsOpen())
    {
        sf::Event event;
        // Events.
        while (window.PollEvent(event))
        {
            if (event.Type == sf::Event::Closed)
            {
                window.Close();
            }
        }
        // This causes the problem.
        glEnable(GL_CULL_FACE);
        glCullFace(GL_BACK);
        // Projection.
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(-5.0f, 5.0f, -5.0f, 5.0f, -1.0f, 1.0f);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        // Only a point.
        glPointSize(4.0f);
        glBegin(GL_POINTS);
        glVertex2f(0.0f, 0.0f);
        glEnd();
        // SFML rendering.
        window.PushGLStates();
        window.Draw(text);
        window.PopGLStates();
        window.Display();
    }
   
    return EXIT_SUCCESS;
}
 

I looked at the source code of SFML and the problem may be in the method ResetGLStates() in the class RenderTarget. I think this method should disable the face culling or set its own culling parameters.

Thanks.
Title: Re: Maybe a issue in rendering with SFML mixed with OpenGL.
Post by: Laurent on June 14, 2012, 06:03:46 pm
Thanks! It's fixed :)