1ALLEGRO_PRIM_ATTR(3) ALLEGRO_PRIM_ATTR(3)
2
3
4
6 ALLEGRO_PRIM_ATTR - Allegro 5 API
7
9 #include <allegro5/allegro_primitives.h>
10
11 typedef enum ALLEGRO_PRIM_ATTR
12
14 Enumerates the types of vertex attributes that a custom vertex may
15 have.
16
17 • ALLEGRO_PRIM_POSITION - Position information, can be stored only in
18 ALLEGRO_PRIM_SHORT_2, ALLEGRO_PRIM_FLOAT_2 and ALLEGRO_PRIM_FLOAT_3.
19
20 • ALLEGRO_PRIM_COLOR_ATTR - Color information, stored in an ALLE‐
21 GRO_COLOR(3). The storage field of ALLEGRO_VERTEX_ELEMENT is ignored
22
23 • ALLEGRO_PRIM_TEX_COORD - Texture coordinate information, can be
24 stored only in ALLEGRO_PRIM_FLOAT_2 and ALLEGRO_PRIM_SHORT_2. These
25 coordinates are normalized by the width and height of the texture,
26 meaning that the bottom-right corner has texture coordinates of (1,
27 1).
28
29 • ALLEGRO_PRIM_TEX_COORD_PIXEL - Texture coordinate information, can be
30 stored only in ALLEGRO_PRIM_FLOAT_2 and ALLEGRO_PRIM_SHORT_2. These
31 coordinates are measured in pixels.
32
33 • ALLEGRO_PRIM_USER_ATTR - A user specified attribute. You can use any
34 storage for this attribute. You may have at most ALLE‐
35 GRO_PRIM_MAX_USER_ATTR (currently 10) of these that you can specify
36 by adding an index to the value of ALLEGRO_PRIM_USER_ATTR, e.g. the
37 first user attribute is ALLEGRO_PRIM_USER_ATTR + 0, the second is AL‐
38 LEGRO_PRIM_USER_ATTR + 1 and so on.
39
40 To access these custom attributes from GLSL shaders you need to de‐
41 clare attributes that follow this nomenclature: al_user_attr_# where
42 # is the index of the attribute.
43
44 For example to have a position and a normal vector for each vertex
45 you could declare it like this:
46
47 ALLEGRO_VERTEX_ELEMENT elements[3] = {
48 {ALLEGRO_PRIM_POSITION, ALLEGRO_PRIM_FLOAT_3, 0},
49 {ALLEGRO_PRIM_USER_ATTR + 0, ALLEGRO_PRIM_FLOAT_3, 12},
50 {0, 0, 0}};
51
52 And then in your vertex shader access it like this:
53
54 attribute vec3 al_pos; // ALLEGRO_PRIM_POSITION
55 attribute vec3 al_user_attr_0; // ALLEGRO_PRIM_USER_ATTR + 0
56 varying float light;
57 const vec3 light_direction = vec3(0, 0, 1);
58 void main() {
59 light = dot(al_user_attr_0, light_direction);
60 gl_Position = al_pos;
61 }
62
63 To access these custom attributes from HLSL you need to declare a pa‐
64 rameter with the following semantics: TEXCOORD{# + 2} where # is the
65 index of the attribute. E.g. the first attribute can be accessed
66 via TEXCOORD2, second via TEXCOORD3 and so on.
67
68 Since: 5.1.6
69
71 ALLEGRO_VERTEX_DECL(3), ALLEGRO_PRIM_STORAGE(3), al_attach_shad‐
72 er_source(3)
73
74
75
76Allegro reference manual ALLEGRO_PRIM_ATTR(3)