I have several objects on the scene, and even if I point out that object A has y = 10 (the highest object), from the TOP camera I can see the lower objects through object A. Here is an image from my scene.

And only today I found an interesting property that affects the order of models, maybe I'm wrong. Here is another image in which I change the drawing order of "ship1", note: "ship1" is the path below my scene if I ship1.draw(); , the ship disappears (correctly), but if I do ship1.draw(); in the latter, it appears from above (incorrectly).

Video : Opengl Inaccessibility Video
- Q1) Does it always have a drawing order?
- Q2) How can I fix this, should I change the drawing order every time I change the camera position?
Change I also compared the Perspective Projection class with the glm library to make sure this is not a problem with my design matrix. All is correct.
Edit1 : I have a project on git: Arkanoid git repository (windows, the project is ready to run on any computer with VS installed)
Edit2 . I do not use normals or textures. Just the tops and indexes.
Edit3 : is there a problem if every object on the scene uses (share) vertices from the same file?
Edit4 . I also changed my predicted projection values. I had about a plane at 0.0f, now I have about = 20.0f and far = 500.0f, angle = 60ΒΊ. But nothing changes, but the view is not deeper. = /
Edit5 . Here are my Vertex and Fragment shaders.
Edit6 : contact me anytime, I'm here all day, so ask me. At the moment I am rewriting the entire project from scratch. I have two cubes that look good, one opposite the other. My class has already been added for: camera, projection, shader handler. Moving to a class that creates and draws objects.
// Vertex shader in vec4 in_Position; out vec4 color; uniform mat4 Model; uniform mat4 View; uniform mat4 Projection; void main(void) { color = in_Position; gl_Position = Projection * View * Model * in_Position; } // Fragment shader
Some codes:
void setupOpenGL() { std::cerr << "CONTEXT: OpenGL v" << glGetString(GL_VERSION) << std::endl; glClearColor(0.1f, 0.1f, 0.1f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glDepthMask(GL_TRUE); glDepthRange(0.0, 1.0); glClearDepth(1.0); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glFrontFace(GL_CCW); } void display() { ++FrameCount; glClearColor(0.1f, 0.1f, 0.1f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderScene(); glutSwapBuffers(); } void renderScene() { wallNorth.draw(shader); obstacle1.draw(shader); wallEast.draw(shader); wallWest.draw(shader); ship1.draw(shader); plane.draw(shader); }