I am new in ALLEGRO PROGRAMMING and I was trying some code and I could not solve it... I looked over internet but there seems no solution OR i don't know what to search.
My CODE IS
and My error message is in Attachment...
]]>What if you replace:
if(eventss.type == ALLEGRO_EVENT_DISPLAY_CLOSE) al_destroy_display(display1); al_destroy_event_queue(eventqueue1);
with:
do { al_wait_for_event(eventqueue1, &eventss); } while(eventss.type != ALLEGRO_EVENT_CLOSE); al_destory_event_source(eventqueue1); al_destroy_display(display1);
]]>
Thomas Fjellstrom - Tried it but same error message pops up when I close the display1 screen...
]]>You're destroying the display twice, which makes it crash. Your event loop could use some work too. If you want to quit when you get an ALLEGRO_EVENT_DISPLAY_CLOSE mesage, just break out of your loop and then call your destruction functions :
]]>
You're destroying the display twice, which makes it crash. Your event loop could use some work too. If you want to quit when you get an ALLEGRO_EVENT_DISPLAY_CLOSE mesage, just break out of your loop and then call your destruction functions :
He's actually creating an entirely new display when hitting a mouse button, then (attempting) waiting for it to be closed, then waiting for the first to be closed.
]]>Jeez. I need to get my eyes checked. Or learn how to read. Or something.
What is really happening is when you close display1 you try to draw to the target bitmap, which is the backbuffer of display1, which you just destroyed. That's why it crashes.
Set the target backbuffer before drawing to a display when you have multiple displays. al_set_target_backbuffer(display);
]]>What is really happening is when you close display1 you try to draw to the target bitmap, which is the backbuffer of display1, which you just destroyed. That's why it crashes.
I guess I'm wrong, but I was under the impression that allegro unset the backbuffer when a display is destroyed. Maybe it does, but some things don't check that the backbuffer is null? That explains the 0xC access.
]]>Well that's what GDB told me when I ran it through there. It said al_draw_prim crashed with a null target bitmap in a call to al_get_bitmap_flags :
I used pretty much the exact code he did (aside from a typo and missing includes) to cause the segfault :
]]>