ALLEGRO_PRIM_ATTR(3alleg5)
π ALLEGRO_PRIM_ATTR π
okay bestie, listen up β this is from the Allegro reference manual, the 3alleg5 corner of it, aka the Allegro 5 API. we're talking about the enum that tells you what kind of vertex attributes a custom vertex can have. it's giving β¨build-your-own-vertexβ¨ energy and honestly? iconic.
β¨ SYNOPSIS β¨
#include <allegro5/allegro_primitives.h>
typedef enum ALLEGRO_PRIM_ATTR
π¦ DESCRIPTION π¦
so basically this enum is the whole menu of vertex attribute types your custom vertex can have. no cap, that's the entire vibe. here's the lineup:
ALLEGRO_PRIM_POSITIONβ the position info, bestie. it can only live inALLEGRO_PRIM_SHORT_2,ALLEGRO_PRIM_FLOAT_2andALLEGRO_PRIM_FLOAT_3. that's it, those are the only fits it will accept. πALLEGRO_PRIM_COLOR_ATTRβ color info, and it's stored in anALLEGRO_COLOR(3alleg5). plot twist: the storage field ofALLEGRO_VERTEX_ELEMENTgets ignored here. yeah. literally ignored. πALLEGRO_PRIM_TEX_COORDβ texture coordinate info, and again it can only be stored inALLEGRO_PRIM_FLOAT_2andALLEGRO_PRIM_SHORT_2. these coords get normalized by the width and height of the texture, which means the bottom-right corner has texture coordinates of(1, 1). remember that, it's on the test. πALLEGRO_PRIM_TEX_COORD_PIXELβ also texture coordinate info, also only inALLEGRO_PRIM_FLOAT_2andALLEGRO_PRIM_SHORT_2... but these ones are measured in pixels. same girls, different font. β¨ALLEGRO_PRIM_USER_ATTRβ your very own custom attribute, main character energy. you can use any storage for this one, no restrictions. you get at mostALLEGRO_PRIM_MAX_USER_ATTRof them β which is currently 10 β and you pick which one by adding an index to the value ofALLEGRO_PRIM_USER_ATTR. so the first user attribute isALLEGRO_PRIM_USER_ATTR + 0, the second isALLEGRO_PRIM_USER_ATTR + 1, and so on forever (well, up to 10). π
so like, if you wanna reach these custom attributes from GLSL shaders, you gotta declare attributes that follow this exact nomenclature: al_user_attr_# where # is the index of the attribute. iykyk.
for example, say you want a position and a normal vector for every vertex β you'd 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 you 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;
}
now, to access these custom attributes from HLSL? different ritual, bestie. you need to declare a parameter with the following semantics: TEXCOORD{# + 2} where # is the index of the attribute. so for example the first attribute can be accessed via TEXCOORD2, the 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)
πΈ go forth and declare those attributes, bestie. you got this. no cap. πΈ
okay that's the whole page!! mwah π this was Allegro reference manual, ALLEGRO_PRIM_ATTR(3alleg5) β Allegro 5 API, out here slaying since forever. bye bestie, go make some vertices πβ¨
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms