X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FCamera.cpp;fp=src%2Fgraphics%2FCamera.cpp;h=5f61d2639fb375e9233cb9053bcf2956a039d296;hb=b7d09e1e35ef90282c97509e0020b20db3c7ea9f;hp=0000000000000000000000000000000000000000;hpb=e53a0e2e711a7d8bd9b0ddacd1360aa14370643f;p=blank.git diff --git a/src/graphics/Camera.cpp b/src/graphics/Camera.cpp new file mode 100644 index 0000000..5f61d26 --- /dev/null +++ b/src/graphics/Camera.cpp @@ -0,0 +1,55 @@ +#include "Camera.hpp" + +#include "../model/geometry.hpp" + +#include +#include + + +namespace blank { + +Camera::Camera() noexcept +: fov(PI_0p25) +, aspect(1.0f) +, near_clip(0.1f) +, far_clip(256.0f) +, projection(glm::perspective(fov, aspect, near_clip, far_clip)) { + +} + + +void Camera::Viewport(int width, int height) noexcept { + Viewport(0, 0, width, height); +} + +void Camera::Viewport(int x, int y, int width, int height) noexcept { + glViewport(x, y, width, height); + Aspect(width, height); +} + +void Camera::FOV(float f) noexcept { + fov = f; + UpdateProjection(); +} + +void Camera::Aspect(float r) noexcept { + aspect = r; + UpdateProjection(); +} + +void Camera::Aspect(float w, float h) noexcept { + Aspect(w / h); +} + +void Camera::Clip(float near, float far) noexcept { + near_clip = near; + far_clip = far; + UpdateProjection(); +} + + +void Camera::UpdateProjection() noexcept { + projection = glm::perspective(fov, aspect, near_clip, far_clip); +} + +}