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

Thread: glFrustum scaling effect seemingly too large

  1. #1
    Newbie Newbie
    Join Date
    Oct 2013
    Posts
    2

    glFrustum scaling effect seemingly too large

    Hi, I'm fairly new to OpenGL, so perhaps I'm completely wrong about this, but it seems to me that the rate at which shapes shrink as they are moved away from the camera (along the z axis) is too much (for me, anyway).
    What I am trying to do is to get a rotating cube that lies completely within the field of view (or projection, I guess) and that occupies a relatively large portion of the screen. I achieved the desired result when using glOrtho (as the cube doesn't shrink when it moves down the z axis); but whenever I try it with glFrustum, the cube is always tiny. The reason for this, is that for the cube to be completely within the field of view it needed to be moved back so far; and when it was moved back so far, it was always really small, due to the large reduction in size by being moved on the z axis.

    As an example of the reduction amount (in word form), when I place a square with screen width and height dicrectly in front of the camera (z=-1), it fills the screen (as expected). However, when I move said square back one unit along the z axis (z=-2) the square shrinks to 1/2 or, maybe, 2/3 of its original size. Another unit along the z axis decreases its size significantly again, etc.

    So, my question is: is it possible to reduce the rate at which objecs shrink/grow when moved along the z axis? Or is there some other way to enlarge objects removed along the z axis, and still keep them within the field of view?


    My OpenGL version is 4.2, by the way (if it matters )

  2. #2
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,072
    Quote Originally Posted by Zaakari View Post
    So, my question is: is it possible to reduce the rate at which objecs shrink/grow when moved along the z axis? Or is there some other way to enlarge objects removed along the z axis, and still keep them within the field of view
    "The rate of shrinking", as you call it, can be changed by varying near/far clip-plane distance.
    But, before going any further, please read something about perspective definition, and how glFrustum() and gluPerspective() work. You need to understand some basic concepts...

  3. #3
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    474
    Perspective scaling is always a strict reciprocal relationship: if you double the distance of the object from the viewpoint, the scale factor will halve.

    Assuming that you want the correct aspect ratio, the only other parameter involved is the field-of-view angle. If you reduce the angle so that the object needs to be placed at e.g. z=-3 in order to fill the screen, then a 1-unit change to z=-4 will only reduce the scale by 3/4 rather than 1/2.

  4. #4
    Newbie Newbie
    Join Date
    Oct 2013
    Posts
    2
    Quote Originally Posted by Aleksandar
    "The rate of shrinking", as you call it, can be changed by varying near/far clip-plane distance.
    Ah, I tried changing the far clip-plane, but didn't think to change the near; that worked. Thank you.
    And thank you GClements, that helps my understanding of it.

Posting Permissions

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