diff options
Diffstat (limited to 'src/main/engine/engine.c')
-rw-r--r-- | src/main/engine/engine.c | 18 |
1 files changed, 18 insertions, 0 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 */ |