summaryrefslogtreecommitdiff
path: root/src/mesa/main/arrayobj.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-06-19 18:07:49 -0600
committerBrian Paul <brianp@vmware.com>2009-06-19 18:12:11 -0600
commitb8000c874ecb33b1554407c5e568afbb471dda3a (patch)
tree373a6687bb163b8c31aaa92565006d13280a3a1a /src/mesa/main/arrayobj.c
parent12cf98f5fc5eaa4743134387ce3f8e584aa20bc4 (diff)
mesa: implement _mesa_BindVertexArray()
Diffstat (limited to 'src/mesa/main/arrayobj.c')
-rw-r--r--src/mesa/main/arrayobj.c55
1 files changed, 43 insertions, 12 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index e078f69ff9..ae9db212ae 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -353,18 +353,15 @@ _mesa_update_array_object_max_element(GLcontext *ctx,
/* API Functions */
/**********************************************************************/
+
/**
- * Bind a new array.
- *
- * \todo
- * The binding could be done more efficiently by comparing the non-NULL
- * pointers in the old and new objects. The only arrays that are "dirty" are
- * the ones that are non-NULL in either object.
+ * Helper for _mesa_BindVertexArray() and _mesa_BindVertexArrayAPPLE().
+ * \param genRequired specifies behavour when id was not generated with
+ * glGenVertexArrays().
*/
-void GLAPIENTRY
-_mesa_BindVertexArrayAPPLE( GLuint id )
+static void
+bind_vertex_array(GLcontext *ctx, GLuint id, GLboolean genRequired)
{
- GET_CURRENT_CONTEXT(ctx);
struct gl_array_object * const oldObj = ctx->Array.ArrayObj;
struct gl_array_object *newObj = NULL;
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -387,8 +384,12 @@ _mesa_BindVertexArrayAPPLE( GLuint id )
/* non-default array object */
newObj = lookup_arrayobj(ctx, id);
if (!newObj) {
- /* If this is a new array object id, allocate an array object now.
- */
+ if (genRequired) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBindVertexArray(id)");
+ return;
+ }
+
+ /* For APPLE version, generate a new array object now */
newObj = (*ctx->Driver.NewArrayObject)(ctx, id);
if (!newObj) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindVertexArrayAPPLE");
@@ -404,7 +405,37 @@ _mesa_BindVertexArrayAPPLE( GLuint id )
/* Pass BindVertexArray call to device driver */
if (ctx->Driver.BindArrayObject && newObj)
- (*ctx->Driver.BindArrayObject)( ctx, newObj );
+ ctx->Driver.BindArrayObject(ctx, newObj);
+}
+
+
+/**
+ * ARB version of glBindVertexArray()
+ * This function behaves differently from glBindVertexArrayAPPLE() in
+ * that this function requires all ids to have been previously generated
+ * by glGenVertexArrays[APPLE]().
+ */
+void GLAPIENTRY
+_mesa_BindVertexArray( GLuint id )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ bind_vertex_array(ctx, id, GL_TRUE);
+}
+
+
+/**
+ * Bind a new array.
+ *
+ * \todo
+ * The binding could be done more efficiently by comparing the non-NULL
+ * pointers in the old and new objects. The only arrays that are "dirty" are
+ * the ones that are non-NULL in either object.
+ */
+void GLAPIENTRY
+_mesa_BindVertexArrayAPPLE( GLuint id )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ bind_vertex_array(ctx, id, GL_FALSE);
}