.\" Automatically generated by Pandoc 3.6.1 .\" .TH "ALLEGRO_PRIM_ATTR" "3" "" "Allegro reference manual" .SH NAME ALLEGRO_PRIM_ATTR \- Allegro 5 API .SH SYNOPSIS .IP .EX #include \f[B]\f[R] \f[B]typedef\f[R] \f[B]enum\f[R] ALLEGRO_PRIM_ATTR .EE .SH DESCRIPTION Enumerates the types of vertex attributes that a custom vertex may have. .IP \[bu] 2 ALLEGRO_PRIM_POSITION \- Position information, can be stored only in ALLEGRO_PRIM_SHORT_2, ALLEGRO_PRIM_FLOAT_2 and ALLEGRO_PRIM_FLOAT_3. .IP \[bu] 2 ALLEGRO_PRIM_COLOR_ATTR \- Color information, stored in an ALLEGRO_COLOR(3). The storage field of ALLEGRO_VERTEX_ELEMENT is ignored .IP \[bu] 2 ALLEGRO_PRIM_TEX_COORD \- Texture coordinate information, can be stored only in ALLEGRO_PRIM_FLOAT_2 and ALLEGRO_PRIM_SHORT_2. These coordinates are normalized by the width and height of the texture, meaning that the bottom\-right corner has texture coordinates of (1, 1). .IP \[bu] 2 ALLEGRO_PRIM_TEX_COORD_PIXEL \- Texture coordinate information, can be stored only in ALLEGRO_PRIM_FLOAT_2 and ALLEGRO_PRIM_SHORT_2. These coordinates are measured in pixels. .IP \[bu] 2 ALLEGRO_PRIM_USER_ATTR \- A user specified attribute. You can use any storage for this attribute. You may have at most ALLEGRO_PRIM_MAX_USER_ATTR (currently 10) of these that you can specify by adding an index to the value of ALLEGRO_PRIM_USER_ATTR, e.g.\ the first user attribute is \f[CR]ALLEGRO_PRIM_USER_ATTR + 0\f[R], the second is \f[CR]ALLEGRO_PRIM_USER_ATTR + 1\f[R] and so on. .RS 2 .PP To access these custom attributes from GLSL shaders you need to declare attributes that follow this nomenclature: \f[CR]al_user_attr_#\f[R] where # is the index of the attribute. .PP For example to have a position and a normal vector for each vertex you could declare it like this: .IP .EX ALLEGRO_VERTEX_ELEMENT elements[3] = { {ALLEGRO_PRIM_POSITION, ALLEGRO_PRIM_FLOAT_3, 0}, {ALLEGRO_PRIM_USER_ATTR + 0, ALLEGRO_PRIM_FLOAT_3, 12}, {0, 0, 0}}; .EE .PP And then in your vertex shader access it like this: .IP .EX attribute vec3 al_pos; \f[I]// ALLEGRO_PRIM_POSITION\f[R] attribute vec3 al_user_attr_0; \f[I]// ALLEGRO_PRIM_USER_ATTR + 0\f[R] varying float light; const vec3 light_direction = vec3(0, 0, 1); void main() { light = dot(al_user_attr_0, light_direction); gl_Position = al_pos; } .EE .PP To access these custom attributes from HLSL you need to declare a parameter with the following semantics: \f[CR]TEXCOORD{# + 2}\f[R] where # is the index of the attribute. E.g. the first attribute can be accessed via \f[CR]TEXCOORD2\f[R], second via \f[CR]TEXCOORD3\f[R] and so on. .PP Since: 5.1.6 .RE .SH SEE ALSO ALLEGRO_VERTEX_DECL(3), ALLEGRO_PRIM_STORAGE(3), al_attach_shader_source(3)