|
|
| Bitmap usage with memset and memcpy |
|
ZweiEuro
Member #23,755
April 2023
|
Hi! I want to combine Allegro with CEF, I almost got it working but I seem to be unable to write to bitmaps in the way I expect it to work according to the docs. I need the memory to be in CPU space since CEF and Allegro both need to access it; I also know that i can only use the drawing functions for it from the opengl thread that created the display, which won't gel well with CEFs drawing system. So, that said, why does this not work: 1 auto m_display = al_create_display(width, height);
2
3
4
5 auto m_osr_buffer = al_create_bitmap(BASE_WIDTH, BASE_HEIGHT);
6
7 al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); // use memory bitmap for OSR buffer
8
9 // clear entire bitmap to white
10 auto locked_region = al_lock_bitmap(m_osr_buffer, ALLEGRO_PIXEL_FORMAT_RGBA_8888, ALLEGRO_LOCK_WRITEONLY);
11 memset(locked_region->data, 0, width * height * locked_region->pixel_size);
12 al_unlock_bitmap(m_osr_buffer);
Code above doesn't even have anything to do with CEF or smth, its just the main thread creating a display and trying to manipulate the data directly. as far as i can tell the locking is done correctly and the range is also correct. But i get a segfault on the memset... is there an init period for the buffer ? The memory pointer looks valid to me though. Sidenote here: CEF uses a weird pixel format EDIT: |
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
ZweiEuro, welcome. Locked bitmaps may have a negative pitch, which means subsequent rows come before not after the previous. You have to memset each line of the bitmap to be sure. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
|