cogl-buffer: Track the last used bind target in CoglBuffer

This makes CoglBuffer track the last used bind target as a private
property. This is later used when binding a buffer to map instead of
always using the PIXEL_UNPACK target.

This also adds some additional sanity checks that code doesn't try to
nest binds to the same target or bind a buffer to multiple targets at
the same time.
This commit is contained in:
Robert Bragg
2010-07-05 23:24:34 +01:00
parent 7571cc1923
commit e98ee6665b
7 changed files with 123 additions and 41 deletions

View File

@ -75,11 +75,22 @@ typedef enum {
COGL_BUFFER_USAGE_HINT_VERTICES
} CoglBufferUsageHint;
typedef enum {
COGL_BUFFER_BIND_TARGET_PIXEL_PACK,
COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK,
COGL_BUFFER_BIND_TARGET_VERTEX_ARRAY,
COGL_BUFFER_BIND_TARGET_VERTEX_INDICES_ARRAY,
COGL_BUFFER_BIND_TARGET_COUNT
} CoglBufferBindTarget;
struct _CoglBuffer
{
CoglObject _parent;
const CoglBufferVtable *vtable;
CoglBufferBindTarget last_target;
CoglBufferFlags flags;
GLuint gl_handle; /* OpenGL handle */
@ -107,6 +118,7 @@ _cogl_buffer_register_buffer_type (GQuark type);
void
_cogl_buffer_initialize (CoglBuffer *buffer,
unsigned int size,
CoglBufferBindTarget default_target,
CoglBufferUsageHint usage_hint,
CoglBufferUpdateHint update_hint);
@ -115,11 +127,20 @@ _cogl_buffer_fini (CoglBuffer *buffer);
void
_cogl_buffer_bind (CoglBuffer *buffer,
GLenum target);
CoglBufferBindTarget target);
void
_cogl_buffer_unbind (CoglBuffer *buffer);
CoglBufferUsageHint
_cogl_buffer_get_usage_hint (CoglBuffer *buffer);
GLenum
_cogl_buffer_get_last_gl_target (CoglBuffer *buffer);
CoglBufferBindTarget
_cogl_buffer_get_last_bind_target (CoglBuffer *buffer);
GLenum
_cogl_buffer_access_to_gl_enum (CoglBufferAccess access);