aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-08-16 15:06:38 -0400
committerDrew DeVault <sir@cmpwn.com>2017-08-17 21:05:13 -0400
commitdfb6a1203690061f9a8910028690a7a69e926b6f (patch)
treee251491092fd85d25fd6bf5fa2bd08d69e98a921 /examples
parent2e9e237f9d5485f65afbf3d8b49c740ed0653e5b (diff)
layout-output example: only render if its on the output
Diffstat (limited to 'examples')
-rw-r--r--examples/output-layout.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/output-layout.c b/examples/output-layout.c
index 81a7251b..cc363504 100644
--- a/examples/output-layout.c
+++ b/examples/output-layout.c
@@ -61,10 +61,14 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
wlr_output_layout_output_coords(sample->layout, output->output, &local_x,
&local_y);
- wlr_texture_get_matrix(sample->cat_texture, &matrix,
- &wlr_output->transform_matrix, local_x, local_y);
- wlr_render_with_matrix(sample->renderer,
- sample->cat_texture, &matrix);
+ if (local_x < width && local_x + 128 > 0 && local_y < height &&
+ local_y + 128 > 0) {
+ // render the image if it intersects with the output
+ wlr_texture_get_matrix(sample->cat_texture, &matrix,
+ &wlr_output->transform_matrix, local_x, local_y);
+ wlr_render_with_matrix(sample->renderer,
+ sample->cat_texture, &matrix);
+ }
wlr_renderer_end(sample->renderer);
wlr_output_swap_buffers(wlr_output);