]> git.tdb.fi Git - libs/gl.git/blob - source/camera.h
Field of view is an angle too
[libs/gl.git] / source / camera.h
1 #ifndef MSP_GL_CAMERA_H_
2 #define MSP_GL_CAMERA_H_
3
4 #include "matrix.h"
5 #include "vector.h"
6
7 namespace Msp {
8 namespace GL {
9
10 class Camera
11 {
12 private:
13         Geometry::Angle<float> fov;
14         float aspect;
15         // Some compilers have "near" and "far" keywords
16         float clip_near;
17         float clip_far;
18         Vector3 position;
19         Vector3 look_dir;
20         Vector3 up_dir;
21         Matrix matrix;
22
23 public:
24         Camera();
25
26         void set_field_of_view(const Geometry::Angle<float> &);
27         void set_aspect(float);
28         void set_depth_clip(float, float);
29         const Geometry::Angle<float> &get_field_of_view() const { return fov; }
30         float get_aspect() const { return aspect; }
31         float get_near_clip() const { return clip_near; }
32         float get_far_clip() const { return clip_far; }
33
34         void set_position(const Vector3 &);
35         void set_look_direction(const Vector3 &);
36         void look_at(const Vector3 &);
37         void set_up_direction(const Vector3 &);
38         const Vector3 &get_position() const { return position; }
39         const Vector3 &get_look_direction() const { return look_dir; }
40         const Vector3 &get_up_direction() const { return up_dir; }
41         const Matrix &get_matrix() const { return matrix; }
42
43         Vector3 project(const Vector4 &) const;
44         Vector3 project(const Vector3 &) const;
45         Vector4 unproject(const Vector4 &) const;
46
47         void apply() const;
48
49 private:
50         void compute_matrix();
51 };
52
53 } // namespace GL
54 } // namespcae Msp
55
56 #endif