From 6d6e70b9e0e40b6d38ba9276127b869bae893d43 Mon Sep 17 00:00:00 2001 From: Simon Zeni Date: Fri, 24 Sep 2021 09:34:51 -0400 Subject: examples: init wlr_output with allocator and renderer --- examples/output-layout.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'examples/output-layout.c') diff --git a/examples/output-layout.c b/examples/output-layout.c index 356d5d56..bc5cb7e9 100644 --- a/examples/output-layout.c +++ b/examples/output-layout.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +28,7 @@ struct sample_state { struct wl_listener new_output; struct wl_listener new_input; struct wlr_renderer *renderer; + struct wlr_allocator *allocator; struct wlr_texture *cat_texture; struct wlr_output_layout *layout; float x_offs, y_offs; @@ -158,6 +160,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)); wlr_output_layout_add_auto(sample->layout, output); sample_output->output = output; @@ -273,11 +278,13 @@ int main(int argc, char *argv[]) { wl_signal_add(&wlr->events.new_input, &state.new_input); state.new_input.notify = new_input_notify; - state.renderer = wlr_backend_get_renderer(wlr); + state.renderer = wlr_renderer_autocreate(wlr); state.cat_texture = wlr_texture_from_pixels(state.renderer, DRM_FORMAT_ABGR8888, cat_tex.width * 4, cat_tex.width, cat_tex.height, cat_tex.pixel_data); + 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); -- cgit v1.2.3