Screen refreshes when another window is displayed above it

I have just started OpenGL and have written a basic program that displays random shapes.

If I drag a different window over the window or hover the mouse over the minimise or maximise buttons on the window the screen refreshes (and new shapes appear).

I tried using a variable which incremented when the procedure was run and the procedure would only run if it was below 1 which works fine for the min/max problem but when I drag a new window over it draws it on and it stays due to it not refreshing.

Is there any way of redrawing the screen with the original image but without running my display procedure which creates new images.

Thanks in advance.

Would have to look at your code, but I would think that you have the routines that change your display in your display routine.

Best to not have anything but drawing code in the display() routine and keep drawning changes done in a control loop.

This way when the display is called after a window event, only the last data is redisplayed and not new data created.

Originally posted by rickp101:
[b]I have just started OpenGL and have written a basic program that displays random shapes.

If I drag a different window over the window or hover the mouse over the minimise or maximise buttons on the window the screen refreshes (and new shapes appear).

I tried using a variable which incremented when the procedure was run and the procedure would only run if it was below 1 which works fine for the min/max problem but when I drag a new window over it draws it on and it stays due to it not refreshing.

Is there any way of redrawing the screen with the original image but without running my display procedure which creates new images.

Thanks in advance.[/b]