Jump to content
  • Advertisement
Sign in to follow this  
JeffreyChen

Is depth buffer not working ?

This topic is 2566 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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?

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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();
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!