X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2Fviewport.cpp;fp=src%2Fgraphics%2Fviewport.cpp;h=4ee85c86b3c01ab15709236341a09284492a2fe7;hb=dfe661278fe5fd69e821d530d50b78082d19ce54;hp=0000000000000000000000000000000000000000;hpb=88073614253d3a9c678848a6e905c3794aa831ca;p=tacos.git diff --git a/src/graphics/viewport.cpp b/src/graphics/viewport.cpp new file mode 100644 index 0000000..4ee85c8 --- /dev/null +++ b/src/graphics/viewport.cpp @@ -0,0 +1,30 @@ +#include "viewport.hpp" + +#include +#include + + +namespace tacos { + +Viewport::Viewport(int w, int h) +: width(w) +, height(h) +, fov(0.78539816339744830961f) // π/4 +, aspect(float(w) / float(h)) +, near(0.1f) +, far(100.0f) +, perspective(glm::perspective(fov, aspect, near, far)) +, ortho(glm::ortho(0.0f, float(width), float(height), 0.0f, near, far)) { + +} + +void Viewport::Resize(int w, int h) noexcept { + width = w; + height = h; + aspect = float(width) / float(height); + perspective = glm::perspective(fov, aspect, near, far); + ortho = glm::ortho(0.0f, float(width), float(height), 0.0f, near, far); + glViewport(0, 0, width, height); +} + +}