Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » speeding up mandelbrot fractal creation

This thread is locked; no one can reply to it. rss feed Print
speeding up mandelbrot fractal creation
dougt719
Member #12,931
June 2011

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?

Thanks.

Edgar Reynaldo
Member #8,592
May 2007
avatar

There are several techniques that allow you to speed up allegro drawing.

al_lock_bitmap
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

al_draw_prim
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.

al_hold_bitmap_drawing
3. Hold your bitmap drawing. This is useful when all graphics being drawn are on the same texture in the gpu.

dougt719
Member #12,931
June 2011

Thanks for the reply. I am using al_lock_bitmap, and will try the other suggestions soon.

jmasterx
Member #11,410
October 2009

mandelbrot is computed per-pixel, thus a shader would probably be the fastest way.

http://learningwebgl.com/lessons/example01/

Edgar Reynaldo
Member #8,592
May 2007
avatar

Bruce Pascoe
Member #15,931
April 2015
avatar

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. :)

Go to: