From 81ae6d8bc64651e717c2a9c2cfc1a3099d0945b7 Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Sat, 13 Jul 2019 00:44:36 +0100 Subject: Remove OpenGL awareness from core logic --- src/imv.c | 6 +----- src/window.c | 9 +++++++++ src/window.h | 3 +++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/imv.c b/src/imv.c index aa99a72..6f8972b 100644 --- a/src/imv.c +++ b/src/imv.c @@ -9,8 +9,6 @@ #include #include -#include - #include "backend.h" #include "binds.h" #include "canvas.h" @@ -443,7 +441,6 @@ static void event_handler(void *data, const struct imv_event *e) const int bh = e->data.resize.buffer_height; imv_viewport_update(imv->view, ww, wh, bw, bh, imv->current_image); imv_canvas_resize(imv->canvas, bw, bh); - glViewport(0, 0, bw, bh); break; } case IMV_EVENT_KEYBOARD: @@ -985,8 +982,7 @@ int imv_run(struct imv *imv) } if (imv->need_redraw) { - glClearColor(0.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); + imv_window_clear(imv->window, 0, 0, 0); render_window(imv); imv_window_present(imv->window); } diff --git a/src/window.c b/src/window.c index ddedf84..8393fa8 100644 --- a/src/window.c +++ b/src/window.c @@ -414,6 +414,7 @@ static void toplevel_configure(void *data, struct xdg_toplevel *toplevel, } } wl_egl_window_resize(window->egl_window, width, height, 0, 0); + glViewport(0, 0, width * window->scale, height * window->scale); struct imv_event e = { .type = IMV_EVENT_RESIZE, @@ -541,6 +542,14 @@ void imv_window_free(struct imv_window *window) free(window); } +void imv_window_clear(struct imv_window *window, unsigned char r, + unsigned char g, unsigned char b) +{ + (void)window; + glClearColor(r / 255.0f, g / 255.0f, b / 255.0f, 1.0); + glClear(GL_COLOR_BUFFER_BIT); +} + void imv_window_get_size(struct imv_window *window, int *w, int *h) { if (w) { diff --git a/src/window.h b/src/window.h index 3e61043..c185b6f 100644 --- a/src/window.h +++ b/src/window.h @@ -46,6 +46,9 @@ struct imv_window *imv_window_create(int w, int h, const char *title); void imv_window_free(struct imv_window *window); +void imv_window_clear(struct imv_window *window, unsigned char r, + unsigned char g, unsigned char b); + void imv_window_get_size(struct imv_window *window, int *w, int *h); void imv_window_get_framebuffer_size(struct imv_window *window, int *w, int *h); -- cgit v1.2.3