|
Rendering modes for bitmaps? |
Alianix
Member #10,518
December 2008
|
I couldn't find any info on this in the docs. What is the rendering mode for ALLEGRO_BITMAPs and is there a way to set it? By rendering mode I mean how does the 2D being drawn, quads? Thanks.
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
You're going to have to be more specific, please. You said ALLEGRO_BITMAP so you're using Allegro 5. You mentioned quad, so I assume you want to texture a quad? You can draw two triangles, using the correct texture coordinates. Try using an ALLEGRO_VERTEX[] && al_draw_prim. 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 |
Alianix
Member #10,518
December 2008
|
Forgive me perhaps I'm in a deep confusion but I understand that ALLEGRO_BITMAP is a rectangular region in Allegro 5. So is the underlying call to the renderer uses quad to draw it or something else? Is there any polygon trimming by default? If I understand correctly with al_draw_prim it's possible to draw a "bitmap" a rectangular region as a quad or other number of vertices. Is there any advantage in doing so? Thanks Edgar
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Everything is ultimately drawn as triangles. This means bitmaps are rendered as two triangles that are coplanar. A quad doesn't have to be aligned with the screen or the z-axis either. But all the 2D drawing functions just map a quad yes. If you only need 2D then there's no point using al_draw_prim unless you're drawing polygons, lines, or points. 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 |
Alianix
Member #10,518
December 2008
|
Thank you. Why do you think there is no point in polygon sprites for 2d? If you have a human character (sprite) for example there will be many empty spaces, so it should be faster with more then a few triangles?
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
That's not what I said. 2D sprites generally don't need meshes unless they're skeletal animations or Pseudo3D. And no, more smaller triangles does not equal better performance. 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 |
Alianix
Member #10,518
December 2008
|
According to what I've read about polygon sprites is that they do perform better on the GPU, as lot of the empty spaces aren't drawn. However they may cost more CPU to process vertices. So there could be a significant speed improvement in drawing larger sprites with more triangles or the optimal number of triangles, this is why I was wondering if allegro 5 supports any such operations? I've no test of the speed improvement but Unity and also Cocos2d employs polygon sprites for performance.
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
You'll have to triangulate the sprites yourself. Allegro does not do such things. 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 |
Doctor Cop
Member #16,833
April 2018
|
So, if I draw a line using a for loop and al_draw_pixel(); will it be slower than using al_draw_line();?
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
It will take longer because you're using multiple drawing calls instead of one. However, turning a 2D sprite into triangles could potentially save gpu work, but not cpu, unless you upload your vertices to the gpu. 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 |
|