Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » locking backbuffer when notebook gets closed

This thread is locked; no one can reply to it. rss feed Print
locking backbuffer when notebook gets closed
allandy
Member #14,845
January 2013

I realized, that this command gives a NULL-pointer as soon as a notebook gets closed:

ALLEGRO_LOCKED_REGION* ar =
al_lock_bitmap(al_get_backbuffer(al5_display), ALLEGRO_PIXEL_FORMAT_ANY, 0);

Just looping until a pointer is available again isn't possible.
I then get an exception at d3d_bmp.cpp, line 767:

if (d3d_disp->render_target->LockRect(&d3d_bmp->locked_rect, &rect, Flags) != D3D_OK) {
ALLEGRO_ERROR("LockRect failed in d3d_lock_region.\n");
return NULL;
}

I need 'ar' for fast pixel draeings. Is there a solution?

It's a self-compiled allegro 5.08 - maybe due to my compilation?
DirectX9c used.

Trent Gamblin
Member #261
April 2000
avatar

It's a directx "feature." You need to use al_d3d_set_restore|release_callback. Google for "Direct3D lost device" or similar for background.

Edgar Reynaldo
Member #8,592
May 2007
avatar

allandy
Member #14,845
January 2013

An event-message is too critical. This also can happen between the event-request and the drawing. I have to try Trent's hint.

It's my first trial with 5.x. There was never a problem using Allegro 4.2.
Miss the midi-driver too and I hate it that the event-queue gets flooded when you are at a breakpoint.
Just had to port it because a friend has problems with Allegro 4.2 on a 64-bit-system. This all ain't no fun anymore. Think I'm getting old...

Think it's worth to post the solution then, because this can happen to almost each program that uses Allegro 5. Will try my very best.

Peter Wang
Member #23
April 2000

I fixed a couple of bugs with respect to device lost handling on the 5.1 branch. These changes are not yet in any released version. 5.1.5 will be released soon.

It's a directx "feature." You need to use al_d3d_set_restore|release_callback. Google for "Direct3D lost device" or similar for background.

Do you really need them in the common case? The documentation only mentions "d3d resources you have created yourself". AFAICS, the mechanisms in 5.0 are enough to handle device lost otherwise.

Go to: