From 61279a1947328df0b8004edebcbe405ab7b1c09e Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 3 Nov 2021 20:47:32 +0100 Subject: Add mgl_window_get_view instead of giving prev view in set_view --- src/window/window.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/window/window.c b/src/window/window.c index 44e0a23..f975c1e 100644 --- a/src/window/window.c +++ b/src/window/window.c @@ -29,14 +29,13 @@ static void set_vertical_sync_enabled(Window window, int enabled) { } static void mgl_window_on_resize(mgl_window *self, int width, int height) { - mgl_context *context = mgl_get_context(); self->size.x = width; self->size.y = height; mgl_view view; view.position = (mgl_vec2i){ 0, 0 }; view.size = self->size; - mgl_window_set_view(self, &view, NULL); + mgl_window_set_view(self, &view); } int mgl_window_create(mgl_window *self, const char *title, int width, int height) { @@ -289,10 +288,7 @@ void mgl_window_display(mgl_window *self) { context->gl.glXSwapBuffers(context->connection, self->window); } -void mgl_window_set_view(mgl_window *self, mgl_view *new_view, mgl_view *prev_view) { - if(prev_view) - *prev_view = self->view; - +void mgl_window_set_view(mgl_window *self, mgl_view *new_view) { mgl_context *context = mgl_get_context(); self->view = *new_view; context->gl.glViewport(new_view->position.x, self->size.y - new_view->size.y - new_view->position.y, new_view->size.x, new_view->size.y); @@ -300,3 +296,7 @@ void mgl_window_set_view(mgl_window *self, mgl_view *new_view, mgl_view *prev_vi context->gl.glLoadIdentity(); context->gl.glOrtho(0.0, new_view->size.x, new_view->size.y, 0.0, 0.0, 1.0); } + +void mgl_window_get_view(mgl_window *self, mgl_view *view) { + *view = self->view; +} -- cgit v1.2.3