Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Fast video frame drawing?

This thread is locked; no one can reply to it. rss feed Print
Fast video frame drawing?
Freemanix
Member #12,891
May 2011

Hi!

I have problems to implement fast live-view from attached camera using Allegro 5. The camera streams uncompress color or grayscale images and I need to draw them inside my Allegro created fullscreen interface.

The problem is how to get frame data into bitmaps. When I use locking and filling the buffer with raw data, it is extremely slow and on a subpar graphics card (Intel 3150) I can get only about 15 FPS for 1024x768 images.

Surprisingly, when I wrote GDI application which uses SetDIBitsToDevice(), I could easily achieve 60 FPS at the same hardware. Why?

I would like to try to create offscreen bitmap, get a GDI drawing context for it and use the SetDIBitsToDevice(), but I do not know how. I found some examples for it, but these were for Allegro 4.

Thanks for help!

Edgar Reynaldo
Member #8,592
May 2007
avatar

Freemanix
Member #12,891
May 2011

That's exactly what I am doing. It is slow.

Is there a way how to get HDC from ALLEGRO_BITMAP? There was such a method in Allegro 4.

Edgar Reynaldo
Member #8,592
May 2007
avatar

Okay then, what if you use a memory bitmap buffer and then draw it to the backbuffer? Is that any faster? Are you also locking the bitmap in the same format as the bitmap?

Freemanix said:

Is there a way how to get HDC from ALLEGRO_BITMAP? There was such a method in Allegro 4.

Looks like the best you can get for now is al_get_d3d_video_texture. Allegro 4 only let you blit to and from an HDC, not create a new one.

Freemanix
Member #12,891
May 2011

Actually, I solved this by creating my own Direct3D texture with D3DUSAGE_DYNAMIC in D3DPOOL_DEFAULT. Locking such a texture is about 10x faster than locking the ALLEGRO_BITMAP whichever way it was created.

Of course, I had to supply my own Direct3D drawing from that texture using DrawPrimitiveUP() call, but it was worth it. Now I just hope that my D3D drawing works seamlessly with the rest of Allegro5.

I would suggest Allegro5 should add new bitmap flag indicating that the bitmap being created is dynamic or suitable for streaming. I guess SDL 1.3.x have such flag already.

Go to: