Removes need for casting (const float *) to (GLfloat *) in _cogl_set_clip_planes
This removes cogl.c:apply_matrix(), and makes cogl.c:project_vertex() use cogl_matrix_transform_point instead.
This commit is contained in:
parent
08932584b5
commit
20a2f76e1f
@ -326,29 +326,20 @@ cogl_set_source_color (const CoglColor *color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_matrix (const float *matrix, float *vertex)
|
project_vertex (const CoglMatrix *modelview_matrix,
|
||||||
{
|
const CoglMatrix *projection_matrix,
|
||||||
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,
|
|
||||||
float *vertex)
|
float *vertex)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Apply the modelview matrix */
|
/* 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 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 */
|
/* Convert from homogenized coordinates */
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
vertex[i] /= vertex[3];
|
vertex[i] /= vertex[3];
|
||||||
@ -409,8 +400,6 @@ _cogl_set_clip_planes (float x_offset,
|
|||||||
{
|
{
|
||||||
CoglMatrix modelview_matrix;
|
CoglMatrix modelview_matrix;
|
||||||
CoglMatrix projection_matrix;
|
CoglMatrix projection_matrix;
|
||||||
GLfloat *modelview;
|
|
||||||
GLfloat *projection;
|
|
||||||
|
|
||||||
float vertex_tl[4] = { x_offset, y_offset, 0, 1.0 };
|
float vertex_tl[4] = { x_offset, y_offset, 0, 1.0 };
|
||||||
float vertex_tr[4] = { x_offset + width, y_offset, 0, 1.0 };
|
float vertex_tr[4] = { x_offset + width, y_offset, 0, 1.0 };
|
||||||
@ -418,23 +407,15 @@ _cogl_set_clip_planes (float x_offset,
|
|||||||
float vertex_br[4] = { x_offset + width, y_offset + height,
|
float vertex_br[4] = { x_offset + width, y_offset + height,
|
||||||
0, 1.0 };
|
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,
|
_cogl_get_matrix (COGL_MATRIX_PROJECTION,
|
||||||
&projection_matrix);
|
&projection_matrix);
|
||||||
projection = (GLfloat*) &projection_matrix;
|
|
||||||
_cogl_get_matrix (COGL_MATRIX_MODELVIEW,
|
_cogl_get_matrix (COGL_MATRIX_MODELVIEW,
|
||||||
&modelview_matrix);
|
&modelview_matrix);
|
||||||
modelview = (GLfloat*) &modelview_matrix;
|
|
||||||
|
|
||||||
project_vertex (modelview, projection, vertex_tl);
|
project_vertex (&modelview_matrix, &projection_matrix, vertex_tl);
|
||||||
project_vertex (modelview, projection, vertex_tr);
|
project_vertex (&modelview_matrix, &projection_matrix, vertex_tr);
|
||||||
project_vertex (modelview, projection, vertex_bl);
|
project_vertex (&modelview_matrix, &projection_matrix, vertex_bl);
|
||||||
project_vertex (modelview, projection, vertex_br);
|
project_vertex (&modelview_matrix, &projection_matrix, vertex_br);
|
||||||
|
|
||||||
/* If the order of the top and bottom lines is different from the
|
/* 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
|
order of the left and right lines then the clip rect must have
|
||||||
|
Loading…
Reference in New Issue
Block a user