1ALLEGRO_VERTEX_ELEMENT(3) ALLEGRO_VERTEX_ELEMENT(3)
2
3
4
6 ALLEGRO_VERTEX_ELEMENT - Allegro 5 API
7
9 #include <allegro5/allegro_primitives.h>
10
11 typedef struct ALLEGRO_VERTEX_ELEMENT ALLEGRO_VERTEX_ELEMENT;
12
14 A small structure describing a certain element of a vertex. E.g. the
15 position of the vertex, or its color. These structures are used by the
16 al_create_vertex_decl(3) function to create the vertex declaration.
17 For that they generally occur in an array. The last element of such an
18 array should have the attribute field equal to 0, to signify that it is
19 the end of the array. Here is an example code that would create a dec‐
20 laration describing the ALLEGRO_VERTEX(3) structure (passing this as
21 vertex declaration to al_draw_prim would be identical to passing NULL):
22
23 /* On compilers without the offsetof keyword you need to obtain the
24 * offset with sizeof and make sure to account for packing.
25 */
26 ALLEGRO_VERTEX_ELEMENT elems[] = {
27 {ALLEGRO_PRIM_POSITION, ALLEGRO_PRIM_FLOAT_3, offsetof(ALLEGRO_VERTEX, x)},
28 {ALLEGRO_PRIM_TEX_COORD_PIXEL, ALLEGRO_PRIM_FLOAT_2, offsetof(ALLEGRO_VERTEX, u)},
29 {ALLEGRO_PRIM_COLOR_ATTR, 0, offsetof(ALLEGRO_VERTEX, color)},
30 {0, 0, 0}
31 };
32 ALLEGRO_VERTEX_DECL* decl = al_create_vertex_decl(elems, sizeof(ALLEGRO_VERTEX));
33
34 Fields:
35
36 • attribute - A member of the ALLEGRO_PRIM_ATTR(3) enumeration, speci‐
37 fying what this attribute signifies
38
39 • storage - A member of the ALLEGRO_PRIM_STORAGE(3) enumeration, speci‐
40 fying how this attribute is stored
41
42 • offset - Offset in bytes from the beginning of the custom vertex
43 structure. The C function offsetof is very useful here.
44
46 al_create_vertex_decl(3), ALLEGRO_VERTEX_DECL(3), ALLEGRO_PRIM_ATTR(3),
47 ALLEGRO_PRIM_STORAGE(3)
48
49
50
51Allegro reference manual ALLEGRO_VERTEX_ELEMENT(3)