PDA

View Full Version : OpenGLES 2.0 and rendering 3D objects


Chirone
06-11-2010, 08:59 AM
This is probably going to seem like a stupid question but... how do i get objects to render as you'd expect them to in OpenGLES 2?
what i mean is...
i have two models, a cone and a cube
i have a program
it has a vertex shader and a fragment shader
both models use this program and shader
the cone is placed at (512, 384, 0) on screen
the cube is place at (512, 384, 60) on screen
the cone is made in a way that the cube should appear infront of the cone
in the drawing method i can draw the cone first and then the cube and the cube appears in front of the cone
if i switch them then the cone appears in front of the cube

how do i stop this from happening and make it so that the cube is always drawn in front of the cone regardless of when it is drawn in the draw method?

changing the z coordinate in the matrix that the vertex is transformed by doesn't appear to bring objects closer or push them further away. could this be why they are drawn as if they are on the same plane?
glEnable(DepthTest) is enabled

MDuffy
06-24-2010, 11:53 PM
It sounds like the drawing surface you created doesn't have a z-buffer. I don't have any sample code to give you, but check your setup code and the docs and make sure you have at least a 16 bit z-buffer set up for your rendering.

Cheers,
Michael

CGTalk Moderation
06-24-2010, 11:53 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.