aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/arrayobj.c
diff options
context:
space:
mode:
authorFredrik Höglund <[email protected]>2015-03-02 18:30:12 +0100
committerFredrik Höglund <[email protected]>2015-05-08 15:31:03 +0200
commit7ccc4f3f2392fa9acbbc034e03e3693c78127f70 (patch)
treefc665e97cf4bb124477e9a4e9055d9374667021d /src/mesa/main/arrayobj.c
parentc99efbd3c2d496dc7e62adf11ab56b7eb006bbc3 (diff)
mesa: Implement VertexArrayElementBuffer
v2: Add a doxygen comment. Reviewed-by: Laura Ekstrand <[email protected]>
Diffstat (limited to 'src/mesa/main/arrayobj.c')
-rw-r--r--src/mesa/main/arrayobj.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 42214d8d6a0..5ce33a082f8 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -644,3 +644,44 @@ _mesa_IsVertexArray( GLuint id )
return obj->EverBound;
}
+
+
+/**
+ * Sets the element array buffer binding of a vertex array object.
+ *
+ * This is the ARB_direct_state_access equivalent of
+ * glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer).
+ */
+void GLAPIENTRY
+_mesa_VertexArrayElementBuffer(GLuint vaobj, GLuint buffer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_vertex_array_object *vao;
+ struct gl_buffer_object *bufObj;
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ /* The GL_ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated by VertexArrayElementBuffer
+ * if <vaobj> is not [compatibility profile: zero or] the name of an
+ * existing vertex array object."
+ */
+ vao =_mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayElementBuffer");
+ if (!vao)
+ return;
+
+ /* The GL_ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated if <buffer> is not zero or
+ * the name of an existing buffer object."
+ */
+ if (buffer != 0)
+ bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
+ "glVertexArrayElementBuffer");
+ else
+ bufObj = ctx->Shared->NullBufferObj;
+
+ if (bufObj)
+ _mesa_reference_buffer_object(ctx, &vao->IndexBufferObj, bufObj);
+}