Reputation: 1119
So I am just getting started with openGL and I'm having trouble trying to figure out how to delete an object that has already been drawn.I have 2 different rectangles
glBegin(GL_POLYGON)
glColor3f(0.5, 0.5, 0.5)
glVertex2f(0, 0)
glVertex2f(0, 10)
glVertex2f(10, 10)
glVertex2f(10, 0)
glEnd()
glBegin(GL_POLYGON)
glColor3f(0.5, 0.5, 0.5)
glVertex2f(30, 30)
glVertex2f(30, 40)
glVertex2f(40, 40)
glVertex2f(40, 30)
glEnd()
Using the mouse, I want to be able to click one of the rectangles with the right mouse button and have it be deleted. Is there some kind of function I can call that would do this?
Upvotes: 1
Views: 4154
Reputation: 8826
Your question is not an OpenGL question; it is a general logic question. If you want one of the rectangles to disappear, you need to simply not render it. Place each rectangle inside an if-statement, and set a boolean variable to false once it is clicked on.
Upvotes: 5