Cannot lock target bitmap
Hello I am trying to read pixels from the target bitmap (al_get_target_bitmap), by locking it.
Unfortunately locking always fails. So I tried cloning the target bitmap and then locking the clone, this also fails
I need to read the target bitmap before saving it to a file, is there any other way I can do this?
SOLVED - SEE POST FOR SOLUTION
i, checksum: integer;
bmp := al_get_target_bitmap;
nil then Exit;
format := al_get_bitmap_format(
flname := 'Screenshot.bmp';
checksum := 0;
lr := al_lock_bitmap(
bmp, format, ALLEGRO_LOCK_READONLY);
nil then Exit;
23 // Note: Never reach this point lr is always nil..
i := (
SCREENHEIGHT - 200)
to SCREENHEIGHT - 1 do
25 // TODO: calculate checksum with lr.data
Can you lock other bitmaps?
Yes I've just tested and there is no problems with
locking any bitmaps.
On a side note I'm using Allegro 5.0.7 until 5.1 is stable.
Curiously this case works fine in a simple test project, but not in my main, I think it could be a bug in my code somewhere..
Ok I've tracked it down to:
Commenting these lines out makes it go away
Intersting to know. Are you using DirectX? I don't think multi-sampling should prevent reading the backbuffer, in general.
I'm just using vanilla Allegro code on Windows 7 X64,
I assume by default it uses OpenGL.
It seems the code below creates the bug in question.
Allegro uses DirectX by default on Windows.
Thread #611379. Printed from Allegro.cc
Is there a way to override this behaviour and make it use opengl?
nvm found it al_set_new_display_flags(ALLEGRO_OPENGL);