Top |
Functions
CoglBool | cogl_is_buffer () |
unsigned int | cogl_buffer_get_size () |
void | cogl_buffer_set_update_hint () |
CoglBufferUpdateHint | cogl_buffer_get_update_hint () |
void * | cogl_buffer_map () |
void | cogl_buffer_unmap () |
CoglBool | cogl_buffer_set_data () |
CoglPixelBuffer * | cogl_pixel_buffer_new () |
CoglBool | cogl_is_pixel_buffer () |
Description
The CoglBuffer API provides a common interface to manipulate
buffers that have been allocated either via cogl_pixel_buffer_new()
or cogl_attribute_buffer_new()
. The API allows you to upload data
to these buffers and define usage hints that help Cogl manage your
buffer optimally.
Data can either be uploaded by supplying a pointer and size so Cogl
can copy your data, or you can mmap()
a CoglBuffer and then you can
copy data to the buffer directly.
One of the most common uses for CoglBuffers is to upload texture data asynchronously since the ability to mmap the buffers into the CPU makes it possible for another thread to handle the IO of loading an image file and unpacking it into the mapped buffer without blocking other Cogl operations.
Functions
cogl_is_buffer ()
CoglBool
cogl_is_buffer (void *object
);
Checks whether buffer
is a buffer object.
Since: 1.2
Stability Level: Unstable
cogl_buffer_get_size ()
unsigned int
cogl_buffer_get_size (CoglBuffer *buffer
);
Retrieves the size of buffer
Since: 1.2
Stability Level: Unstable
cogl_buffer_set_update_hint ()
void cogl_buffer_set_update_hint (CoglBuffer *buffer
,CoglBufferUpdateHint hint
);
Sets the update hint on a buffer. See CoglBufferUpdateHint for a description of the available hints.
Since: 1.2
Stability Level: Unstable
cogl_buffer_get_update_hint ()
CoglBufferUpdateHint
cogl_buffer_get_update_hint (CoglBuffer *buffer
);
Retrieves the update hints set using cogl_buffer_set_update_hint()
Since: 1.2
Stability Level: Unstable
cogl_buffer_map ()
void * cogl_buffer_map (CoglBuffer *buffer
,CoglBufferAccess access
,CoglBufferMapHint hints
);
Maps the buffer into the application address space for direct
access. This is equivalent to calling cogl_buffer_map_range()
with
zero as the offset and the size of the entire buffer as the size.
It is strongly recommended that you pass
COGL_BUFFER_MAP_HINT_DISCARD
as a hint if you are going to replace
all the buffer's data. This way if the buffer is currently being
used by the GPU then the driver won't have to stall the CPU and
wait for the hardware to finish because it can instead allocate a
new buffer to map.
The behaviour is undefined if you access the buffer in a way
conflicting with the access
mask you pass. It is also an error to
release your last reference while the buffer is mapped.
Parameters
buffer |
a buffer object |
|
access |
how the mapped buffer will be used by the application |
|
hints |
A mask of CoglBufferMapHints that tell Cogl how the data will be modified once mapped. |
Since: 1.2
Stability Level: Unstable
cogl_buffer_unmap ()
void
cogl_buffer_unmap (CoglBuffer *buffer
);
Unmaps a buffer previously mapped by cogl_buffer_map()
.
Since: 1.2
Stability Level: Unstable
cogl_buffer_set_data ()
CoglBool cogl_buffer_set_data (CoglBuffer *buffer
,size_t offset
,const void *data
,size_t size
);
Updates part of the buffer with new data from data
. Where to put this new
data is controlled by offset
and offset
+ data
should be less than the
buffer size.
Parameters
buffer |
a buffer object |
|
offset |
destination offset (in bytes) in the buffer |
|
data |
a pointer to the data to be copied into the buffer |
|
size |
number of bytes to copy |
Since: 1.2
Stability Level: Unstable
cogl_pixel_buffer_new ()
CoglPixelBuffer * cogl_pixel_buffer_new (CoglContext *context
,size_t size
,const void *data
);
Declares a new CoglPixelBuffer of size
bytes to contain arrays of
pixels. Once declared, data can be set using cogl_buffer_set_data()
or by mapping it into the application's address space using
cogl_buffer_map()
.
If data
isn't NULL
then size
bytes will be read from data
and
immediately copied into the new buffer.
Parameters
context |
A CoglContext |
|
size |
The number of bytes to allocate for the pixel data. |
|
data |
An optional pointer to vertex data to upload immediately |
Since: 1.10
Stability Level: Unstable
cogl_is_pixel_buffer ()
CoglBool
cogl_is_pixel_buffer (void *object
);
Checks whether object
is a pixel buffer.
Since: 1.2
Stability Level: Unstable
Types and Values
enum CoglBufferUpdateHint
The update hint on a buffer allows the user to give some detail on how often the buffer data is going to be updated.
Since: 1.2
Stability Level: Unstable
enum CoglBufferAccess
The access hints for cogl_buffer_set_update_hint()
Since: 1.2
Stability Level: Unstable