aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-03-15 11:10:56 +0100
committeremersion <contact@emersion.fr>2018-03-15 11:10:56 +0100
commitd26b67cb06509fb39d9ed473a5d27b1f241ff635 (patch)
tree704c2732b6a3ce247dce8510eed9e629a35ce828 /render
parentb6a3f240c7621d1ebb5774fcdf7784d976500ee1 (diff)
matrix: unify API, don't use array pointers
Diffstat (limited to 'render')
-rw-r--r--render/gles2/renderer.c21
-rw-r--r--render/gles2/texture.c14
-rw-r--r--render/wlr_renderer.c9
-rw-r--r--render/wlr_texture.c4
4 files changed, 25 insertions, 23 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index 5b1395fb..9134a2fd 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -122,8 +122,8 @@ static void wlr_gles2_end(struct wlr_renderer *wlr_renderer) {
}
static void wlr_gles2_clear(struct wlr_renderer *wlr_renderer,
- const float (*color)[4]) {
- glClearColor((*color)[0], (*color)[1], (*color)[2], (*color)[3]);
+ const float color[static 4]) {
+ glClearColor(color[0], color[1], color[2], color[3]);
glClear(GL_COLOR_BUFFER_BIT);
}
@@ -171,14 +171,15 @@ static void draw_quad() {
}
static bool wlr_gles2_render_texture(struct wlr_renderer *wlr_renderer,
- struct wlr_texture *texture, const float (*matrix)[16], float alpha) {
+ struct wlr_texture *texture, const float matrix[static 16],
+ float alpha) {
if (!texture || !texture->valid) {
wlr_log(L_ERROR, "attempt to render invalid texture");
return false;
}
wlr_texture_bind(texture);
- GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, *matrix));
+ GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, matrix));
GL_CALL(glUniform1f(2, alpha));
draw_quad();
return true;
@@ -186,18 +187,18 @@ static bool wlr_gles2_render_texture(struct wlr_renderer *wlr_renderer,
static void wlr_gles2_render_quad(struct wlr_renderer *wlr_renderer,
- const float (*color)[4], const float (*matrix)[16]) {
+ const float color[static 4], const float matrix[static 16]) {
GL_CALL(glUseProgram(shaders.quad));
- GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, *matrix));
- GL_CALL(glUniform4f(1, (*color)[0], (*color)[1], (*color)[2], (*color)[3]));
+ GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, matrix));
+ GL_CALL(glUniform4f(1, color[0], color[1], color[2], color[3]));
draw_quad();
}
static void wlr_gles2_render_ellipse(struct wlr_renderer *wlr_renderer,
- const float (*color)[4], const float (*matrix)[16]) {
+ const float color[static 4], const float matrix[static 16]) {
GL_CALL(glUseProgram(shaders.ellipse));
- GL_CALL(glUniformMatrix4fv(0, 1, GL_TRUE, *matrix));
- GL_CALL(glUniform4f(1, (*color)[0], (*color)[1], (*color)[2], (*color)[3]));
+ GL_CALL(glUniformMatrix4fv(0, 1, GL_TRUE, matrix));
+ GL_CALL(glUniform4f(1, color[0], color[1], color[2], color[3]));
draw_quad();
}
diff --git a/render/gles2/texture.c b/render/gles2/texture.c
index 7a180446..0dfebc48 100644
--- a/render/gles2/texture.c
+++ b/render/gles2/texture.c
@@ -227,16 +227,16 @@ static bool gles2_texture_upload_eglimage(struct wlr_texture *wlr_tex,
}
static void gles2_texture_get_matrix(struct wlr_texture *_texture,
- float (*matrix)[16], const float (*projection)[16], int x, int y) {
+ float mat[static 16], const float projection[static 16], int x, int y) {
struct wlr_gles2_texture *texture = (struct wlr_gles2_texture *)_texture;
float world[16];
- wlr_matrix_identity(matrix);
- wlr_matrix_translate(&world, x, y, 0);
- wlr_matrix_mul(matrix, &world, matrix);
- wlr_matrix_scale(&world,
+ wlr_matrix_identity(mat);
+ wlr_matrix_translate(world, x, y, 0);
+ wlr_matrix_mul(mat, mat, world);
+ wlr_matrix_scale(world,
texture->wlr_texture.width, texture->wlr_texture.height, 1);
- wlr_matrix_mul(matrix, &world, matrix);
- wlr_matrix_mul(projection, matrix, matrix);
+ wlr_matrix_mul(mat, mat, world);
+ wlr_matrix_mul(mat, projection, mat);
}
static void gles2_texture_get_buffer_size(struct wlr_texture *texture, struct
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c
index ce8fbe36..372e4caf 100644
--- a/render/wlr_renderer.c
+++ b/render/wlr_renderer.c
@@ -23,7 +23,7 @@ void wlr_renderer_end(struct wlr_renderer *r) {
r->impl->end(r);
}
-void wlr_renderer_clear(struct wlr_renderer *r, const float (*color)[4]) {
+void wlr_renderer_clear(struct wlr_renderer *r, const float color[static 4]) {
r->impl->clear(r, color);
}
@@ -36,17 +36,18 @@ struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r) {
}
bool wlr_render_with_matrix(struct wlr_renderer *r,
- struct wlr_texture *texture, const float (*matrix)[16], float alpha) {
+ struct wlr_texture *texture, const float matrix[static 16],
+ float alpha) {
return r->impl->render_with_matrix(r, texture, matrix, alpha);
}
void wlr_render_colored_quad(struct wlr_renderer *r,
- const float (*color)[4], const float (*matrix)[16]) {
+ const float color[static 4], const float matrix[static 16]) {
r->impl->render_quad(r, color, matrix);
}
void wlr_render_colored_ellipse(struct wlr_renderer *r,
- const float (*color)[4], const float (*matrix)[16]) {
+ const float color[static 4], const float matrix[static 16]) {
r->impl->render_ellipse(r, color, matrix);
}
diff --git a/render/wlr_texture.c b/render/wlr_texture.c
index a82a16b2..0bfac32c 100644
--- a/render/wlr_texture.c
+++ b/render/wlr_texture.c
@@ -54,8 +54,8 @@ bool wlr_texture_upload_eglimage(struct wlr_texture *texture,
}
void wlr_texture_get_matrix(struct wlr_texture *texture,
- float (*matrix)[16], const float (*projection)[16], int x, int y) {
- texture->impl->get_matrix(texture, matrix, projection, x, y);
+ float mat[static 16], const float projection[static 16], int x, int y) {
+ texture->impl->get_matrix(texture, mat, projection, x, y);
}
void wlr_texture_get_buffer_size(struct wlr_texture *texture, struct wl_resource