Associate an externally allocated buffer with a window


#include <screen/screen.h>
int screen_attach_window_buffers(screen_window_t win,
                                 int count,
                                 screen_buffer_t *buf)


The handle of a window that doesn't already share a buffer with another window, and that doesn't have one or more buffers created or associated to it.
The number of buffers to be attached.
An array of count buffers to be attached that was allocated by the application.




Function Type: Flushing Execution

This function can be used by drivers and other middleware components that must allocate their own buffers. The client must ensure that all usage constraints are met when allocating the buffers. Failure to do so may prevent the buffers from being successfully attached, or may result in artifacts and system instability. You must use either screen_attach_window_buffers() or screen_create_window_buffers() to associate windows with buffers, but not both.

Before calling this function, ensure that you set the SCREEN_PROPERTY_USAGE property on the window to indicate your intended usage of the window's buffer(s). For example, to retrieve SCREEN_PROPERTY_POINTER from the buffer(s), you must have set the SCREEN_PROPERTY_USAGE property to include the SCREEN_USAGE_READ and/or SCREEN_USAGE_WRITE flags on the window prior to calling screen_attach_window_buffers().


0 if successful, or -1 if an error occurred (errno is set; refer to errno.h for more details).