ALLEGRO_PRIM_ATTR(3)

πŸ“¦
version 5.2.11.3 Β· 3 versions
, in arch rolling

πŸŽ€ ALLEGRO_PRIM_ATTR(3) πŸŽ€

okay so this is ALLEGRO_PRIM_ATTR(3), coming at you from the Library Functions Manual / Allegro reference manual, and it is literally the enum that tells you what kinds of vertex attributes a custom vertex can have. bestie, it’s giving β€œsmall enum, big shader energy” and we’re obsessed πŸ’…βœ¨


🌸 NAME 🌸

ALLEGRO_PRIM_ATTR β€” the Allegro 5 API enum for custom vertex attribute types. periodt πŸ’–


✨ SYNOPSIS ✨

              #include <allegro5/allegro_primitives.h>

              typedef enum ALLEGRO_PRIM_ATTR

πŸ¦‹ DESCRIPTION πŸ¦‹

This enum lists the types of vertex attributes that a custom vertex may have. no cap, every member matters:

  • ALLEGRO_PRIM_POSITION β€” position information, and it can be stored only in ALLEGRO_PRIM_SHORT_2, ALLEGRO_PRIM_FLOAT_2 and ALLEGRO_PRIM_FLOAT_3. that’s the whole lineup, don’t try to sneak in anything else 🫢
  • ALLEGRO_PRIM_COLOR_ATTR β€” color information, stored in an ALLEGRO_COLOR(3). the storage field of ALLEGRO_VERTEX_ELEMENT is ignored here, bestie πŸ’…
  • ALLEGRO_PRIM_TEX_COORD β€” texture coordinate information, and it 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). yes, that bottom-right corner is main character energy 🌈
  • ALLEGRO_PRIM_TEX_COORD_PIXEL β€” texture coordinate information, and it can be stored only in ALLEGRO_PRIM_FLOAT_2 and ALLEGRO_PRIM_SHORT_2. these coordinates are measured in pixels, so think pixel-precise, not normalized πŸŽ€
  • 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. the cap is real, bestie, ten custom user attrs max πŸ‘‘

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. HLSL besties stay fed too πŸ“

Since: 5.1.6 ✨


πŸ”₯ SEE ALSO πŸ”₯

these are the linked besties, go check them out when you’re done here πŸ’œ


source/version: Allegro reference manual Β· date: not listed on this page, bestie β€” so here’s your sparkly sign-off instead of that footer line. πŸ’–πŸŽ€

πŸ“¦ where this page comes from
  • arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms