1 #include "viewport.hpp"
4 #include <glm/gtc/matrix_transform.hpp>
9 Viewport::Viewport(int w, int h)
12 , inverse_size(1.0f / float(width), 1.0f / float(height))
13 , fov(0.78539816339744830961f) // π/4
14 , aspect(float(w) / float(h))
17 , perspective(glm::perspective(fov, aspect, near, far))
18 , ortho(glm::ortho(0.0f, float(width), float(height), 0.0f, near, far)) {
22 void Viewport::Resize(int w, int h) noexcept {
25 float fw = float(w), fh = float(h);
26 inverse_size.x = 1.0f / fw;
27 inverse_size.y = 1.0f / fh;
29 perspective = glm::perspective(fov, aspect, near, far);
30 ortho = glm::ortho(0.0f, fw, fh, 0.0f, near, far);
31 glViewport(0, 0, width, height);