Argh! I made a little test program to narrow down the problem, but the application crashes on exit with the following code (I am using the exact same library versions as in my game):
#include <SFML\Window.hpp>
#include <SFML\OpenGL.hpp>
#include <SFML\Graphics.hpp>
#include <string>
int main(int argc, char* args[])
{
sf::RenderWindow appWindow;
sf::Renderer appRenderer(appWindow);
// Create a settings description struct
sf::ContextSettings settings;
// Settings for app window
settings.AntialiasingLevel = 4;
// Create the app window
appWindow.Create(sf::VideoMode(800, 600, 32), "SFML Text", sf::Style::Close, settings);
// Enable Smooth Shading
glShadeModel(GL_SMOOTH);
// Black Background
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// Depth Buffer Setup
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
// Really Nice Perspective Calculations
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
// Resize perspective to fit screen aspect ratio
glViewport(0, 0, 800, 600);
// Enable alpha rendering (transparency) in textures
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Enable alpha blending
glEnable(GL_BLEND);
// Enable texture mapping
glEnable(GL_TEXTURE_2D);
// Enable backface culling
glEnable(GL_CULL_FACE);
if(glGetError() != GL_NO_ERROR)
abort();
// Additional settings
appWindow.SetFramerateLimit(60);
appWindow.EnableVerticalSync(true);
const sf::Input &inpt(appWindow.GetInput());
sf::Text t;
t.SetFont(sf::Font::GetDefaultFont());
t.SetString("bla bla bla");
sf::Event e;
bool quit = false;
while(!quit)
{
while(appWindow.GetEvent(e))
{
// Window closed
if (e.Type == sf::Event::Closed)
quit = true;
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor4f(0.3f, 0.5f, 0.3f, 1.0f);
glBegin(GL_QUADS);
glVertex2f(10.0f, 0.0f);
glVertex2f(10.0f, 10.0f);
glVertex2f(0.0f, 10.0f);
glVertex2f(0.0f, 0.0f);
glEnd();
appRenderer.SaveGLStates();
appWindow.Draw(t);
appRenderer.RestoreGLStates();
appWindow.Display();
}
appWindow.Close();
return EXIT_SUCCESS;
}
It doesn't crash on exit if I remove the line containing the appWindow.Draw(t);
call.
What is going on here?