summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-06-19 18:17:25 -0600
committerBrian Paul <brianp@vmware.com>2009-06-19 18:17:25 -0600
commit9342e6f5a94d3b884dcb98b4741295f1aa23e282 (patch)
tree9994eef87ed7afb77a17378bf5c4508991b33e0b
parentb8000c874ecb33b1554407c5e568afbb471dda3a (diff)
mesa: implement _mesa_GenVertexArrays() for GL_ARB_vertex_array_object
This also involves adding a gl_array_object::VBOonly field. For the ARB extension, all arrays in the object must reside in a VBO. This flag keeps track of that requirement.
-rw-r--r--src/mesa/main/arrayobj.c33
-rw-r--r--src/mesa/main/arrayobj.h2
-rw-r--r--src/mesa/main/mtypes.h1
3 files changed, 32 insertions, 4 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index ae9db212ae..fd35d4e38c 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -485,14 +485,14 @@ _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids)
/**
* Generate a set of unique array object IDs and store them in \c arrays.
- *
+ * Helper for _mesa_GenVertexArrays[APPLE]() functions below.
* \param n Number of IDs to generate.
* \param arrays Array of \c n locations to store the IDs.
+ * \param vboOnly Will arrays have to reside in VBOs?
*/
-void GLAPIENTRY
-_mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays)
+static void
+gen_vertex_arrays(GLcontext *ctx, GLsizei n, GLuint *arrays, GLboolean vboOnly)
{
- GET_CURRENT_CONTEXT(ctx);
GLuint first;
GLint i;
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -518,6 +518,7 @@ _mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenVertexArraysAPPLE");
return;
}
+ obj->VBOonly = vboOnly;
save_array_object(ctx, obj);
arrays[i] = first + i;
}
@@ -525,6 +526,30 @@ _mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays)
/**
+ * ARB version of glGenVertexArrays()
+ * All arrays will be required to live in VBOs.
+ */
+void GLAPIENTRY
+_mesa_GenVertexArrays(GLsizei n, GLuint *arrays)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ gen_vertex_arrays(ctx, n, arrays, GL_TRUE);
+}
+
+
+/**
+ * APPLE version of glGenVertexArraysAPPLE()
+ * Arrays may live in VBOs or ordinary memory.
+ */
+void GLAPIENTRY
+_mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ gen_vertex_arrays(ctx, n, arrays, GL_FALSE);
+}
+
+
+/**
* Determine if ID is the name of an array object.
*
* \param id ID of the potential array object.
diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
index e2f156d16c..8999edc724 100644
--- a/src/mesa/main/arrayobj.h
+++ b/src/mesa/main/arrayobj.h
@@ -74,6 +74,8 @@ void GLAPIENTRY _mesa_BindVertexArrayAPPLE( GLuint id );
void GLAPIENTRY _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids);
+void GLAPIENTRY _mesa_GenVertexArrays(GLsizei n, GLuint *arrays);
+
void GLAPIENTRY _mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *buffer);
GLboolean GLAPIENTRY _mesa_IsVertexArrayAPPLE( GLuint id );
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 69a23fe98a..0d082cbc8a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1563,6 +1563,7 @@ struct gl_array_object
GLint RefCount;
_glthread_Mutex Mutex;
+ GLboolean VBOonly; /**< require all arrays to live in VBOs? */
/** Conventional vertex arrays */
/*@{*/