Writing single pixels to the screen (using GDI graphics) was very fast in Allegro 4 but in Allegro 5 it is very slow - at least as far as I got it to work. So I want to use bitmaps instead.
I have a program that generates a bitmap in TRUECOLOR8888 pixel format in memory and then asks to write this on the screen giving the address and pitch of the bitmap in memory and the position plus width and height where this block of pixels shall be put on the display.
Do I need to lock this bitmap in memory as an Allegro bitmap? Can I define my display where this bitmap shall be written as a bitmap and how do you do that? How do I then copy from the bitmap in memory to the display? The bitmap in memory can start at any position on the screen and end at a different position on another line on the display. I did some reading on this but found no solution.
This easiest approach would probably be this (if I understood what exactly you're trying to do):
1) Create a video bitmap
2) Depending on how many pixels you want to draw:
a) Use al_lock_bitmap + al_put_pixel to modify pixel data (if drawing a lot of pixels)
b) Use al_draw_pixel to draw pixels (if drawing a small or medium amount of pixels)
Probably even try both methods to see which one is faster for you
3) Draw this bitmap to whereever on the display you want it with al_draw_bitmap
My question probably had too many misunderstandings of the Allegro concepts, sorry.
Anyhow, here is my test program which writes from a flat block of pixels in memory to the display using Allegro. The program I finally want to use Allegro with provides such a block of pixels to have them written to the display.
If anything should be changed, please post.
Inmediate strike for captain obious.
You have to call al_init() bevor doing anything. Often used bug:-)
If you don't you will have changing outcomes.
al_init is in line 11. To keep the example short I do not check if successful.
The example works as expected but maybe I overlooked something.
Before line 11 you call al_init_display(), respective allegro_display...
In older times, calling anything allegro before init would lead to
strange and unforeseable behaviour, I think.