diff options
author | Simon Zeni <simon@bl4ckb0ne.ca> | 2021-09-24 09:34:51 -0400 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2021-11-18 09:37:57 -0500 |
commit | 6d6e70b9e0e40b6d38ba9276127b869bae893d43 (patch) | |
tree | 7a459cc6e4283fd3783e66d43bc5cfd0a21b945a /examples/touch.c | |
parent | 142d10e591c0f349843f718d87b44c8ba2b33476 (diff) |
examples: init wlr_output with allocator and renderer
Diffstat (limited to 'examples/touch.c')
-rw-r--r-- | examples/touch.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/examples/touch.c b/examples/touch.c index 0c9cd2b4..ae2dcf8f 100644 --- a/examples/touch.c +++ b/examples/touch.c @@ -10,8 +10,9 @@ #include <wayland-server-core.h> #include <wlr/backend.h> #include <wlr/backend/session.h> -#include <wlr/types/wlr_output.h> +#include <wlr/render/allocator.h> #include <wlr/render/wlr_renderer.h> +#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_keyboard.h> #include <wlr/types/wlr_matrix.h> @@ -23,6 +24,7 @@ struct sample_state { struct wl_display *display; struct wlr_renderer *renderer; + struct wlr_allocator *allocator; struct wlr_texture *cat_texture; struct wl_list touch_points; struct timespec last_frame; @@ -148,6 +150,9 @@ static void output_remove_notify(struct wl_listener *listener, void *data) { static void new_output_notify(struct wl_listener *listener, void *data) { struct wlr_output *output = data; struct sample_state *sample = wl_container_of(listener, sample, new_output); + + wlr_output_init_render(output, sample->allocator, sample->renderer); + struct sample_output *sample_output = calloc(1, sizeof(struct sample_output)); sample_output->output = output; sample_output->sample = sample; @@ -254,8 +259,7 @@ int main(int argc, char *argv[]) { state.new_input.notify = new_input_notify; clock_gettime(CLOCK_MONOTONIC, &state.last_frame); - - state.renderer = wlr_backend_get_renderer(wlr); + state.renderer = wlr_renderer_autocreate(wlr); if (!state.renderer) { wlr_log(WLR_ERROR, "Could not start compositor, OOM"); exit(EXIT_FAILURE); @@ -268,6 +272,8 @@ int main(int argc, char *argv[]) { exit(EXIT_FAILURE); } + state.allocator = wlr_allocator_autocreate(wlr, state.renderer); + if (!wlr_backend_start(wlr)) { wlr_log(WLR_ERROR, "Failed to start backend"); wlr_backend_destroy(wlr); |