LWJGL VBO depth overlapping

114 views Asked by At

I am attempting to draw multiple vbos in lwjgl, they render correctly but when I move the camera behind one vbo, I can still see the other in front of the object, even though it is deeper in the screen.

Here is a screenshot of the problem.

Vbo problem

Vbo problem 2

Note that this is from the back of the objects, from the front of the object in the distance, there is no problem. Also the small bulge in the corner of the farther object is to identify each one.

This code draws each vbo

    GL20.glUseProgram(ss.pId);

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, t.id);

    GL30.glBindVertexArray(g.vaoId);
    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    GL20.glEnableVertexAttribArray(2);

    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, g.vboiId);

    GL11.glDrawElements(GL11.GL_TRIANGLES, g.indices, GL11.GL_UNSIGNED_BYTE, 0);

    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
    GL20.glDisableVertexAttribArray(2);
    GL20.glUseProgram(0);

Variables included are:

g - geometry, vertices, indices, st coords, ids, (P.S: g.vboiId is the indices id and g.indices is the indices array.)

t - texture, texture id,

ss - shader set (vertex/fragment), shader ids

Please leave a comment if you need any more of my code, and thanks for your help.

0

There are 0 answers