![]() |
|
al_draw_prim() |
AleX-G Squadron
Member #13,593
October 2011
![]() |
Hi! www.anothergames.com |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
It's fairly self explanatory if you look at the parameter list. vtxs is a void* to either ALLEGRO_VERTEX's or custom vertices you create using an ALLEGRO_VERTEX_DECL object. See http://www.allegro.cc/manual/5/allegro_prim_type for what to use for the type parameter. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
AleX-G Squadron
Member #13,593
October 2011
![]() |
I understood the last parameter, but i dont understand other parameters. int al_draw_prim(const void* vtxs, const ALLEGRO_VERTEX_DECL* decl, Is says: 1ALLEGRO_VERTEX v[] = {
2 {.x = 128, .y = 0, .z = 0, .u = 128, .v = 0},
3 {.x = 0, .y = 256, .z = 0, .u = 0, .v = 256},
4 {.x = 256, .y = 256, .z = 0, .u = 256, .v = 256}};
5al_draw_prim(v, NULL, texture, 0, 3, ALLEGRO_PRIM_TRIANGLE_LIST);
I copy pasted the code and it doesnt explain anything. 1ALLEGRO_VERTEX v[] = {
2 {128, 0, 0, 128, 0},
3 {0, 256, 0, 0, 256},
4 {256, 256, 0, 256, 256}};
5
6 al_draw_prim(v, NULL, 0, 0, 3, ALLEGRO_PRIM_TRIANGLE_LIST);
www.anothergames.com |
Trent Gamblin
Member #261
April 2000
![]() |
Click ALLEGRO_VERTEX in that code listing and it'll show you that there is another parameter, color. So That code probably shouldn't have compiled in MSVC. I usually just set them like this: v = 0; verts[v].x = some_x; // same for y, z = 0 verts[v].u = some_u; // same for v verts[v].color = some_ALLEGRO_COLOR; v++; // next vertex Color is important for texturing too. If you want the texture to show up without tinting, use pure white.
|
alehbeer
Member #12,996
July 2011
![]() |
const ALLEGRO_VERTEX_DECL* decl Trent Gamblin said: Color is important for texturing too. If you want the texture to show up without tinting, use pure white. Talking about colour, what is meant by 'multiply by colour' as the new way of dealing with colour manipulation? I have seen this stated a couple of times on the forum, although I would have to go find a link to an example if one was needed. Does this apply for the al_draw_prim function too? I'm not sure, but this should probably be in 'Programming Questions' rather than 'Game Design & Concepts'. EDIT: 2ALLEGRO_COLOR color = al_map_rgba_f(1.0*alpha, 0.4*alpha, 0.6*alpha, alpha); // <-- correct
3//ALLEGRO_COLOR color = al_map_rgba_f(1.0, 0.4, 0.6, alpha); // <--no longer correct
|
Trent Gamblin
Member #261
April 2000
![]() |
texels will be multiplied by the tint (in al_draw_tinted_*_bitmap) and color (in al_draw_prim). If you have a RGB value of (0.5, 1.0, 0.25) in the texture... Multiply by white: (0.5*1, 1.0*1, 0.25*1) it doesn't change. If you wanted to make it half the brightness, multiply by a shade of gray (0.5, 0.5, 0.5): (0.5*0.5, 1.0*0.5, 0.25*0.5) and you get (0.25, 0.5, 0.125) which is half as bright as the original texture color. You could also filter out all color components but red, as another example: (0.5*1, 1.0*0, 0.25*0) = (0.5, 0, 0) only the red color remains. And so on for any color you choose, in any proportion. EDIT: Your example just shows the way alpha blending is done. Allegro uses premultipled alpha by default, which has the blender set like so: al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); All it means is the color components should be pre-multiplied by the alpha value before drawing, which you can see is what's done in your example. What may seem more familiar (but has problems, see the manual) is this blend mode: al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); With that mode you'd use the comment out line in your example instead.
|
alehbeer
Member #12,996
July 2011
![]() |
Trent Gamblin, you're the man. I can see some cool stuff to do with that 'multiply by colour'! I'm off to make 3D glasses out of paper and plastic...
|
AleX-G Squadron
Member #13,593
October 2011
![]() |
I still cannot get it to work, i dont know why. www.anothergames.com |
alehbeer
Member #12,996
July 2011
![]() |
check out ex_prim.c
|
|