speeding up mandelbrot fractal creation
I am using Allegro 5 on Ubuntu 14.04. I am creating the Mandelbrot fractal on a 1333 x 1000 display, and a bitmap of the same size. I lock the bitmap, issue 273248 calls to al_put_pixel with color black (background is white), unlock the bitmap, and flip the display. The resulting display is fine, but the timing is not so good compared to SDL2:
time on Allegro 5: 3.8 seconds
time on SDL2 : 0.15 seconds
I would appreciate advice on how to speed up the Allegro version, and also can Allegro take advantage of my Nvidia Fermi architecture graphics card?
There are several techniques that allow you to speed up allegro drawing.
1. Lock your target bitmap before drawing to it, and unlock it when done.
A. Lock only the region you need. The smaller the better.
B. Lock it write only if you can. This prevents the download of the texture from the gpu
2. Draw using the primitives addon. Depends on what you're doing, but batch drawing helps speed things up for example if you have an ALLEGRO_PRIM_POINT_LIST.
3. Hold your bitmap drawing. This is useful when all graphics being drawn are on the same texture in the gpu.
Thanks for the reply. I am using al_lock_bitmap, and will try the other suggestions soon.
Thread #615551. Printed from Allegro.cc
al_draw_pixel() is generally the faster of the two, I've found.
al_draw_prim() is the best option here though. This lets you build up the points in memory and send them to the GPU all at once so the whole thing is blazing fast.
Directly working with the screen at the pixel level is a thing of the past. You need different techniques with modern hardware.