summaryrefslogtreecommitdiff
path: root/cogl/cogl-buffer.c
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2010-10-12 13:14:17 +0100
committerRobert Bragg <robert@linux.intel.com>2010-11-03 17:28:45 +0000
commit7cc6dedea495f9b84bd974209b770f2cfe389f52 (patch)
tree243d086ca7a08443e71dbf7fb54fe589057d8df9 /cogl/cogl-buffer.c
parent406d0c4a289a1388f9fc1aeb0b6938309b625218 (diff)
downloadcogl-7cc6dedea495f9b84bd974209b770f2cfe389f52.tar.gz
buffer: make _bind() return base pointer
We now make _cogl_buffer_bind return a base pointer for the bound buffer which can be used with OpenGL. The pointer will be NULL for GPU based buffers or may point to an malloc'd buffer. Since OpenGL expects an offset instead of a pointer when dealing with buffer objects this means we can handle fallback malloc buffers and GPU buffers in a consistent way.
Diffstat (limited to 'cogl/cogl-buffer.c')
-rw-r--r--cogl/cogl-buffer.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/cogl/cogl-buffer.c b/cogl/cogl-buffer.c
index 5ed466a1..ebe8e610 100644
--- a/cogl/cogl-buffer.c
+++ b/cogl/cogl-buffer.c
@@ -351,28 +351,31 @@ _cogl_buffer_hints_to_gl_enum (CoglBufferUsageHint usage_hint,
}
#endif
-void
+void *
_cogl_buffer_bind (CoglBuffer *buffer, CoglBufferBindTarget target)
{
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+ _COGL_GET_CONTEXT (ctx, NULL);
- g_return_if_fail (buffer != NULL);
+ g_return_val_if_fail (buffer != NULL, NULL);
/* Don't allow binding the buffer to multiple targets at the same time */
- g_return_if_fail (ctx->current_buffer[buffer->last_target] != buffer);
+ g_return_val_if_fail (ctx->current_buffer[buffer->last_target] != buffer,
+ NULL);
/* Don't allow nesting binds to the same target */
- g_return_if_fail (ctx->current_buffer[target] == NULL);
+ g_return_val_if_fail (ctx->current_buffer[target] == NULL, NULL);
buffer->last_target = target;
+ ctx->current_buffer[target] = buffer;
if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT)
{
GLenum gl_target = convert_bind_target_to_gl_target (buffer->last_target);
GE( glBindBuffer (gl_target, buffer->gl_handle) );
+ return NULL;
}
-
- ctx->current_buffer[target] = buffer;
+ else
+ return buffer->data;
}
void