I am quite new at openGL rendering, and no matter what I do the depth depth won't work.
i obviously already enabled depth test (glEnable(GL_DEPTH_TEST);
), and i clear the buffer each frame.
But openGL keeps showing last objects rendered in front of others...
You can see my code on my github. These are the two files concerned : Main loop. My main loop is at src/tk/azertyfun/fps/Fps.java
and the render at src/tk/azertyfun/fps/objects/Mesh.java
.
I am using java and lwjgl.
As you say, you correctly enable depth testing before your rendering loop starts with:
glEnable(GL_DEPTH_TEST);
...and correctly clear the buffer at the beginning of each frame:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
The first thing you then draw in each frame via your render() method is with:
skybox.draw();
If you look at the implementation of the draw() method in Skybox, you'll see that you have:
glDisable(GL_DEPTH_TEST);
So it is disabled before you actually draw anything and never enabled again.