diff options
author | 2025-05-20 18:10:28 +0200 | |
---|---|---|
committer | 2025-05-20 18:10:28 +0200 | |
commit | 9a1b0eb36cf9200b190f58af2c8289f5690dd0be (patch) | |
tree | f7e07260bcdd990abb8b9628acf03273fa110bf9 | |
parent | d658971135bc1016325b223a3b21007be5fcc6e8 (diff) | |
download | tris-9a1b0eb36cf9200b190f58af2c8289f5690dd0be.tar.gz tris-9a1b0eb36cf9200b190f58af2c8289f5690dd0be.zip |
Add logic to keep the ratio on resizing the window
-rw-r--r-- | src/main/engine/engine.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main/engine/engine.c b/src/main/engine/engine.c index 92222bb..ab595ac 100644 --- a/src/main/engine/engine.c +++ b/src/main/engine/engine.c @@ -185,8 +185,15 @@ engine_on_ui_expose(UIEventResize *er) /* Objects in the rendering area must maintain the proportions. So, let's enable Ortho */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); - float aspect = (float)er->width / (float)er->height; - glOrtho(-aspect, aspect, -1, 1, -1, 1); + + float aspect; + if (er->width >= er->height) { + aspect = (float)er->width / (float)er->height; + glOrtho(-aspect, aspect, -1, 1, -1, 1); + } else { + aspect = (float)er->height / (float)er->width; + glOrtho(-1, 1, -aspect, aspect, -1, 1); + } /* Returns to the model view */ glMatrixMode(GL_MODELVIEW); |