From bb761e760aebe4c61bc61c6736ca98f6fa6058e1 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 19 Mar 2009 16:46:07 +0000 Subject: [PATCH] Removes a hack in gles/cogl.c that was already fixed in gl/cogl.c It removes the need to cast a CoglMatrix to a float * for transforming a vertex manually instead of using cogl_matrix_transform_point. --- gles/cogl.c | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/gles/cogl.c b/gles/cogl.c index 0d8ccfacd..aba1ace80 100644 --- a/gles/cogl.c +++ b/gles/cogl.c @@ -249,29 +249,20 @@ cogl_set_source_color (const CoglColor *color) } static void -apply_matrix (const float *matrix, float *vertex) -{ - int x, y; - float vertex_out[4] = { 0 }; - - for (y = 0; y < 4; y++) - for (x = 0; x < 4; x++) - vertex_out[y] += vertex[x] * matrix[y + x * 4]; - - memcpy (vertex, vertex_out, sizeof (vertex_out)); -} - -static void -project_vertex (float *modelview, - float *project, +project_vertex (const CoglMatrix *modelview_matrix, + const CoglMatrix *projection_matrix, float *vertex) { int i; /* Apply the modelview matrix */ - apply_matrix (modelview, vertex); + cogl_matrix_transform_point (modelview_matrix, + &vertex[0], &vertex[1], + &vertex[2], &vertex[3]); /* Apply the projection matrix */ - apply_matrix (project, vertex); + cogl_matrix_transform_point (projection_matrix, + &vertex[0], &vertex[1], + &vertex[2], &vertex[3]); /* Convert from homogenized coordinates */ for (i = 0; i < 4; i++) vertex[i] /= vertex[3]; @@ -334,8 +325,6 @@ _cogl_set_clip_planes (float x_offset, { CoglMatrix modelview_matrix; CoglMatrix projection_matrix; - GLfloat *modelview; - GLfloat *projection; float vertex_tl[4] = { x_offset, y_offset, 0, 1.0 }; float vertex_tr[4] = { x_offset + width, y_offset, 0, 1.0 }; @@ -343,23 +332,15 @@ _cogl_set_clip_planes (float x_offset, float vertex_br[4] = { x_offset + width, y_offset + height, 0, 1.0 }; - /* hack alert: there's no way to get *and modify* - * CoglMatrix as a float array. So we just - * use a cast instead of cogl_matrix_get_array(), - * and know that we will not call any more CoglMatrix - * methods after we write to it directly. - */ _cogl_get_matrix (COGL_MATRIX_PROJECTION, &projection_matrix); - projection = (GLfloat*) &projection_matrix; _cogl_get_matrix (COGL_MATRIX_MODELVIEW, &modelview_matrix); - modelview = (GLfloat*) &modelview_matrix; - project_vertex (modelview, projection, vertex_tl); - project_vertex (modelview, projection, vertex_tr); - project_vertex (modelview, projection, vertex_bl); - project_vertex (modelview, projection, vertex_br); + project_vertex (&modelview_matrix, &projection_matrix, vertex_tl); + project_vertex (&modelview_matrix, &projection_matrix, vertex_tr); + project_vertex (&modelview_matrix, &projection_matrix, vertex_bl); + project_vertex (&modelview_matrix, &projection_matrix, vertex_br); /* If the order of the top and bottom lines is different from the order of the left and right lines then the clip rect must have