Domanda

Firstly, sorry for the poor question title, I didn't know exactly what to put!

So I have an OpenGL application running from a SFML Window context.

I previously posted a question about poor performance, but that issue seems to be solved now.

As you can see on the images I have uploaded, something rather odd is happening. I don't know really how to describe it, but it looks like the right half of the window shouldn't be there!

Right Hand side of window starts with grey block

This is an example of what happens after resize

It looks like 2 OpenGL contexts exist side by side?

Anyone any ideas on the problem?

Here is my code:

sf::ContextSettings settings;
settings.depthBits = 32;
settings.stencilBits = 8;
settings.antialiasingLevel=4;
settings.majorVersion = 3;
settings.minorVersion = 0;

sf::Window window(sf::VideoMode(800, 600), "insert title", sf::Style::Default, settings);
window.setVerticalSyncEnabled(true);


bool running = true;
while(running)
{
    sf::Event e;
    while(window.pollEvent(e))
    {
        if(e.type == sf::Event::Closed)
        {
            running = false;
        }

        if(e.type == sf::Event::Resized)
        {
            glViewport(0, 0, e.size.width, e.size.height);
            gluLookAt(0,0,-1, 0,0,0, 0,1,0);;
        }
    }


    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    glutSolidSphere(1, 12, 12);

    window.display();
}
È stato utile?

Soluzione

Turns out this is caused by copying and pasting code.

Above the code shown, I had the lines:

sf::ContextSettings settings;
settings.depthBits = 24;
settings.stencilBits = 0;
settings.antialiasingLevel = 0;
settings.majorversion = 3;
settings.minorversion = 2;

The minor version was incorrect. Removing the lines ' settings.majorversion = 3;' and 'settings.minorversion = 2;' fixed the issue!

As an experiment I changed the major to 4. This caused the program to crash all together.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top