3
#include "test-utils.h"
5
typedef CoglVertexP2C4 Vertex;
8
setup_orthographic_modelview (void)
11
int fb_width = cogl_framebuffer_get_width (test_fb);
12
int fb_height = cogl_framebuffer_get_height (test_fb);
14
/* Set up a non-identity modelview matrix. When the journal is
15
* flushed it will usually flush the identity matrix. Using the
16
* non-default matrix ensures that we test that Cogl restores the
17
* matrix we asked for. The matrix sets up an orthographic transform
18
* in the modelview matrix */
20
cogl_matrix_init_identity (&matrix);
21
cogl_matrix_orthographic (&matrix,
22
0.0f, 0.0f, /* x_1 y_1 */
27
cogl_framebuffer_set_modelview_matrix (test_fb, &matrix);
31
create_primitives (CoglPrimitive *primitives[2])
33
static const Vertex vertex_data[8] =
35
/* triangle strip 1 */
36
{ 0, 0, 255, 0, 0, 255 },
37
{ 0, 100, 255, 0, 0, 255 },
38
{ 100, 0, 255, 0, 0, 255 },
39
{ 100, 100, 255, 0, 0, 255 },
40
/* triangle strip 2 */
41
{ 200, 0, 0, 0, 255, 255 },
42
{ 200, 100, 0, 0, 255, 255 },
43
{ 300, 0, 0, 0, 255, 255 },
44
{ 300, 100, 0, 0, 255, 255 },
47
primitives[0] = cogl_primitive_new_p2c4 (test_ctx,
48
COGL_VERTICES_MODE_TRIANGLE_STRIP,
49
G_N_ELEMENTS (vertex_data),
51
cogl_primitive_set_n_vertices (primitives[0], 4);
53
primitives[1] = cogl_primitive_copy (primitives[0]);
54
cogl_primitive_set_first_vertex (primitives[1], 4);
55
cogl_primitive_set_n_vertices (primitives[1], 4);
59
create_pipeline (void)
61
CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
63
cogl_pipeline_set_color4ub (pipeline, 0, 255, 0, 255);
69
test_primitive_and_journal (void)
71
CoglPrimitive *primitives[2];
72
CoglPipeline *pipeline;
74
setup_orthographic_modelview ();
75
create_primitives (primitives);
76
pipeline = create_pipeline ();
78
/* Set a clip to clip all three rectangles to just the bottom half.
79
* The journal flushes its own clip state so this verifies that the
80
* clip state is correctly restored for the second primitive. */
81
cogl_framebuffer_push_rectangle_clip (test_fb,
84
cogl_framebuffer_draw_primitive (test_fb,
88
/* Draw a rectangle using the journal in-between the two primitives.
89
* This should test that the journal gets flushed correctly and that
90
* the modelview matrix is restored. Half of the rectangle should be
91
* overriden by the second primitive */
92
cogl_framebuffer_draw_rectangle (test_fb,
95
300, 100 /* x2/y2 */);
97
cogl_framebuffer_draw_primitive (test_fb,
101
/* Check the three rectangles */
102
test_utils_check_region (test_fb,
106
test_utils_check_region (test_fb,
110
test_utils_check_region (test_fb,
115
/* Check that the top half of all of the rectangles was clipped */
116
test_utils_check_region (test_fb,
121
cogl_framebuffer_pop_clip (test_fb);
123
if (cogl_test_verbose ())