lets imagine, that i use two rectangles with these vertices:
0,0, -1,
0,-1,-1,
1,-1,-1
1,0,-1
and another
-1,-1,1
-1,1,1
1,1,1
1,-1,1
the first has green colour and second has red color.
and i create a SFML context like this:
sf::ContextSettings settings;
settings.depthBits = 24;
settings.stencilBits = 8;
settings.antialiasingLevel = 4;
settings.majorVersion = 3;
settings.minorVersion = 0;
sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, settings);
and i draw everyrhing using gl-functiins(e.g. glClear)
as result i want to see green rectangle on top of red rectangle (that how must work depth testing) but i see only red rectangle(because without depth testing everything you s draw in painters algorithm - the last drawn thing is on top of previous draw stuff
i draw everything with this code
while(window.isOpen()){
//process events
glClear(glColorBuffetBit | glDepthBufferBit);
//draw rectangle green first and then red
window.display();
}
but when i make everything myself (e.g. setup context, allocate framebuffer) depth testing works - green rectangle overlaps red rectangle.