PDA

View Full Version : Stuck up with basics of glut :(



debonair
08-29-2013, 10:43 PM
Hi, can anyone tell me what is difference between glutDisplayFunc and glutReshapeFunc ?
my understanding is that display is called whenever window re-sizes which looks pretty much same as that of glutReshapeFunc(). Please help me with this

Alfonse Reinheart
08-30-2013, 12:09 AM
They're different in that they are in no way alike.

Yes, when the window is resized, they both get called. But you'll notice that the reshape function gets the new size, while the display function does not. They're getting called for different reasons. One is being called because the window has been resized; the other is being called because the display needs to be redrawn.

Also, you'll notice that the display function can be called even when the window isn't being resized.

GClements
08-30-2013, 05:22 AM
Hi, can anyone tell me what is difference between glutDisplayFunc and glutReshapeFunc ?
The display function is called whenever the window needs to be redrawn. The reshape function is called when the window has been resized.

Resizing the window will result in both being called. Many other things will result in the display function being called.

The display function should redraw the window.

The reshape function should do whatever needs to be done when the window is resized (e.g. change the viewport and the projection matrix to match the new size; or alternatively, store the new size so that you can set the viewport and the projection matrix in the display function).