# Thread: Horizontal/Vertical FOV GLM Projection matrix.

1. ## 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. Originally Posted by niklasbanan
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. 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
•