]> git.localhorst.tv Git - blank.git/blob - src/camera.cpp
rough (untested) implementation of Worley noise
[blank.git] / src / camera.cpp
1 #include "camera.hpp"
2
3 #include <GL/glew.h>
4 #include <glm/gtc/matrix_transform.hpp>
5
6
7 namespace blank {
8
9 Camera::Camera()
10 : fov(45.0f)
11 , aspect(1.0f)
12 , near_clip(0.1f)
13 , far_clip(256.0f)
14 , projection(glm::perspective(fov, aspect, near_clip, far_clip)) {
15
16 }
17
18
19 void Camera::Viewport(int width, int height) {
20         Viewport(0, 0, width, height);
21 }
22
23 void Camera::Viewport(int x, int y, int width, int height) {
24         glViewport(x, y, width, height);
25         Aspect(width, height);
26 }
27
28 void Camera::FOV(float f) {
29         fov = f;
30         UpdateProjection();
31 }
32
33 void Camera::Aspect(float r) {
34         aspect = r;
35         UpdateProjection();
36 }
37
38 void Camera::Aspect(float w, float h) {
39         Aspect(w / h);
40 }
41
42 void Camera::Clip(float near, float far) {
43         near_clip = near;
44         far_clip = far;
45         UpdateProjection();
46 }
47
48
49 void Camera::UpdateProjection() {
50         projection = glm::perspective(fov, aspect, near_clip, far_clip);
51 }
52
53 }