Scroll to navigation

al_draw_prim(3) al_draw_prim(3)

NAME

al_draw_prim - Allegro 5 API

SYNOPSIS

#include <allegro5/allegro_primitives.h>
int al_draw_prim(const void* vtxs, const ALLEGRO_VERTEX_DECL* decl,

ALLEGRO_BITMAP* texture, int start, int end, int type)

DESCRIPTION

Draws a subset of the passed vertex array.

Parameters:

texture - Texture to use, pass NULL to use only color shaded primitves
vtxs - Pointer to an array of vertices
decl - Pointer to a [vertex declaration]al_create_vertex_decl(3). If set to NULL, the vertices are assumed to be of the ALLEGRO_VERTEX(3) type
start - Start index of the subset of the vertex array to draw
end - One past the last index of the subset of the vertex array to draw
type - A member of the ALLEGRO_PRIM_TYPE(3) enumeration, specifying what kind of primitive to draw

Returns: Number of primitives drawn

For example to draw a textured triangle you could use:

ALLEGRO_COLOR white = al_map_rgb_f(1, 1, 1);
ALLEGRO_VERTEX v[] = {

{.x = 128, .y = 0, .z = 0, .color = white, .u = 128, .v = 0},
{.x = 0, .y = 256, .z = 0, .color = white, .u = 0, .v = 256},
{.x = 256, .y = 256, .z = 0, .color = white, .u = 256, .v = 256}}; al_draw_prim(v, NULL, texture, 0, 3, ALLEGRO_PRIM_TRIANGLE_LIST);

SEE ALSO

ALLEGRO_VERTEX(3), ALLEGRO_PRIM_TYPE(3), ALLEGRO_VERTEX_DECL(3), al_draw_indexed_prim(3)

Allegro reference manual