Order of 2d objects in OpenGL

I need to use two different kinds of 2d objects in my program. One of them must appear always behind (like a wall paper). The other one, always in first order (always visble).

Can I do that using the Depht Buffer?

All is programed in 3D, but using the third coordenate equal to zero.

The depth buffer is used to determin what object drawing order is based on Z axis level.

With depth off your drawing order is based on first draw object are drawn over by next object, so you have to draw far objects first the near last.

but you can just draw your 2D using the Z axis as a level value.
Z = -1 = far level (backgound)
Z = 0 = middle level.( object area )
Z = 1 = near level ( forground )

I hope this gives you the idea.

Originally posted by nusuto:
[b]I need to use two different kinds of 2d objects in my program. One of them must appear always behind (like a wall paper). The other one, always in first order (always visble).

Can I do that using the Depht Buffer?

All is programed in 3D, but using the third coordenate equal to zero.

[/b]

You do something like:
glDisable( GL_DEPTH_TEST );
DrawWallPaper();
DrawOther2DObject();
glEnable( GL_DEPTH_TEST );

I am pretty sure this should work.

-Drew

I guess drawing the back object first, then other objects, and at the very end the front object is too easy, do you have a limitation that prevents you from doing this?

> Can I do that using the Depht Buffer?

yes, assign z values <0 for back objects,
0 for other objects and >0 for front objects

>All is programed in 3D, but using the third coordenate equal to zero.

well change z
or sort the drawing of your object according to their group.

have fun!
cb

Thank you all.

I can’t separate both kinds of objects (It’s my problem). But all your explanations lead me to think that using the z coordenate and Enable(GL_DEPTH_TEST), I can do that. I’ll try.

Thanks again.