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 10 of 10

Thread: glviewport query

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    14

    glviewport query


    Can any1 tell me y we need to use glViewport. I am not very clear with its usage.

  2. #2
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    26

    Re: glviewport query

    The viewport is like the canvas of a paint. Once u define how big is the Frame of your paint (corresponding to the border of the window) you need to define how big is ur canvas where ur going to draw. that's the viewport. That's why it always defined in the reshape function.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    14

    Re: glviewport query

    hi

    that means that it is the area made available for drawing purposes.
    Drawing using opengl cant be done outside this portion , rite?
    But why do we need it in reshape function of window?

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    26

    Re: glviewport query

    yes potentially is the area in Pixel which defines where u can draw with OpenGL.

    Usually is callled in the reshape as the reshape event is the very first one occuring as soon as the window is creted. Suddenly followed by the display one.

    So calling the glViewport(0,0,w,h) makes sure that u always define a viewport. it's also important in case you change dimensions of the windows. it lets you openGL to update the viewport with the new dimensions.

  5. #5
    Advanced Member Frequent Contributor _NK47's Avatar
    Join Date
    Mar 2008
    Posts
    574

    Re: glviewport query

    if you remember old games like doom, duke nukem, etc. you could always decrease/increase the viewport size to get better framerates, also the image looked smaller. viewport can be any size you want but it makes too much sense if its the size of your window (also when window is resized).

  6. #6
    Junior Member Regular Contributor
    Join Date
    Aug 2005
    Posts
    148

    Re: glviewport query

    I remember having to reduce the viewport to the size of postage stamp to play Quake on my old 486 (woot!). It was a bit like peering through a keyhole (not that I ever have), but mighty fun none the less.

  7. #7
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: glviewport query

    doing that in the original Doom, down to the smaller possible size, a message appeared "buy a 486 !"

  8. #8
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    14

    Re: glviewport query


    Hi
    Thanx ppl for ur replies.

    Is the purpose of the configure event also to adjust the size of viewport whenever the window is resized?Does it have any other purpose?Is it always required to have a callback written for this event?

  9. #9
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    14

    Re: glviewport query


    Hi

    can anyone tell me where the coordinate (0,0)is located on the window ? I am getting confused with the negative values used for the first two parameters passed in glviewport function.Similarly when we use negative values for functions like glrectf what does it mean?

  10. #10
    Junior Member Regular Contributor
    Join Date
    Aug 2005
    Posts
    148

    Re: glviewport query

    That sort of depends on your transformation matrices.

    If you have a projection matrix that maps the unit square to the entirety of the viewport, like

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, viewportWidth, 0, viewportHeight, -1, 1);

    then a view space (0, 0) would be mapped to the lower left hand corner of the screen, whereas

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, viewportWidth, viewportHeight, 0, -1, 1);

    would map (0, 0) to the upper left corner, and so on.

Posting Permissions

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