X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2Fviewport.cpp;h=4ff27920ba6d2b88b16b6391535e53aa923c5f0b;hb=HEAD;hp=4ee85c86b3c01ab15709236341a09284492a2fe7;hpb=dfe661278fe5fd69e821d530d50b78082d19ce54;p=tacos.git diff --git a/src/graphics/viewport.cpp b/src/graphics/viewport.cpp index 4ee85c8..4ff2792 100644 --- a/src/graphics/viewport.cpp +++ b/src/graphics/viewport.cpp @@ -9,10 +9,11 @@ namespace tacos { Viewport::Viewport(int w, int h) : width(w) , height(h) +, inverse_size(1.0f / float(width), 1.0f / float(height)) , fov(0.78539816339744830961f) // π/4 , aspect(float(w) / float(h)) , near(0.1f) -, far(100.0f) +, far(256.0f) , perspective(glm::perspective(fov, aspect, near, far)) , ortho(glm::ortho(0.0f, float(width), float(height), 0.0f, near, far)) { @@ -21,9 +22,12 @@ Viewport::Viewport(int w, int h) void Viewport::Resize(int w, int h) noexcept { width = w; height = h; - aspect = float(width) / float(height); + float fw = float(w), fh = float(h); + inverse_size.x = 1.0f / fw; + inverse_size.y = 1.0f / fh; + aspect = fw / fh; perspective = glm::perspective(fov, aspect, near, far); - ortho = glm::ortho(0.0f, float(width), float(height), 0.0f, near, far); + ortho = glm::ortho(0.0f, fw, fh, 0.0f, near, far); glViewport(0, 0, width, height); }