Stuck up with basics of glut :(
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
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.
The display function is called whenever the window needs to be redrawn. The reshape function is called when the window has been resized.
Originally Posted by debonair
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).