From a77da0acc88c7fb861043fd0dcb9cc6536e591f1 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 2 Dec 2021 17:51:53 +0100 Subject: Window: add scissor --- src/gl.c | 1 + src/window/window.c | 11 +++++++++++ 2 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/gl.c b/src/gl.c index f7607c2..e9eeacb 100644 --- a/src/gl.c +++ b/src/gl.c @@ -34,6 +34,7 @@ int mgl_gl_load(mgl_gl *self) { { &self->glXSwapBuffers, "glXSwapBuffers" }, { &self->glViewport, "glViewport" }, + { &self->glScissor, "glScissor" }, { &self->glClearColor, "glClearColor" }, { &self->glClear, "glClear" }, { &self->glEnable, "glEnable" }, diff --git a/src/window/window.c b/src/window/window.c index 13bb4ba..8a6edbb 100644 --- a/src/window/window.c +++ b/src/window/window.c @@ -231,6 +231,7 @@ static void mgl_window_on_resize(mgl_window *self, int width, int height) { view.position = (mgl_vec2i){ 0, 0 }; view.size = self->size; mgl_window_set_view(self, &view); + mgl_window_set_scissor(self, &(mgl_scissor){ .position = { 0, 0 }, .size = self->size }); } static int mgl_window_init(mgl_window *self, const char *title, const mgl_window_create_params *params, Window existing_window) { @@ -721,6 +722,16 @@ void mgl_window_get_view(mgl_window *self, mgl_view *view) { *view = self->view; } +void mgl_window_set_scissor(mgl_window *self, mgl_scissor *new_scissor) { + mgl_context *context = mgl_get_context(); + self->scissor = *new_scissor; + context->gl.glScissor(self->scissor.position.x, self->scissor.position.y, self->scissor.size.x, self->scissor.size.y); +} + +void mgl_window_get_scissor(mgl_window *self, mgl_scissor *scissor) { + *scissor = self->scissor; +} + bool mgl_window_is_open(const mgl_window *self) { return self->open; } -- cgit v1.2.3