~ubuntu-branches/ubuntu/vivid/clutter-1.0/vivid-proposed

« back to all changes in this revision

Viewing changes to tests/conform/test-cogl-vertex-buffer-interleved.c

  • Committer: Package Import Robot
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2014-03-26 11:51:28 UTC
  • mfrom: (1.5.1) (4.1.30 experimental)
  • Revision ID: package-import@ubuntu.com-20140326115128-timmbsde8734o6wz
Tags: 1.18.0-1
* New upstream release.
* debian/control.in:
  + Bump gtk-doc-tools build dependency.
  + Also break libcogl15.
  + Standards-Version is 3.9.5, no changes needed.
* debian/libclutter-1.0-0.symbols:
  + Drop a few symbols that were accidentally exported in the DSO because
    they had a clutter_ prefix but were not in the public headers.
  + Add one new symbol.
  + Drop unnecessary debian revisions from some symbols.
* debian/control.in,
  debian/rules,
  debian/libclutter-1.0-0.symbols:
  + Temporarily disable evdev input support. It was only enabled in 1.17.6-1
    in experimental and there is nothing using it yet, and I would like to
    wait a bit before uploading libinput to unstable as the ABI isn't stable
    yet.
* d/p/0001-wayland-Add-missing-CLUTTER_AVAILABLE-annotations.patch:
  + Add missing annotations so that a few symbols are exported in the DSO.

* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
#include <clutter/clutter.h>
3
 
#include <cogl/cogl.h>
4
 
 
5
 
#include "test-conform-common.h"
6
 
 
7
 
/* This test verifies that interleved attributes work with the vertex buffer
8
 
 * API. We add (x,y) GLfloat vertices, interleved with RGBA GLubyte color
9
 
 * attributes to a buffer, submit and draw.
10
 
 *
11
 
 * If you want visual feedback of what this test paints for debugging purposes,
12
 
 * then remove the call to clutter_main_quit() in validate_result.
13
 
 */
14
 
 
15
 
typedef struct _TestState
16
 
{
17
 
  CoglHandle buffer;
18
 
  ClutterGeometry stage_geom;
19
 
} TestState;
20
 
 
21
 
typedef struct _InterlevedVertex
22
 
{
23
 
  float x, y;
24
 
  guint8 r, g, b, a;
25
 
} InterlevedVertex;
26
 
 
27
 
 
28
 
static void
29
 
validate_result (TestState *state)
30
 
{
31
 
  guint8 pixel[4];
32
 
  int y_off = 90;
33
 
 
34
 
  /* NB: We ignore the alpha, since we don't know if our render target is
35
 
   * RGB or RGBA */
36
 
 
37
 
#define RED 0
38
 
#define GREEN 1
39
 
#define BLUE 2
40
 
 
41
 
  /* Should see a blue pixel */
42
 
  cogl_read_pixels (10, y_off, 1, 1,
43
 
                    COGL_READ_PIXELS_COLOR_BUFFER,
44
 
                    COGL_PIXEL_FORMAT_RGBA_8888_PRE,
45
 
                    pixel);
46
 
  if (g_test_verbose ())
47
 
    g_print ("pixel 0 = %x, %x, %x\n", pixel[RED], pixel[GREEN], pixel[BLUE]);
48
 
  g_assert (pixel[RED] == 0 && pixel[GREEN] == 0 && pixel[BLUE] != 0);
49
 
 
50
 
#undef RED
51
 
#undef GREEN
52
 
#undef BLUE
53
 
 
54
 
  /* Comment this out if you want visual feedback of what this test
55
 
   * paints.
56
 
   */
57
 
  clutter_main_quit ();
58
 
}
59
 
 
60
 
static void
61
 
on_paint (ClutterActor *actor, TestState *state)
62
 
{
63
 
  /* Draw a faded blue triangle */
64
 
  cogl_vertex_buffer_draw (state->buffer,
65
 
                           COGL_VERTICES_MODE_TRIANGLE_STRIP, /* mode */
66
 
                           0, /* first */
67
 
                           3); /* count */
68
 
 
69
 
  validate_result (state);
70
 
}
71
 
 
72
 
static gboolean
73
 
queue_redraw (gpointer stage)
74
 
{
75
 
  clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
76
 
 
77
 
  return TRUE;
78
 
}
79
 
 
80
 
void
81
 
test_cogl_vertex_buffer_interleved (TestConformSimpleFixture *fixture,
82
 
                                    gconstpointer data)
83
 
{
84
 
  TestState state;
85
 
  ClutterActor *stage;
86
 
  ClutterColor stage_clr = {0x0, 0x0, 0x0, 0xff};
87
 
  ClutterActor *group;
88
 
  guint idle_source;
89
 
 
90
 
  stage = clutter_stage_new ();
91
 
 
92
 
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_clr);
93
 
  clutter_actor_get_geometry (stage, &state.stage_geom);
94
 
 
95
 
  group = clutter_group_new ();
96
 
  clutter_actor_set_size (group,
97
 
                          state.stage_geom.width,
98
 
                          state.stage_geom.height);
99
 
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), group);
100
 
 
101
 
  /* We force continuous redrawing incase someone comments out the
102
 
   * clutter_main_quit and wants visual feedback for the test since we
103
 
   * wont be doing anything else that will trigger redrawing. */
104
 
  idle_source = g_idle_add (queue_redraw, stage);
105
 
 
106
 
  g_signal_connect (group, "paint", G_CALLBACK (on_paint), &state);
107
 
 
108
 
  {
109
 
    InterlevedVertex verts[3] =
110
 
      {
111
 
        { /* .x = */ 0.0, /* .y = */ 0.0,
112
 
          /* blue */
113
 
          /* .r = */ 0x00, /* .g = */ 0x00, /* .b = */ 0xff, /* .a = */ 0xff },
114
 
 
115
 
        { /* .x = */ 100.0, /* .y = */ 100.0,
116
 
          /* transparent blue */
117
 
          /* .r = */ 0x00, /* .g = */ 0x00, /* .b = */ 0xff, /* .a = */ 0x00 },
118
 
 
119
 
        { /* .x = */ 0.0, /* .y = */ 100.0,
120
 
          /* transparent blue */
121
 
          /* .r = */ 0x00, /* .g = */ 0x00, /* .b = */ 0xff, /* .a = */ 0x00 },
122
 
      };
123
 
 
124
 
    /* We assume the compiler is doing no funny struct padding for this test:
125
 
     */
126
 
    g_assert (sizeof (InterlevedVertex) == 12);
127
 
 
128
 
    state.buffer = cogl_vertex_buffer_new (3 /* n vertices */);
129
 
    cogl_vertex_buffer_add (state.buffer,
130
 
                            "gl_Vertex",
131
 
                            2, /* n components */
132
 
                            COGL_ATTRIBUTE_TYPE_FLOAT,
133
 
                            FALSE, /* normalized */
134
 
                            12, /* stride */
135
 
                            &verts[0].x);
136
 
    cogl_vertex_buffer_add (state.buffer,
137
 
                            "gl_Color",
138
 
                            4, /* n components */
139
 
                            COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
140
 
                            FALSE, /* normalized */
141
 
                            12, /* stride */
142
 
                            &verts[0].r);
143
 
    cogl_vertex_buffer_submit (state.buffer);
144
 
  }
145
 
 
146
 
  clutter_actor_show_all (stage);
147
 
 
148
 
  clutter_main ();
149
 
 
150
 
  cogl_handle_unref (state.buffer);
151
 
 
152
 
  g_source_remove (idle_source);
153
 
 
154
 
  clutter_actor_destroy (stage);
155
 
 
156
 
  if (g_test_verbose ())
157
 
    g_print ("OK\n");
158
 
}