ALLEGRO_PRIM_ATTR(3)
π 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 inALLEGRO_PRIM_SHORT_2,ALLEGRO_PRIM_FLOAT_2andALLEGRO_PRIM_FLOAT_3. thatβs the whole lineup, donβt try to sneak in anything else π«ΆALLEGRO_PRIM_COLOR_ATTRβ color information, stored in anALLEGRO_COLOR(3). the storage field ofALLEGRO_VERTEX_ELEMENTis ignored here, bestie πALLEGRO_PRIM_TEX_COORDβ texture coordinate information, and it can be stored only inALLEGRO_PRIM_FLOAT_2andALLEGRO_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 inALLEGRO_PRIM_FLOAT_2andALLEGRO_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 mostALLEGRO_PRIM_MAX_USER_ATTR(currently10) of these that you can specify by adding an index to the value ofALLEGRO_PRIM_USER_ATTR, e.g. the first user attribute isALLEGRO_PRIM_USER_ATTR + 0, the second isALLEGRO_PRIM_USER_ATTR + 1and 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