Quad appearing infront of other Quads problem

Started by
1 comment, last by Astra 12 years, 9 months ago
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
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.

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

This topic is closed to new replies.

Advertisement