PDA

View Full Version : display a cube inside another bigger cube



jyoung77
05-07-2003, 05:00 PM
Hi,

Is it possible to display a cube inside another bigger cube easily? I tried to disable the depth when rendering the smaller cube. I can see the smaller one in this way. But since the depth test is disabled, the smaller one has its font and back faces messed up.

Another solution may be applying some transformation? Please help. Thanks.

Tony

rgpc
05-07-2003, 05:58 PM
This isn't an advanced topic.


Look up glCullface and draw your smaller cube first (assuming you don't want your outer cube to be transparent - in which case you should set your colours to include alpha < 1, enable blending and draw your small cube first)

dorbie
05-08-2003, 02:25 PM
How about just clearing the depth buffer between cubes?

glClear(GL_DEPTH_BUFFER_BIT);

rgpc
05-08-2003, 06:12 PM
Originally posted by dorbie:
How about just clearing the depth buffer between cubes?

glClear(GL_DEPTH_BUFFER_BIT);

That might not achieve the desired result (but then again it might). It would make the smaller cube look like it's floating in front of the bigger cube. If the result is to make the smaller cube look like it is inside the larger (ie. like looking down into an open box) then culling is the best way to go...