I'm using SFML 2.0, on Windows 7 Ultimate.
I want to create an OpenGL context that enables the depth buffer. Here is how I'm currently going about it:sf::ContextSettings context(24, 8, 2, 3, 3);
sf::Window window(sf::VideoMode(500, 500, 32), "SFML Window", 7U, context);
{ //Loads OpenGL functions
glewExperimental=TRUE;
GLenum err = glewInit();
if (GLEW_OK != err)
{
/* Problem: glewInit failed, something is seriously wrong. */
fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
}
fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
}
sf::ContextSettings windowSettings = window.GetSettings();
std::cout
<< "windowSettings.DepthBits: " << windowSettings.DepthBits << "\n"
<< "windowSettings.StencilBits: " << windowSettings.StencilBits << "\n"
<< "windowSettings.AntialiasingLevel: " << windowSettings.AntialiasingLevel << "\n"
<< "windowSettings.MajorVersion: " << windowSettings.MajorVersion << "\n"
<< "windowSettings.MinorVersion: " << windowSettings.MinorVersion << "\n";
window.SetActive();
The output is what I expect:
Status: Using GLEW 1.7.0
windowSettings.DepthBits: 24
windowSettings.StencilBits: 8
windowSettings.AntialiasingLevel: 2
windowSettings.MajorVersion: 3
windowSettings.MinorVersion: 3
I thought creating a window with an sf::ContextSettings that has some number of bits for DepthBits automatically enables the depth buffer. But it seems writing/reading from the depth buffer does not work. When I wrap my exact same OpenGL code around a freeglut framework, rather than an SFML framework, depth testing appears to work.