Sign in to follow this  

Quad appearing infront of other Quads problem

This topic is 2349 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
[url="http://pastebin.com/TLnLF5Le"]http://pastebin.com/TLnLF5Le[/url]

main.h
[url="http://pastebin.com/UPheJgAa"]http://pastebin.com/UPheJgAa[/url]

keyboard.cpp
[url="http://pastebin.com/ntJ2AF62"]http://pastebin.com/ntJ2AF62[/url]

keyboard.h
[url="http://pastebin.com/U0B0Vwnt"]http://pastebin.com/U0B0Vwnt[/url]

character.cpp
[url="http://pastebin.com/2fjQWYXp"]http://pastebin.com/2fjQWYXp[/url]

character.h
[url="http://pastebin.com/QmXwKiug"]http://pastebin.com/QmXwKiug[/url]


thank you

Share this post


Link to post
Share on other sites
I couldn't find any setup for your depth buffer.
[url="http://www.opengl.org/resources/faq/technical/depthbuffer.htm"]http://www.opengl.or...depthbuffer.htm[/url]
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
[quote name='EVIL_ENT' timestamp='1310306836' post='4833326']
I couldn't find any setup for your depth buffer.
[url="http://www.opengl.org/resources/faq/technical/depthbuffer.htm"]http://www.opengl.or...depthbuffer.htm[/url]
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.
[/quote]

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

Share this post


Link to post
Share on other sites

This topic is 2349 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this