Jump to content
  • Advertisement
Sign in to follow this  
Astra

Quad appearing infront of other Quads problem

This topic is 2567 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

Hi guys, I'm writing a 3d game, and my characters (two brown rectangles at the moment) are showing up in front of all other objects. Their Z value is 8.85, and the front and back values of the stage are 8.7 and 9.0. So i would assume my characters would go ''through'' the stage when i move them down or up, but they appear in front as though they are closest to the screen.

Here are my files I'd appreciate any input:


main.cpp
http://pastebin.com/TLnLF5Le

main.h
http://pastebin.com/UPheJgAa

keyboard.cpp
http://pastebin.com/ntJ2AF62

keyboard.h
http://pastebin.com/U0B0Vwnt

character.cpp
http://pastebin.com/2fjQWYXp

character.h
http://pastebin.com/QmXwKiug


thank you

Share this post


Link to post
Share on other sites
Advertisement
I couldn't find any setup for your depth buffer.
http://www.opengl.or...depthbuffer.htm
If you don't have any depth testing opengl will display what you have drawn last on top of everything.
Same what happens when drawing in real world.

You could also sort your objects yourself so you begin drawing with the objects which are far away.
But if you have objects which are intersecting each other that won't work.

Share this post


Link to post
Share on other sites

I couldn't find any setup for your depth buffer.
http://www.opengl.or...depthbuffer.htm
If you don't have any depth testing opengl will display what you have drawn last on top of everything.
Same what happens when drawing in real world.

You could also sort your objects yourself so you begin drawing with the objects which are far away.
But if you have objects which are intersecting each other that won't work.


thanks mate, was just missing the glEnable(GL_DEPTH_TEST) command

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!