]> git.tdb.fi Git - libs/gl.git/blob - source/camera.h
Add a rendering supervisor class
[libs/gl.git] / source / camera.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2010  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_CAMERA_H_
9 #define MSP_GL_CAMERA_H_
10
11 #include "matrix.h"
12 #include "vector.h"
13
14 namespace Msp {
15 namespace GL {
16
17 class Camera
18 {
19 private:
20         float fov;
21         float aspect;
22         // Some compilers have "near" and "far" keywords
23         float clip_near;
24         float clip_far;
25         Vector3 position;
26         Vector3 look_dir;
27         Vector3 up_dir;
28         Matrix matrix;
29
30 public:
31         Camera();
32
33         void set_field_of_view(float);
34         void set_aspect(float);
35         void set_depth_clip(float, float);
36         float get_field_of_view() const { return fov; }
37         float get_aspect() const { return aspect; }
38         float get_near_clip() const { return clip_near; }
39         float get_far_clip() const { return clip_far; }
40
41         void set_position(const Vector3 &);
42         void set_look_direction(const Vector3 &);
43         void look_at(const Vector3 &);
44         void set_up_direction(const Vector3 &);
45         const Vector3 &get_position() const { return position; }
46         const Vector3 &get_look_direction() const { return look_dir; }
47         const Vector3 &get_up_direction() const { return up_dir; }
48         const Matrix &get_matrix() const { return matrix; }
49
50         Vector3 project(const Vector4 &) const;
51         Vector4 unproject(const Vector4 &) const;
52
53         void apply() const;
54
55 private:
56         void compute_matrix();
57 };
58
59 } // namespace GL
60 } // namespcae Msp
61
62 #endif