Kernael
Kernael

Reputation: 3280

OpenGL depth buffer does not seem to take effect

I recently started to code an OpenGL 3D application and have followed several tutorials, such as open.gl.

I'm currently facing a rendering problem when trying to display my objects in 3D, the depth buffer simply does not seem to work. Wether I enable it, clear the buffer bit, or not, the display is always the same.

Even when copy-pasting the code from open.gl, the 3D is never effective.

The only things that differ with my test code and the source code above is that I can't use the #version 150 core of GLSL, thus using #version 130. and a #define GLM_FORCE_RADIANS to avoid compilation errors.

Upvotes: 0

Views: 155

Answers (1)

Kernael
Kernael

Reputation: 3280

I figured out my problem.

The problem was coming from the context initialization with the SFML, I needed to configure a proper ContextSettings class and pass it to my window :

  sf::ContextSettings           settings;
  settings.depthBits            = 24;
  settings.stencilBits          = 8;
  settings.antialiasingLevel    = 2;

  sf::Window window(sf::VideoMode(800, 600, 32), "OpenGL", sf::Style::Titlebar | sf::Style::Close, settings);

Upvotes: 1

Related Questions