"Initial commit to Gerrit"
[profile/ivi/cogl.git] / tests / conform / test-sparse-pipeline.c
1 #include <cogl/cogl2-experimental.h>
2 #include <string.h>
3
4 #include "test-utils.h"
5
6 typedef struct _TestState
7 {
8   int fb_width;
9   int fb_height;
10 } TestState;
11
12 static void
13 test_sparse_layer_combine (TestState *state)
14 {
15   CoglPipeline *pipeline;
16   CoglTexture *tex1, *tex2;
17
18   cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
19
20   /* This tests that the TEXTURE_* numbers used in the layer combine
21      string refer to the layer number rather than the unit numbers by
22      creating a pipeline with very large layer numbers. This should
23      end up being mapped to much smaller unit numbers */
24
25   tex1 = test_utils_create_color_texture (ctx, 0xff0000ff);
26   tex2 = test_utils_create_color_texture (ctx, 0x00ff00ff);
27
28   pipeline = cogl_pipeline_new (ctx);
29
30   cogl_pipeline_set_layer_texture (pipeline, 50, tex1);
31   cogl_pipeline_set_layer_texture (pipeline, 100, tex2);
32   cogl_pipeline_set_layer_combine (pipeline, 200,
33                                    "RGBA = ADD(TEXTURE_50, TEXTURE_100)",
34                                    NULL);
35
36   cogl_framebuffer_draw_rectangle (fb, pipeline, -1, -1, 1, 1);
37
38   test_utils_check_pixel (fb, 2, 2, 0xffff00ff);
39
40   cogl_object_unref (pipeline);
41   cogl_object_unref (tex1);
42   cogl_object_unref (tex2);
43 }
44
45 void
46 test_sparse_pipeline (void)
47 {
48   TestState state;
49
50   state.fb_width = cogl_framebuffer_get_width (fb);
51   state.fb_height = cogl_framebuffer_get_height (fb);
52
53   test_sparse_layer_combine (&state);
54
55   /* FIXME: This should have a lot more tests, for example testing
56      whether using an attribute with sparse texture coordinates will
57      work */
58
59   if (cogl_test_verbose ())
60     g_print ("OK\n");
61 }
62