Hello everbody,
I am quite new to C++ and Allegro and started by following this tutorial Demoscene C++ Allegro Tutorial. I was even able to convert the code to Allegro Version 5 and everything worked fine. Then I started on the task with the snow piling up (at the bottom part of the Tutorial). After a while I also managed to solve this task. Now my problem is that the application is running very slow as you will see if you compile it by yourself. I guess this is because I am working with a Bitmap. My question now is how can I speed up the whole application ?
Here is the code:
best regards and many thanks for any help !
djtschke
Putting pixels is expensive in A5 and likely your bottleneck. Look into bitmap locking or blit your particle to a bitmap then draw that bitmap instead with al_hold_bitmap_drawing set to true.
I already looked into the al_lock_bitmap() function and experimented a bit. But it didn't really help anything. Also I must confess I didn't quite get the clue of how that function works.
best regards,
djtschke
Then try the other method. create a new bitmap, set it as the target bitmap, draw your pattern, then set the target back to the back buffer, now instead of calls to al_draw_pixel, right before the for loop call:
al_hold_bitmap_drawing(true);
then in your for loop, draw the bitmap.
then after the for loop call:
al_hold_bitmap_drawing(false);
Try al_draw_prim with ALLEGRO_PRIM_POINT_LIST and a custom vertex declaration (see ex_prim example).
A bit off-topic but that's a horrible gap in the tutorial I see. It goes from basically the smallest possible allegro program to a slightly extensive particle snow tutorial.
Very much off-topic:
I run my laptop at 60hz, but my PC at 120.
Yesterday I discovered my CRT monitor had a 120Hz mode 
I didn't know of al_draw_prim. Interesting. How do you define colour when using NULL as a texture?
ALLEGRO_VERTEX has a color parameter. Custom vertex declarations also have a method to specify the color.