ALLEGRO_VERTEX_ELEMENT(3)

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

πŸ’… ALLEGRO_VERTEX_ELEMENT(3) πŸ’…

okay so this is the ALLEGRO_VERTEX_ELEMENT page from the Library Functions Manual β€” Allegro 5 API, bestie, and it's genuinely not scary, promise 🫢


✨ SYNOPSIS ✨

#include <allegro5/allegro_primitives.h>

typedef struct ALLEGRO_VERTEX_ELEMENT ALLEGRO_VERTEX_ELEMENT;

🌸 DESCRIPTION 🌸

okay so picture this: it's a tiny little structure that describes one certain element of a vertex πŸ‘‘. like, the position of the vertex, or its color. that's it. that's the whole vibe. it's giving "small but iconic" ✨

these structures get used by the al_create_vertex_decl(3) function to create the vertex declaration β€” and for that, they generally show up in an array πŸ¦‹. and here's the part you cannot skip, bestie: the last element of such an array should have the attribute field equal to 0, to signify that it's the end of the array. it's the "k bye" of the array. the terminator. no cap πŸ’€

here's example code that would create a declaration describing the ALLEGRO_VERTEX(3) structure (and passing this as vertex declaration to al_draw_prim would be identical to passing NULL, iykyk):

/* On compilers without the offsetof keyword you need to obtain the
 * offset with sizeof and make sure to account for packing.
 */
ALLEGRO_VERTEX_ELEMENT elems[] = {
   {ALLEGRO_PRIM_POSITION, ALLEGRO_PRIM_FLOAT_3, offsetof(ALLEGRO_VERTEX, x)},
   {ALLEGRO_PRIM_TEX_COORD_PIXEL, ALLEGRO_PRIM_FLOAT_2, offsetof(ALLEGRO_VERTEX, u)},
   {ALLEGRO_PRIM_COLOR_ATTR, 0, offsetof(ALLEGRO_VERTEX, color)},
   {0, 0, 0}
};
ALLEGRO_VERTEX_DECL* decl = al_create_vertex_decl(elems, sizeof(ALLEGRO_VERTEX));

πŸŽ€ Fields πŸŽ€

  • attribute β€” a member of the ALLEGRO_PRIM_ATTR(3) enumeration, specifying what this attribute signifies πŸ’–
  • storage β€” a member of the ALLEGRO_PRIM_STORAGE(3) enumeration, specifying how this attribute is stored 🌈
  • offset β€” offset in bytes from the beginning of the custom vertex structure. the C function offsetof is very useful here, fr fr ⭐
lowkey the offsetof thing is the whole magic trick, bestie β€” it's how you tell Allegro where in your struct each thing lives πŸ’…

πŸ‘€ SEE ALSO πŸ‘€

al_create_vertex_decl(3), ALLEGRO_VERTEX_DECL(3), ALLEGRO_PRIM_ATTR(3), ALLEGRO_PRIM_STORAGE(3)


and that's the whole page, bestie, you ate that πŸ“ go forth and declare your vertices slay πŸ’œ

this has been the Allegro reference manual, ALLEGRO_VERTEX_ELEMENT(3) β€” mwah, ily, go build something cute 🧚

πŸ“¦ 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