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;
}