Is depth buffer not working ?

Started by
12 comments, last by JeffreyChen 12 years, 9 months ago
How do I solve this problem ... all objects are texture mapped cubes ... I have enabled the depth test but I cant figure out whats wrong ... is order of drawing important ?

I have labeled the order of my drawing ...
plz let me know what is wrong and how to fix it

And does the depth buffer only work with z value ?

my + z axis is up
+x axis right and
+y axis down
much like the space that appears in 3d software with +Z axis going top
Advertisement
Depth testing is enabled, but is depth writing enabled?
what is depth writing ?
if you turn off depth writing, then when you draw an object, it doesn't write its depth values to the depth buffer.

quick question, what do you mean all objects are texture mapped cubes? can you post a pic of just the "house" object?
I have mapped the texture of the cottage to a cube ..
how do I enable depth writing ?

how do I enable depth writing ?


See http://www.khronos.org/opengles/sdk/1.1/docs/man/glDepthMask.xml
You say your objects are texture mapped cubes?

What I see is that your cubes are overlapping each other and for that reason hiding objects drawn after them.

I don't exactly understand the shape of your objects and what kind of texture each object has.

For me it seems that your z-buffer is working correctly.

Seems that you could solve the problem by drawing your objects back to front order.
However, that is probably you want to avoid since you are using z-buffer.

Can you elaborate a bit your objects (like show them closer or from different angles and show the real geometry in wireframe) ?

Cheers!
Alpha channel and alpha testing is what you are looking for-


Ok, seems that you have alpha channel for your textures. Check that you use alpha testing to clip transparent pixels.

Cheers!
by default its enabled ... so to check it I enabled it and still having the same results..

public void render() {
glDepthMask(true);
glEnable(GL_TEXTURE_2D);
loadView();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Color.white.bind();

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
loadIsometricView();
setViewQuadrant(quadrant);
glTranslatef(movementInX, movementInY, 0);
drawTerrain();

glPushMatrix();
glTranslatef(-movementInX, -movementInY, 0);
c3.mapTexture(cottage, 1, GL_MODULATE);
c3.draw();
glPopMatrix();

glPushMatrix();

glTranslatef(100, 400, 0);
c2.mapTexture(tree3, 1, GL_MODULATE);
c2.draw();
glTranslatef(50, 0, 0);
c2.draw();
glTranslatef(200, -100, 0);
c2.draw();
glTranslatef(-200, +50, 0);
c3.mapTexture(cottage, 1, GL_MODULATE);
c3.draw();
glPopMatrix();

unloadIsometricView();
}

This topic is closed to new replies.

Advertisement