Jump to content

  • Log In with Google      Sign In   
  • Create Account

Quad appearing infront of other Quads problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Astra   Members   -  Reputation: 100

Like
0Likes
Like

Posted 10 July 2011 - 07:26 AM

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

Sponsor:

#2 EVIL_ENT   Members   -  Reputation: 212

Like
1Likes
Like

Posted 10 July 2011 - 08:07 AM

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.

#3 Astra   Members   -  Reputation: 100

Like
0Likes
Like

Posted 10 July 2011 - 10:23 AM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS