test-cogl-tex-polygon: Actually use the material it creates
test-cogl-tex-polygon creates a separate material so that it can set the texture filters. However in the paint functions that use cogl_polygon it was calling cogl_set_source_texture which replaces the material and ends up always using GL_LINEAR. This patch makes the paint functions assume the correct source is set up instead of trying to select a new source.
This commit is contained in:
parent
53cf25ef11
commit
fdf608af4c
@ -79,8 +79,7 @@ struct _TestCoglboxPrivate
|
|||||||
*--------------------------------------------------*/
|
*--------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_coglbox_fade_texture (CoglHandle tex_id,
|
test_coglbox_fade_texture (gfloat x1,
|
||||||
gfloat x1,
|
|
||||||
gfloat y1,
|
gfloat y1,
|
||||||
gfloat x2,
|
gfloat x2,
|
||||||
gfloat y2,
|
gfloat y2,
|
||||||
@ -123,26 +122,22 @@ test_coglbox_fade_texture (CoglHandle tex_id,
|
|||||||
cogl_color_premultiply (&(vertices[i].color));
|
cogl_color_premultiply (&(vertices[i].color));
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_set_source_texture (tex_id);
|
|
||||||
cogl_polygon (vertices, 4, TRUE);
|
cogl_polygon (vertices, 4, TRUE);
|
||||||
|
|
||||||
cogl_set_source_color4ub (255, 255, 255, 255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_coglbox_triangle_texture (CoglHandle tex_id,
|
test_coglbox_triangle_texture (int tex_width,
|
||||||
gfloat x,
|
int tex_height,
|
||||||
gfloat y,
|
gfloat x,
|
||||||
gfloat tx1,
|
gfloat y,
|
||||||
gfloat ty1,
|
gfloat tx1,
|
||||||
gfloat tx2,
|
gfloat ty1,
|
||||||
gfloat ty2,
|
gfloat tx2,
|
||||||
gfloat tx3,
|
gfloat ty2,
|
||||||
gfloat ty3)
|
gfloat tx3,
|
||||||
|
gfloat ty3)
|
||||||
{
|
{
|
||||||
CoglTextureVertex vertices[3];
|
CoglTextureVertex vertices[3];
|
||||||
int tex_width = cogl_texture_get_width (tex_id);
|
|
||||||
int tex_height = cogl_texture_get_height (tex_id);
|
|
||||||
|
|
||||||
vertices[0].x = x + tx1 * tex_width;
|
vertices[0].x = x + tx1 * tex_width;
|
||||||
vertices[0].y = y + ty1 * tex_height;
|
vertices[0].y = y + ty1 * tex_height;
|
||||||
@ -162,7 +157,6 @@ test_coglbox_triangle_texture (CoglHandle tex_id,
|
|||||||
vertices[2].tx = tx3;
|
vertices[2].tx = tx3;
|
||||||
vertices[2].ty = ty3;
|
vertices[2].ty = ty3;
|
||||||
|
|
||||||
cogl_set_source_texture (tex_id);
|
|
||||||
cogl_polygon (vertices, 3, FALSE);
|
cogl_polygon (vertices, 3, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,8 +189,7 @@ test_coglbox_paint (ClutterActor *self)
|
|||||||
cogl_set_source (material);
|
cogl_set_source (material);
|
||||||
cogl_rectangle_with_texture_coords (0, 0, tex_width, tex_height,
|
cogl_rectangle_with_texture_coords (0, 0, tex_width, tex_height,
|
||||||
0, 0, 1, 1);
|
0, 0, 1, 1);
|
||||||
test_coglbox_fade_texture (tex_handle,
|
test_coglbox_fade_texture (0, tex_height,
|
||||||
0, tex_height,
|
|
||||||
tex_width, (tex_height * 3 / 2),
|
tex_width, (tex_height * 3 / 2),
|
||||||
0.0, 1.0,
|
0.0, 1.0,
|
||||||
1.0, 0.5);
|
1.0, 0.5);
|
||||||
@ -209,12 +202,12 @@ test_coglbox_paint (ClutterActor *self)
|
|||||||
cogl_translate (-tex_width / 2 - 10, 0, 0);
|
cogl_translate (-tex_width / 2 - 10, 0, 0);
|
||||||
|
|
||||||
/* Draw the texture split into two triangles */
|
/* Draw the texture split into two triangles */
|
||||||
test_coglbox_triangle_texture (tex_handle,
|
test_coglbox_triangle_texture (tex_width, tex_height,
|
||||||
0, 0,
|
0, 0,
|
||||||
0, 0,
|
0, 0,
|
||||||
0, 1,
|
0, 1,
|
||||||
1, 1);
|
1, 1);
|
||||||
test_coglbox_triangle_texture (tex_handle,
|
test_coglbox_triangle_texture (tex_width, tex_height,
|
||||||
20, 0,
|
20, 0,
|
||||||
0, 0,
|
0, 0,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user