|
How does allegro draw primitives? |
Markobar
Member #16,921
December 2018
|
Hi all, This is my first post here, just tell me if I am breaking any forum rules. My question is about how allegro deals with the primitives. Have a look to the picture attached. This example is based 99.9% on this code: https://wiki.allegro.cc/index.php?title=Tilemap_Example I just added a couple of lines for testing purposes: When doing zoom and rotate, triangles, circles, splines lose resolution, while rectangles do not. Is it because allegro rasterises the first ones before drawing them? Why this does not happen with rectangles? Another question is about the edges between the white and black rectangles. If you look closer, the left and top edges look sharper than the other two, which look more blended or anti aliased. I did another test where I drew a 3d pyramid by using the "al_draw_indexed_prim" function, and even if this object contains triangles, the object does not lose resolution when zooming or rotating. Which is the explanation for this different behaviour? Is there a way to write the same tile map without losing resolution? If I am not wrong, the allegro primitives are vector graphics, isn't it? EDIT: I just realised that the bottom of the triangles look straight, even if one zooms or rotates. So maybe allegro rasterises everything, but since rectangles are purely vertical and horizontal lines, one cannot see what happens with diagonal or curved lines. I am right? Thank you in advance and regards! |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You've got to keep in mind, allegro is not drawing primitives in this example, it's drawing a scaled bitmap with primitives drawn on it at a smaller resolution. That's why they don't scale well, even with ALLEGRO_MAG_LINEAR (which looks blurry, imo) or ALLEGRO_MIN_LINEAR (which scales down great). If you were to draw the primitives instead of the tiles, they would look much sharper. EDIT 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 |
Markobar
Member #16,921
December 2018
|
Thank you for your fast response, Edgar. That explains everything. And thanks again for the welcome! Regards, |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You can get even better looking primitives when enabling multi sampling, and you can get scaled down versions of bitmaps for free when you enable ALLEGRO_MIPMAP. Up to 8x or 16x multisampling looks best in my opinion. 2 and 4 are okay, but 8 is great. Super smooth. 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 |
Markobar
Member #16,921
December 2018
|
I will definitely try that! I presume that you can do the same thing with fonts. Loading them 8x or 16x and then scale them down. Allegro is wonderful Best! |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Ah, a caveat. Actually with fonts, no. They are not rendered as primitives, sadly, they are rendered as pre-sized glyphs. That could change, but not likely without a big font overhaul. EDIT 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 |
|