---
name: "ALLEGRO_PRIM_ATTR"
section: "3alleg5"
platform: "linux"
package: "allegro5-doc"
version: "2:5.2.10.1+dfsg-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/ALLEGRO_PRIM_ATTR/3alleg5"
---

# ALLEGRO\_PRIM\_ATTR(3alleg5)

Allegro 5 API

## NAME

ALLEGRO\_PRIM\_ATTR - Allegro 5 API

## SYNOPSIS

-

  ```
  #include <allegro5/allegro_primitives.h>
  typedef enum ALLEGRO_PRIM_ATTR
  ```

## DESCRIPTION

Enumerates the types of vertex attributes that a custom vertex may have.

- •

  ALLEGRO\_PRIM\_POSITION - Position information, can be stored only in ALLEGRO\_PRIM\_SHORT\_2, ALLEGRO\_PRIM\_FLOAT\_2 and ALLEGRO\_PRIM\_FLOAT\_3.

- •

  ALLEGRO\_PRIM\_COLOR\_ATTR - Color information, stored in an ALLEGRO\_COLOR(3alleg5). The storage field of ALLEGRO\_VERTEX\_ELEMENT is ignored

- •

  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).

- •

  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.

- •

  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 `ALLEGRO_PRIM_USER_ATTR + 0`, the second is `ALLEGRO_PRIM_USER_ATTR + 1` and so on.

  To access these custom attributes from GLSL shaders you need to declare attributes that follow this nomenclature: `al_user_attr_#` where # is the index of the attribute.

  For example to have a position and a normal vector for each vertex you could declare it like this:

  -

    ```
    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}};
    ```

  And then in your vertex shader access it like this:

  -

    ```
    attribute vec3 al_pos; // ALLEGRO_PRIM_POSITION
    attribute vec3 al_user_attr_0; // ALLEGRO_PRIM_USER_ATTR + 0
    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;
    }
    ```

  To access these custom attributes from HLSL you need to declare a parameter with the following semantics: `TEXCOORD{# + 2}` where # is the index of the attribute. E.g. the first attribute can be accessed via `TEXCOORD2`, second via `TEXCOORD3` and so on.

  Since: 5.1.6

## SEE ALSO

ALLEGRO\_VERTEX\_DECL(3alleg5), ALLEGRO\_PRIM\_STORAGE(3alleg5), al\_attach\_shader\_source(3alleg5)
