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: Horizontal/Vertical FOV GLM Projection matrix.

  1. #1
    Newbie Newbie
    Join Date
    Sep 2015
    Posts
    3

    Horizontal/Vertical FOV GLM Projection matrix.

    Hey!

    I suppose that in every new game that has an FOV(Field of view) slider in it adjusts the horizontal angle. The GLM perspective(fovy, aspect, near, far) matrix accepts an angle that is vertical.
    How can I adjust the horizontal angle? Does the projection matrix calculate the relationship between the vertical/horizontal? example: if I set the vertical angle to 65 degrees, how many degrees is the horizontal angle? I know how to calculate from vertical to horizontal and from horizontal to vertical, https://en.wikipedia.org/wiki/Field_...in_video_games.
    If I let the user to adjust the horizontal angle with a slider and then convert it afterwards to vertical with the formula described at wikipedia, will this result in a correct relationship if I use the GLM perspective function with the converted horizontal angle?


    Thanks

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,854
    Quote Originally Posted by niklasbanan View Post
    I suppose that in every new game that has an FOV(Field of view) slider in it adjusts the horizontal angle. The GLM perspective(fovy, aspect, near, far) matrix accepts an angle that is vertical.
    How can I adjust the horizontal angle?
    First, look at the definition given in the gluPerspective reference page. glm::perspective() is intended as a drop-in replacement for that function.

    Second, swap x and y. I.e. replace f=cot(fovy/2) with f=cot(fovx/2), change aspect=x/y to aspect=y/x, and change the scale factors from (f/aspect,f) to (f,f/aspect).

    If you want to avoid constructing the matrix yourself, you can just use glm::perspective() with fovy and aspect using the above definitions, then just swap the [0][0] and [1][1] elements afterwards.

  3. #3
    Newbie Newbie
    Join Date
    Sep 2015
    Posts
    3
    Thx!

    I will try this solution when I get back home!

    Thx again.

Posting Permissions

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