PDA

View Full Version : Positions in the space and transparency.



UnIcron
02-14-2003, 05:48 AM
Hey, guys,
I wanna draw a ball inside a wire cube.
and the cube is drawn before the ball.
the problem is that the ball looks like floating on the surface of the cube instead of inside it.
that is i cannot see the front edges of the cube , for they are covered by the ball.

is there anything function i'd call to achieve the space relationships between objects?

Thanks.

Deiussum
02-14-2003, 06:06 AM
In your initial setup:
glEnable(GL_DEPTH_TEST);

In your display:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

nexusone
02-14-2003, 07:33 AM
How are you drawing your objects?
Are you using gl Push/pop matrix when drawing them?

Also is the depth buffer enable?


Originally posted by Unicron:
Hey, guys,
I wanna draw a ball inside a wire cube.
and the cube is drawn before the ball.
the problem is that the ball looks like floating on the surface of the cube instead of inside it.
that is i cannot see the front edges of the cube , for they are covered by the ball.

is there anything function i'd call to achieve the space relationships between objects?

Thanks.

UnIcron
02-14-2003, 11:51 PM
I did glEnable(GL_DEPTH_TEST )and glClear(...)
but the result was : the majority of the scene became black.

by the way, i used glPushMatrix at the very beginning, drew the cube, then transformations, then drew the ball, followed by glPopMatrix. is it OK?

UnIcron
02-15-2003, 12:01 AM
I got it now.

The reason might be :
1. i forgot to clear the depth_buffer_bit
2. i enabled blending( after i clear the depth buffer bit, the scene appeared but the ball moves to the back of the cube, and once the blending was disabled, the ball was placed inside the cube, could anyone tell me why ?)

I am thankful to any help.