Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Stuck up with basics of glut :(

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    190

    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

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    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.

  3. #3
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    474
    Quote Originally Posted by debonair View Post
    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).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •