From 379835c42f182aa2c8fa814dea20a325361f8bdf Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 14 Aug 2020 10:31:44 +0200 Subject: examples/simple: use wlr_renderer instead of GL --- examples/simple.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/simple.c b/examples/simple.c index 965e97be..e3af1a11 100644 --- a/examples/simple.c +++ b/examples/simple.c @@ -1,5 +1,4 @@ #define _POSIX_C_SOURCE 200112L -#include #include #include #include @@ -8,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -18,7 +18,7 @@ struct sample_state { struct wl_listener new_output; struct wl_listener new_input; struct timespec last_frame; - float color[3]; + float color[4]; int dec; }; @@ -40,6 +40,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { struct sample_output *sample_output = wl_container_of(listener, sample_output, frame); struct sample_state *sample = sample_output->sample; + struct wlr_output *wlr_output = sample_output->output; + struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); @@ -56,12 +58,15 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { sample->dec = inc; } - wlr_output_attach_render(sample_output->output, NULL); + wlr_output_attach_render(wlr_output, NULL); - glClearColor(sample->color[0], sample->color[1], sample->color[2], 1.0); - glClear(GL_COLOR_BUFFER_BIT); + struct wlr_renderer *renderer = + wlr_backend_get_renderer(wlr_output->backend); + wlr_renderer_begin(renderer, wlr_output->width, wlr_output->height); + wlr_renderer_clear(renderer, sample->color); + wlr_renderer_end(renderer); - wlr_output_commit(sample_output->output); + wlr_output_commit(wlr_output); sample->last_frame = now; } @@ -162,7 +167,7 @@ int main(void) { wlr_log_init(WLR_DEBUG, NULL); struct wl_display *display = wl_display_create(); struct sample_state state = { - .color = { 1.0, 0.0, 0.0 }, + .color = { 1.0, 0.0, 0.0, 1.0 }, .dec = 0, .last_frame = { 0 }, .display = display -- cgit v1.2.3