]> git.tdb.fi Git - libs/gl.git/blobdiff - source/camera.cpp
Field of view is an angle too
[libs/gl.git] / source / camera.cpp
index 406135796f3e10c1cc0135cb23a097ee51e32259..a3ab730d98ddd06ed167a8a0bd739b0e56554890 100644 (file)
@@ -6,7 +6,7 @@ namespace Msp {
 namespace GL {
 
 Camera::Camera():
-       fov(M_PI/4),
+       fov(Geometry::Angle<float>::from_turns(0.125)),
        aspect(4.0/3.0),
        clip_near(0.1),
        clip_far(10),
@@ -15,7 +15,7 @@ Camera::Camera():
        up_dir(0, 1, 0)
 { }
 
-void Camera::set_field_of_view(float f)
+void Camera::set_field_of_view(const Geometry::Angle<float> &f)
 {
        fov = f;
 }
@@ -58,7 +58,7 @@ void Camera::look_at(const Vector3 &p)
 
 Vector3 Camera::project(const Vector4 &p) const
 {
-       float frustum_h = tan(fov/2);
+       float frustum_h = tan(fov/2.0f);
        float frustum_w = frustum_h*aspect;
        float z_range = clip_far-clip_near;
 
@@ -75,7 +75,7 @@ Vector3 Camera::project(const Vector3 &p) const
 
 Vector4 Camera::unproject(const Vector4 &p) const
 {
-       float frustum_h = tan(fov/2);
+       float frustum_h = tan(fov/2.0f);
        float frustum_w = frustum_h*aspect;
        float z_range = clip_far-clip_near;