Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: zooming using gluOrtho2D

  1. #1
    Newbie Newbie
    Join Date
    Mar 2018

    zooming using gluOrtho2D


    I'm wondering if somebody could help me figure out how to zoom in/out in 2D using gluOrtho2D.
    Currently I have glViewport(0, 0, 400, 300) and gluOrtho2D(0.0, 400.0, 0.0, 300.0) but I am uncertain as to how these work together.
    So, how might I do this and maintain aspect ratio so the objects in the view don't get stretched and stay in the center of the window?


  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    To preserve the aspect ratio, the ratio (r-l)/(t-b) for gluOrtho2D() should be equal to w/h for glViewport().

    But if you just want to zoom by a specific factor, it's probably simpler to just apply a glScale() transformation to the projection matrix after gluOrtho2D().

Posting Permissions

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