Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: The created OpenGL context does not fully meet the settings that were requested  (Read 1110 times)

0 Members and 1 Guest are viewing this topic.

darkonaito_

  • Newbie
  • *
  • Posts: 5
    • View Profile
I'm trying to port a simple example taken by this tutorial () from Glut to SFML. I tried following the tutorial for using OpenGL in the forum, but when I run the example the Window crashed and the terminal outputs this:
Warning: The created OpenGL context does not fully meet the settings that were requested
Requested: version = 1.1 ; depth bits = 32 ; stencil bits = 0 ; AA level = 0 ; core = false ; debug = false ; sRGB = false
Created: version = 4.6 ; depth bits = 24 ; stencil bits = 0 ; AA level = 0 ; core = false ; debug = false ; sRGB = false
The code is:
#include <GL/glew.h>

#include <iostream>

#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>

using namespace sf;

GLuint buffer_handle;

void renderCallback()
{
    static GLclampf color {};

    if(color > 1.0f)
    {
        color = 0.0f;
    } else
    {
        color += 1.0f/256.0f;
    }

    glClearColor(color, 1.0f - color, 1.0f - color, 1.0f);

    glClear(GL_COLOR_BUFFER_BIT);
}

int main()
{
    // create the window
    sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, sf::ContextSettings(32));
    window.setVerticalSyncEnabled(true);

    window.setActive(true);

    bool running = true;

    while (running)
    {
        // handle events
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                // end the program
                running = false;
            }
        }

        std::cout << "OK";
        std::cin.get();

        renderCallback();

        window.display();
    }

    return 0;
}

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Did it actually crash or just output the warning?

The reason you got a warning is because OpenGL didn't allow for requesting a 32 bits depth buffer and just return you a 24bits one.
If you remove that request from the ContextSettings, the warning should disappear.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
If it is crashing, can you tell us at which point in the code that it stops?

As an aside, it's worth noting that GLclampf is clamped to 0-1 range so checking to see if it's higher that 1 doesn't make sense.
If you do need to 'go over' so you can cycle, use a float (or a GLfloat). Also, it is a bit simpler to just add the value every time and then check if it's over 1 and drop it if it is (again, still using a non-clamped float).
e.g.
static float color{ 0.f };

color += 1.f / 256.f;
if (color > 1.f)
    color = 0.f;
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything