1ALLEGRO_VERTEX_ELEMENT(3)  Library Functions Manual  ALLEGRO_VERTEX_ELEMENT(3)
2
3
4

NAME

6       ALLEGRO_VERTEX_ELEMENT
7

SYNOPSIS

9              #include <allegro5/allegro_primitives.h>
10
11              typedef struct ALLEGRO_VERTEX_ELEMENT ALLEGRO_VERTEX_ELEMENT;
12

DESCRIPTION

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  function  to create the vertex declaration.  For
17       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 structure (passing this as ver‐
21       tex 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 enumeration, specifying
37         what this attribute signifies
38
39       · storage  - A member of the ALLEGRO_PRIM_STORAGE enumeration, specify‐
40         ing how this attribute is stored
41
42       · offset - Offset in bytes from the  beginning  of  the  custom  vertex
43         structure.  C function offsetof is very useful here.
44

SEE ALSO

46       al_create_vertex_decl(3),   ALLEGRO_VERTEX_DECL(3),  ALLEGRO_PRIM_STOR‐
47       AGE(3)
48
49
50
51Allegro reference manual                             ALLEGRO_VERTEX_ELEMENT(3)
Impressum