summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/arrayobj.c
diff options
context:
space:
mode:
authorFredrik Höglund <fredrik@kde.org>2015-03-02 18:22:50 +0100
committerFredrik Höglund <fredrik@kde.org>2015-05-08 15:31:02 +0200
commita1f48268b4ee166eb9fde21bceaaef12a6e0c89a (patch)
tree5d01068e1acff449f0c4b3b855f5124e3f7b0172 /src/mesa/main/arrayobj.c
parente51bad669a4c42845c44a925bbb5d8885799c28f (diff)
downloadexternal_mesa3d-a1f48268b4ee166eb9fde21bceaaef12a6e0c89a.zip
external_mesa3d-a1f48268b4ee166eb9fde21bceaaef12a6e0c89a.tar.gz
external_mesa3d-a1f48268b4ee166eb9fde21bceaaef12a6e0c89a.tar.bz2
mesa: Implement CreateVertexArrays
v2: Update the documentation for gen_vertex_arrays(). Reviewed-by: Laura Ekstrand <laura@jlekstrand.net>
Diffstat (limited to 'src/mesa/main/arrayobj.c')
-rw-r--r--src/mesa/main/arrayobj.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 8147f6a..ea56154 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -481,19 +481,23 @@ _mesa_DeleteVertexArrays(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.
+ * Helper for _mesa_GenVertexArrays[APPLE]() and _mesa_CreateVertexArrays()
+ * 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?
+ * \param create Indicates that the objects should also be created.
+ * \param func The name of the GL entry point.
*/
static void
-gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays)
+gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays,
+ bool create, const char *func)
{
GLuint first;
GLint i;
if (n < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGenVertexArrays");
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
return;
}
@@ -503,16 +507,20 @@ gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays)
first = _mesa_HashFindFreeKeyBlock(ctx->Array.Objects, n);
- /* Allocate new, empty array objects and return identifiers */
+ /* For the sake of simplicity we create the array objects in both
+ * the Gen* and Create* cases. The only difference is the value of
+ * EverBound, which is set to true in the Create* case.
+ */
for (i = 0; i < n; i++) {
struct gl_vertex_array_object *obj;
GLuint name = first + i;
obj = (*ctx->Driver.NewArrayObject)( ctx, name );
if (!obj) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenVertexArrays");
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
return;
}
+ obj->EverBound = create;
save_array_object(ctx, obj);
arrays[i] = first + i;
}
@@ -527,7 +535,7 @@ void GLAPIENTRY
_mesa_GenVertexArrays(GLsizei n, GLuint *arrays)
{
GET_CURRENT_CONTEXT(ctx);
- gen_vertex_arrays(ctx, n, arrays);
+ gen_vertex_arrays(ctx, n, arrays, false, "glGenVertexArrays");
}
@@ -539,7 +547,19 @@ void GLAPIENTRY
_mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays)
{
GET_CURRENT_CONTEXT(ctx);
- gen_vertex_arrays(ctx, n, arrays);
+ gen_vertex_arrays(ctx, n, arrays, false, "glGenVertexArraysAPPLE");
+}
+
+
+/**
+ * ARB_direct_state_access
+ * Generates ID's and creates the array objects.
+ */
+void GLAPIENTRY
+_mesa_CreateVertexArrays(GLsizei n, GLuint *arrays)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ gen_vertex_arrays(ctx, n, arrays, true, "glCreateVertexArrays");
}