How can I wipe off an already display triangle ?

I draw a triangle,but when I draw a new triangle, it was covered by the old one.

I don’t want to redraw the screen, just want to wipe off the old triangle or set it transparent. How can I do?


As soon as the triangle is drawn to screen its just a bunch of pixels so opengl have no information left about that triangles corners orh whats behind it. The solution is the one that you didnt want, clear and redraw everything except the triangle that you want to remove.

Thank you!
I will try other methods to solve the problem!

As Mazy already told you:

The only ‘reasonable’ way to get rid of an already drawn triangle is to redraw the hole scene without that triangle.

Why do people always try to reinvent the wheel?

it depends on your context, but you could also consider saving the buffer with the triangle not drawn, and copy it across and only redraw the triangle you want moved/deleted/transparent. This would be particularly beneficial if your scene is very expensive and you know a priori what triangle you want to move. Useful, for instance, when drawing a triangle sprite over a complicated scenes.