tags:

views:

227

answers:

2

I have drawn a picture with openGL on my windows. Now whenever I hold the mouse button on the windows and move it, my picture always got distorted. I don't know what function in openGL that can help me redraw the picture while the windows is moved. Anybody could help?

I tried this but seems not work:

void myDisplay()
{
   .....
}

void reshape(int x, int y)
{
   glutPostRedisplay();
}

int main()
{
   .....
   glutDisplayFunc(myDisplay);
   glutReshapeFunc(reshape);
}
+3  A: 

The first (and usually only) necessary step is to to quit using glut. glut is oriented primarily toward producing a static display, so it attempts to accumulate changes and then redraw only when the state has "stabilized" again, such as when you're done resizing the window. That made sense at one time, but mostly doesn't anymore.

Given that it's been around 10 years since glut was last updated, out of date design goals are hardly a surprise. That doesn't change the fact that it's carefully written to prevent what you want from happening. If you wanted to, you could probably rewrite it to fit your expectations better, but it'll almost certainly be quite a bit simpler to use something else that's designed to do what you want (or at least something closer to what you want).

Jerry Coffin