Archived

This topic is now archived and is closed to further replies.

Multi Layer drawing and erasing them individually

This topic is 5887 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am developing an real time application in which i want to have different individual layers on which i want to draw objects and erase them with out effecting the other layers. all the layers should be one over the other individually. how can i do it please help me out. srikanth

Share this post


Link to post
Share on other sites
I did something like that with my 2D RPG engine. You have 2 options :

-use drawing-order sorting :
Disable depth testing.
Draw a layer of objects, and then another. Remove an object from the first layer and then redraw the second layer. OpenGL will draw the second layer over the first one since it was drawn after it.

Good points : pretty fast, very easy
Bad points : multiple rendering passes

-use Z-Buffer sorting
Enable depth testing, and create a function like so :


void glDrawLayer(char layer, float depth)
{

if(layer==1)
{
glBegin(GL_WHATEVER_IT_IS_YOU_WANNA_DRAW_IN_LAYER_1)
glVertex3f(0.0, 0.0, depth);
glVertex3f(0.0, 1.0, depth);
glEnd();
}

if(layer=2)
{
glBegin(GL_WHATEVER_IT_IS_YOU_WANNA_DRAW_IN_LAYER_2)
glVertex3f(0.0, 0.0, depth);
glVertex3f(0.0, 1.0, depth);
glEnd();
}

}

At that point just call glDrawLayer(the layer you want, the depth you want)

Share this post


Link to post
Share on other sites
Thanx for the reply, but i dont want to redraw the different layers, i want to only erase one layer without effecting the other. bcos i have to maintain 7 layers to do this. so erasing all of them will be a problem. can u suggest for an better idea.


srikanth

Share this post


Link to post
Share on other sites