---
name: "ALLEGRO_VERTEX_ELEMENT"
section: "3alleg5"
platform: "linux"
package: "allegro5-doc"
version: "2:5.2.10.1+dfsg-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/ALLEGRO_VERTEX_ELEMENT/3alleg5"
---

# ALLEGRO\_VERTEX\_ELEMENT(3alleg5)

Allegro 5 API

## NAME

ALLEGRO\_VERTEX\_ELEMENT - Allegro 5 API

## SYNOPSIS

-

  ```
  #include <allegro5/allegro_primitives.h>
  typedef struct ALLEGRO_VERTEX_ELEMENT ALLEGRO_VERTEX_ELEMENT;
  ```

## DESCRIPTION

A small structure describing a certain element of a vertex. E.g. the position of the vertex, or its color. These structures are used by the al\_create\_vertex\_decl(3alleg5) function to create the vertex declaration. For that they generally occur in an array. The last element of such an array should have the attribute field equal to 0, to signify that it is the end of the array. Here is an example code that would create a declaration describing the ALLEGRO\_VERTEX(3alleg5) structure (passing this as vertex declaration to al\_draw\_prim would be identical to passing NULL):

-

  ```
  /* 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(3alleg5) enumeration, specifying what this attribute signifies

- •

  storage - A member of the ALLEGRO\_PRIM\_STORAGE(3alleg5) 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.

## SEE ALSO

al\_create\_vertex\_decl(3alleg5), ALLEGRO\_VERTEX\_DECL(3alleg5), ALLEGRO\_PRIM\_ATTR(3alleg5), ALLEGRO\_PRIM\_STORAGE(3alleg5)
