![]() |
|
draw_sprite in allegro 5 |
jim109109
Member #14,273
May 2012
|
Hello, I'm new to Allegro and learning the functions gradually as I need them. Everything seemed great..until now...My first problem I need to draw a bitmap on top of another. I have found the allegro 4 "draw_sprite" function which seems to do the trick. The problem is I can't seem to find the equivalent in allegro 5... I get: Same error for blit() and a couple of similar functions. Are those particular functions obsolete in allegro 5? Thanks! |
Matthew Leverton
Supreme Loser
January 1999
![]() |
Use al_draw_bitmap() with an image that has an alpha channel. |
jim109109
Member #14,273
May 2012
|
That is hardly as convenient...then i have to handle the images one by one. |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Umm... It does the exact same thing, only using sprites with zero alpha instead of magic pink..... 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 |
jim109109
Member #14,273
May 2012
|
But can it draw on another bitmap rather than the actual display? :O Thanks men |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
al_set_target_bitmap does what you're looking for. The drawing target in A5 is now state based instead of parameter based like in A4. 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 |
jmasterx
Member #11,410
October 2009
|
al_set_target_bitmap should do it for you. D'Oh, beat me to it. Agui GUI API -> https://github.com/jmasterx/Agui |
jim109109
Member #14,273
May 2012
|
That is exactly what I'm look for! Thank you! |
Evert
Member #794
November 2000
![]() |
jim109109 said: I have a map composed of tiles. I want the map to be a bitmap, and to draw the tiles over it. I would not be so sure of that, especially if the map is large. By all means try it though. |
Thomas Fjellstrom
Member #476
June 2000
![]() |
Drawing to bitmaps and "double buffering" like that is likely to be slower than just drawing directly to the screen. You can't think of allegro 5 behaving anything like allegro 4 performance wise. They are completely different. Essentially, the most compatible and fastest way to draw in A5 is to just dump everything directly to the screen, optionally skipping stuff that just gets overdrawn later (though that may not matter much with a simple 2d game). One tip for a5 is to put all of your tiles and sprites into a single bitmap (aka: an atlas) and then wrap all of the drawing of the items in that atlas in al_hold_bitmap_drawing calls. It's an implementation detail, but a fairly important one. This way allegro won't needlessly change the texture state, and it'll hold all of the drawing till you unhold the drawing, so it gets transferred in one large blob. It can mean a significant speed up for things like tile maps. Note, some systems may not support drawing to textures, or if they do, it'll be quite slow. Something to watch out for. -- |
jim109109
Member #14,273
May 2012
|
I will probably try both methods and let you know which is faster. Here's how I would go about drawing tile by tile (correct me if wrong): or *The way my camera will be setup, every movement will alter the camera and the tiles will have to be redrawn. ==================================== UPDATE: Both draw methods have an execution time of 0.001 seconds! Therefore, any of the two are viable. However, drawing the whole map beforehand uses up MORE MEMORY and has an initial load of 0.019 seconds [on map load]! Drawing tiles directly on screen is ALSO independent of map size. For these reasons, I will use that method! Thank you for the valuable help, my questions have hereby been FULLY ANSWERED TO MY SATISFACTION! |
|