PDA

View Full Version : Delete drawing from overlay



Inoss
03-24-2011, 11:52 AM
Hello everyone,

I'm new to the forum and pretty much to OpenGL as well, but I'll do my best to refrain from asking dumb questions.

I need to draw a visual aid (a circle) around the mouse cursor.
The problem is my graphics card doesn't support overlay drawing with beginOverlayDrawing() - endOverlayDrawing()
so I'm using the following code:

view->beginGL();

static bool mDrawState = false;
glPushAttrib(GL_ALL_ATTRIB_BITS);
glClear(GL_CURRENT_BIT);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble)w, 0.0, (GLdouble)h);
glMatrixMode(GL_MODELVIEW);
glShadeModel(GL_SMOOTH);

glTranslatef( 0.375f + pMouseEvent->x(), 0.375f + h - pMouseEvent->y(), 0.0f );

// Draw selection circle
glBegin( GL_LINE_LOOP );
for( int i = 0; i < 36 ; ++i )
{
float x = *radius * cos( i * 10 * 3.14159f / 180.0f );
float y = *radius * sin( i * 10 * 3.14159f / 180.0f );
glVertex2f( x, y );
}
glEnd();

glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();

if(!mDrawState)
{
#ifndef _WIN32
glXSwapBuffers(view.display(), view.window());
#else
SwapBuffers(view->deviceContext());
#endif
}

glPopAttrib();
view->endGL();

The thing is, when the mouse moves, I don't know how to erase the previous circle before drawing the new one.
Could anyone explain how to do this or where to look for information?

Thank you in advance.

Cheers,
Inos