ALLEGRO_PRIM_ATTR(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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 in ALLEGRO_PRIM_SHORT_2, ALLEGRO_PRIM_FLOAT_2 and ALLEGRO_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 an ALLEGRO_COLOR(3alleg5). plot twist: the storage field of ALLEGRO_VERTEX_ELEMENT gets ignored here. yeah. literally ignored. πŸ™ˆ
  • ALLEGRO_PRIM_TEX_COORD β€” texture coordinate info, and again it can only be stored in ALLEGRO_PRIM_FLOAT_2 and ALLEGRO_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 in ALLEGRO_PRIM_FLOAT_2 and ALLEGRO_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 most ALLEGRO_PRIM_MAX_USER_ATTR of them β€” which is currently 10 β€” and you pick which one by adding an index to the value of ALLEGRO_PRIM_USER_ATTR. so the first user attribute is ALLEGRO_PRIM_USER_ATTR + 0, the second is ALLEGRO_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