Getting the angle of FOV

Started by
2 comments, last by nckchan 22 years, 5 months ago
Hi, I want to implement the zoom function of a camera so I intend to change the parameter of glPerspective(). Before calling this function, how can I get the current angle of FOV of OpenGL setting?? Thx! William
chikit
Advertisement
Well, let me see... You get the projection matrix (glGet) then let''s say the fifth value (Or [1][1] if you get it as a 2D array) is Val:
We know that (from the MesaGL source code, I downloaded it long ago, lots of good stuff in there):Val = cot(FOV)So, therefore:Val = 1/tan(FOV)1/Val = tan(FOV)atan(1/Val) = FOV

Tell me if that works, it''s late so I could make mistakes .

[Resist Windows XP''s Invasive Production Activation Technology!]
thx for your help

It works after I used the sixth element to calculate and I also found that the equal should be:

FOV = atan(1/Val) * 2
chikit
Yeah, you''re right . When I said fifth I was thinking in a zero-index frame of mind.

[Resist Windows XP''s Invasive Production Activation Technology!]

This topic is closed to new replies.

Advertisement