PDA

View Full Version : a texture(early created)cover another texture(new)



FishLv
03-21-2012, 02:20 AM
Hi , big ones~ ,I 'm back,The game I wrote (a tank shoot planes) now has get all texture rendered correctly. Thanks~
And I get a new question : For shoot , I create a class names Collimator . I render it the time the game begin,and then create many planes.
So.. When I move the Collimator to the plane which I want to shoot,
the plane covers my collimator! Because as far as I know , the texture late created will cover the texture early created...
I just want to know how to set a texture shows that will never be covered?

tonyo_au
03-21-2012, 09:49 PM
You will have to start using the depth buffer if you don't want to sort the objects from back to front.

Have you used a depth buffer before?

FishLv
03-21-2012, 09:55 PM
Do you mean:
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);

I has already set .
But I don't quite understand how these make my textures render.
Can you give more information? Thanks~!

tonyo_au
03-22-2012, 12:08 AM
You need a z value on each vertex. If you are looking down the negative-z axis (which probably you are in a 2D render). An object drawn with say z = -1 will always cover and object drawn with z = -2 no matter the draw order

FishLv
03-22-2012, 01:58 AM
Thanks for your help ~! I got it !
Now I know the z axis can move texture deep or out of the screen~ so the texture can cover them correctly~!