diff options
Diffstat (limited to 'src/graphics.h')
| -rw-r--r-- | src/graphics.h | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/graphics.h b/src/graphics.h index 56d16de..0dd916e 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -4,6 +4,7 @@ #include <wayland-egl.h> #include "utils.h" +#include "window.h" enum graphics_error_e : u8 { GRAPHICS_ERROR_NONE = 0, @@ -25,10 +26,45 @@ void wayc_graphics_deinit(struct graphics_s* graphics); enum renderer_error_e : u8 { RENDERER_ERROR_NONE = 0, + RENDERER_ERROR_WINDOW_CREATION, + RENDERER_ERROR_SURFACE_CREATION, }; struct renderer_s { struct graphics_s* graphics; - wl_egl_window_t window; - EGLSurface surface; + wl_egl_window_t ewindow; + EGLSurface esurface; + + i32 width, height; }; + +enum renderer_error_e wayc_renderer_init(struct renderer_s* renderer, + struct window_s* window, + struct graphics_s* graphics, i32 width, + i32 height); +static inline void wayc_renderer_resize(struct renderer_s* renderer, i32 width, + i32 height) { + wayc_notnull(renderer); + renderer->width = width; + renderer->height = height; + wl_egl_window_resize(renderer->ewindow, width, height, 0, 0); +} + +static inline void wayc_renderer_use(struct renderer_s* renderer) { + wayc_notnull(renderer); + struct graphics_s* graphics = renderer->graphics; + EGLDisplay display = graphics->display; + + eglMakeCurrent(display, renderer->esurface, renderer->esurface, + graphics->context); +} + +static inline void wayc_renderer_swap(struct renderer_s* renderer) { + wayc_notnull(renderer); + struct graphics_s* graphics = renderer->graphics; + EGLDisplay display = graphics->display; + + eglSwapBuffers(display, renderer->esurface); +} + +void wayc_renderer_deinit(struct renderer_s* renderer); |
