Texture on ALLEGRO_VERTEX
SaintBass

Hi guys!!! I`m using ALLEGRO_VERTEX but i can`t understand how the texture`s work, the u and v attributes are in pixels, but ¿How can i draw a complete image?.
In my code i have this rectangle:

ALLEGRO_VERTEX v[4] = {
{150,50,0,0,0,al_map_rgb(255,255,255)},
{300,50,0,0,0,al_map_rgb(255,255,255)},
{150,200,0,0,0,al_map_rgb(255,255,255)},
{300,200,0,0,0,al_map_rgb(255,255,255)},
}

and draw this:

al_draw_prim(v, NULL, texture, 0, 4, 4);

Edgar Reynaldo

al_draw_prim

I swapped your 3rd and 4th vertices so that it draws triangles with vertices 0,1,2 and 0,2,3. You also need to adjust your u,v coordinates to match the bitmap's corners.

int w = al_get_bitmap_width(bmp);
int h = al_get_bitmap_height(bmp);
ALLEGRO_VERTEX v[4] = {
{150,50 ,0,0,0,al_map_rgb(255,255,255)},
{300,50 ,0,w,0,al_map_rgb(255,255,255)},
{300,200,0,w,h,al_map_rgb(255,255,255)},
{150,200,0,0,h,al_map_rgb(255,255,255)}
};

al_draw_prim(v, NULL, texture, 0, 4, ALLEGRO_PRIM_TRIANGLE_FAN);

SaintBass

Thanks for your help!!!
it works perfectly :D

Thread #615736. Printed from Allegro.cc