diff options
-rw-r--r-- | src/main/engine/engine.c | 18 | ||||
-rw-r--r-- | src/main/engine/ui/x11/ui.c | 1 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/main/engine/engine.c b/src/main/engine/engine.c index b4d70b0..08823a6 100644 --- a/src/main/engine/engine.c +++ b/src/main/engine/engine.c @@ -153,9 +153,27 @@ draw_frames() engine_calculate_fps(); } +static void +engine_on_ui_expose(UIEventResize *er) +{ + /* Set the viewport to the window size */ + glViewport(0, 0, er->width, er->height); + + /* 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); + + /* Returns to the model view */ + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + void engine_loop(void) { + ui_set_resize_listener(engine_on_ui_expose); ui_set_loop_listener(draw_frames); /* FPS calculation */ diff --git a/src/main/engine/ui/x11/ui.c b/src/main/engine/ui/x11/ui.c index 312bdec..7a325ce 100644 --- a/src/main/engine/ui/x11/ui.c +++ b/src/main/engine/ui/x11/ui.c @@ -146,7 +146,6 @@ ui_on_resize(XEvent event) er->height = event.xconfigure.height; on_resize_event(er); } - glViewport(0, 0, event.xconfigure.width, event.xconfigure.height); } static void |