aboutsummaryrefslogtreecommitdiff
path: root/examples/output-layers.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-04-17 19:44:33 +0200
committerAlexander Orzechowski <alex@ozal.ski>2023-05-30 16:18:19 +0000
commit8e81b4bb4237fe846e3f9eb997404aef2c396da5 (patch)
tree3ba24eebe3531a62b14194d3c51730b4b35a9ee0 /examples/output-layers.c
parent8fe29e6bd113044d35efaa538546663538196421 (diff)
examples: convert to new rendering API
Left out multi-pointer (will be removed) and quads (requires arbitrary rotation).
Diffstat (limited to 'examples/output-layers.c')
-rw-r--r--examples/output-layers.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/examples/output-layers.c b/examples/output-layers.c
index 69c97b11..0c53a18e 100644
--- a/examples/output-layers.c
+++ b/examples/output-layers.c
@@ -64,7 +64,6 @@ struct output {
static void output_handle_frame(struct wl_listener *listener, void *data) {
struct output *output = wl_container_of(listener, output, frame);
- struct wlr_renderer *renderer = output->server->renderer;
struct wl_array layers_arr = {0};
struct output_surface *output_surface;
@@ -91,15 +90,16 @@ static void output_handle_frame(struct wl_listener *listener, void *data) {
return;
}
- if (!wlr_output_attach_render(output->wlr_output, NULL)) {
- wlr_log(WLR_ERROR, "wlr_output_attach_render() failed");
- return;
- }
-
int width, height;
wlr_output_effective_resolution(output->wlr_output, &width, &height);
- wlr_renderer_begin(renderer, width, height);
- wlr_renderer_clear(renderer, (float[4]){ 0.3, 0.3, 0.3, 1.0 });
+
+ struct wlr_output_state output_state = {0};
+ struct wlr_render_pass *pass = wlr_output_begin_render_pass(output->wlr_output, &output_state, NULL);
+
+ wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){
+ .box = { .width = width, .height = height },
+ .color = { 0.3, 0.3, 0.3, 1 },
+ });
size_t i = 0;
struct wlr_output_layer_state *layers = layers_arr.data;
@@ -118,13 +118,16 @@ static void output_handle_frame(struct wl_listener *listener, void *data) {
continue;
}
- wlr_render_texture(renderer, texture, output->wlr_output->transform_matrix,
- output_surface->x, output_surface->y, 1.0);
+ wlr_render_pass_add_texture(pass, &(struct wlr_render_texture_options){
+ .texture = texture,
+ .dst_box = { .x = output_surface->x, .y = output_surface->y },
+ });
}
- wlr_renderer_end(renderer);
+ wlr_render_pass_submit(pass);
- wlr_output_commit(output->wlr_output);
+ wlr_output_commit_state(output->wlr_output, &output_state);
+ wlr_output_state_finish(&output_state);
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);