]> git.tdb.fi Git - libs/gl.git/blob - source/camera.h
Add a Camera 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 "vector.h"
12
13 namespace Msp {
14 namespace GL {
15
16 class Camera
17 {
18 private:
19         float fov;
20         float aspect;
21         // Some compilers have "near" and "far" keywords
22         float clip_near;
23         float clip_far;
24         Vector3 position;
25         Vector3 look_dir;
26         Vector3 up_dir;
27         float matrix[16];
28
29 public:
30         Camera();
31
32         void set_field_of_view(float);
33         void set_aspect(float);
34         void set_depth_clip(float, float);
35
36         void set_position(const Vector3 &);
37         void set_look_direction(const Vector3 &);
38         void look_at(const Vector3 &);
39         void set_up_direction(const Vector3 &);
40         const Vector3 &get_position() const { return position; }
41         const Vector3 &get_look_direction() const { return look_dir; }
42         const Vector3 &get_up_direction() const { return up_dir; }
43
44         Vector3 project(const Vector4 &) 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