render: add simple functions to render rectangles and ellipses

This commit is contained in:
emersion 2018-03-26 12:41:51 -04:00
parent bcb74c2c78
commit 793c3b3047
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
6 changed files with 61 additions and 30 deletions

View file

@ -49,7 +49,6 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
wlr_renderer_begin(sample->renderer, wlr_output->width, wlr_output->height);
wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1});
float matrix[9];
float distance = 0.8f * (1 - sample->distance);
float tool_color[4] = { distance, distance, distance, 1 };
for (size_t i = 0; sample->button && i < 4; ++i) {
@ -61,12 +60,12 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
float pad_height = sample->height_mm * scale;
float left = width / 2.0f - pad_width / 2.0f;
float top = height / 2.0f - pad_height / 2.0f;
struct wlr_box box = {
const struct wlr_box box = {
.x = left, .y = top,
.width = pad_width, .height = pad_height,
};
wlr_matrix_project_box(matrix, &box, 0, 0, wlr_output->transform_matrix);
wlr_render_colored_quad(sample->renderer, sample->pad_color, matrix);
wlr_render_rect(sample->renderer, &box, sample->pad_color,
wlr_output->transform_matrix);
if (sample->proximity) {
struct wlr_box box = {
@ -75,16 +74,17 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
.width = 16 * (sample->pressure + 1),
.height = 16 * (sample->pressure + 1),
};
wlr_matrix_project_box(matrix, &box, 0, sample->ring,
wlr_output->transform_matrix);
wlr_render_colored_quad(sample->renderer, tool_color, matrix);
float matrix[9];
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL,
sample->ring, wlr_output->transform_matrix);
wlr_render_quad_with_matrix(sample->renderer, tool_color, matrix);
box.x += sample->x_tilt;
box.y += sample->y_tilt;
box.width /= 2;
box.height /= 2;
wlr_matrix_project_box(matrix, &box, 0, 0,
wlr_render_rect(sample->renderer, &box, tool_color,
wlr_output->transform_matrix);
wlr_render_colored_quad(sample->renderer, tool_color, matrix);
}
wlr_renderer_end(sample->renderer);