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

Thread: can't adjust camera!

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2013
    Posts
    8

    can't adjust camera!

    Hi all,

    I writed a opengl program and i want to use perspective projection, but i can't show my scence correct, how can i understand what is best value for gluprespective and glulookat?!
    if anyone wants also i can send my code in private message, but i can't puted here because it's my homework!

  2. #2
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,136
    If it is a homework, you should learn how to do it by yourself.
    Maybe I'm boring with my proposals to read something firs, but I think it is essential to have a firm understanding of basic concepts before going any further.
    So, please take a look at Chapter 3 of the old red book.

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2013
    Posts
    8
    Hey man, i read this part two times! i know all conceptions, but i can't understand just for example in that chapter in example 3.1 how we can understand that we should set near and far parameter in glfrustum in reshape function to 1.5 and 20!!!! i think someone should explain for me so simple like some materials for dummies!!!!

  4. #4
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,136
    Near and far clip-planes should frame all objects in the scene.
    Values 1.5 and 20.0 for near and far clip-planes mean: "only objects at distance from 1.5 to 20.0 "units" from the camera will be rendered".
    You are free to choose whatever values you like as long as near clip-plane is not 0.0 and far/near ratio is less than 10e5 (or so).
    Value 0.0 will produce a singularity in a perspective projection matrix, while the ratio greater than 10e5 will probably make artifacts caused by z-fighting.

  5. #5
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    490
    Quote Originally Posted by Aleksandar View Post
    You are free to choose whatever values you like as long as near clip-plane is not 0.0 and far/near ratio is less than 10e5 (or so).
    As a rule of thumb, half of the range of depth values will be mapped to the Z range [zNear,2*zNear] and the other half to [2*zNear,zFar]. Similarly, 90% of the depth range will be mapped to [zNear,10*zNear] versus 10% for [10*zNear,zFar], and more generally [N*zNear,zFar] gets roughly 1/N of the range.

    E.g. if zNear is 1 and zFar is 1000, the Z range [1,10] (the closest 1% to the near plane) gets 90% of the depth range and the range [10,1000] (the other 99%) gets the other 10%.

    IOW, the greater the ratio zFar/zNear, the greater the non-linearity in the depth values, i.e. the more they'll be clustered close to the near plane, resulting in poor depth resolution in the rest of the scene.

Posting Permissions

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