summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-02-18 12:30:41 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-02-18 12:30:41 +0100
commit1635f59f28454908411d6f41ba11a04f84cf9668 (patch)
tree3176c8333f08053262c466c7383fd6b1ec95401c
parent714390250377d88376b7336900b9806cdcefc23a (diff)
set proper viewport size
-rw-r--r--main.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/main.cpp b/main.cpp
index f9daa3be..c4796f3a 100644
--- a/main.cpp
+++ b/main.cpp
@@ -95,7 +95,9 @@ atlas_texture application::make_atlas(const std::string& file, Vector2i dims)
Matrix4x4 application::make_projection(Vector3 offset)
{
auto m = glm::mat4{1};
- m = glm::ortho<float>(-256, 256, -256, 256, -512, 512);
+ auto size = windowSize();
+ float x = size[0]*.5f, y = size[1]*.5f, w = 4*sqrt(x*x+y*y);
+ m = glm::ortho<float>(-x, x, -y, y, -w, w);
m = glm::translate(m, { offset[0], -offset[1], offset[2] });
m = glm::scale(m, { 1.f, 0.6f, 1.f });
m = glm::rotate(m, glm::radians(-45.f), glm::vec3(1.0f, 0.0f, 0.0f));