Same as display_capture_surface but copies screen pixels to a buffer instead.
Use this if you need captured data to be persistent so that you can recover it via buffer_set_surface later.
If out_buffer is specified, it is resized (if needed) and overwritten with new data.
Otherwise a new buffer is created (if needed).
Returns the ID of the resulting (new or reused) buffer or -1 in case of error.
Currently, can only fail if the DLL failed to load or is amiss entirely.
Creating a buffer:
// setup/capture:
buf = display_capture_buffer_part(
display_mouse_get_x()100, display_mouse_get_y()100, 200, 200);
width = display_capture_rect[2];
height = display_capture_rect[3];
surf = 1;
// draw:
if (!surface_exists(surf) && buf != 1) {
surf = surface_create(width, height);
buffer_set_surface(buf, surf, 0, 0, 0);
}
if (surface_exists(surf)) draw_surface(surf, x, y);
Reusing a buffer:
// setup:
buf = 1;
surf = 1;
// capture:
var b = display_capture_buffer_part(
display_mouse_get_x()100, display_mouse_get_y()100, 200, 200, buf);
if (b != 1) {
buf = b;
width = display_capture_rect[2];
height = display_capture_rect[3];
}
// draw:
if (!surface_exists(surf) && buf != 1) {
surf = surface_create(width, height);
buffer_set_surface(buf, surf, 0, 0, 0);
}
if (surface_exists(surf)) draw_surface(surf, x, y);