Browse Source

Allow passing nullptr to IndexedMesh::setIndexBuffer().

Similar functionality should be in Mesh itself for unbinding vertex
buffers.
pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
8abc836ae4
  1. 8
      src/IndexedMesh.cpp
  2. 3
      src/IndexedMesh.h
  3. 2
      src/Mesh.h

8
src/IndexedMesh.cpp

@ -42,7 +42,7 @@ void IndexedMesh::draw() {
}
void IndexedMesh::bind() {
CORRADE_ASSERT(_indexCount, "IndexedMesh: the mesh has zero index count!", );
CORRADE_ASSERT(!_indexCount || _indexBuffer, "IndexedMesh: index buffer must be added if index count is non-zero", );
Mesh::bind();
(this->*bindIndexedImplementation)();
@ -66,11 +66,13 @@ void IndexedMesh::bindIndexBufferImplementationDefault() {}
void IndexedMesh::bindIndexBufferImplementationVAO() {
bindVAO(vao);
_indexBuffer->bind(Buffer::Target::ElementArray);
if(_indexBuffer) _indexBuffer->bind(Buffer::Target::ElementArray);
else Buffer::unbind(Buffer::Target::ElementArray);
}
void IndexedMesh::bindIndexedImplementationDefault() {
_indexBuffer->bind(Buffer::Target::ElementArray);
if(_indexBuffer) _indexBuffer->bind(Buffer::Target::ElementArray);
else Buffer::unbind(Buffer::Target::ElementArray);
}
void IndexedMesh::bindIndexedImplementationVAO() {}

3
src/IndexedMesh.h

@ -68,6 +68,9 @@ class MAGNUM_EXPORT IndexedMesh: public Mesh {
/**
* @brief Set index buffer
*
* By default there is no index buffer. Parameter @p buffer can be
* `nullptr`, in that case current index buffer is unbound from the
* mesh.
* @see MeshTools::compressIndices(), @fn_gl{BindVertexArray},
* @fn_gl{BindBuffer} (if @extension{APPLE,vertex_array_object}
* is available)

2
src/Mesh.h

@ -112,6 +112,8 @@ more information.
@todo Support for indirect draw buffer (OpenGL 4.0, @extension{ARB,draw_indirect})
@todo Redo in a way that allows glMultiDrawArrays, glDrawArraysInstanced etc.
@todo Allow unbinding all vertex buffers with some function (not as side effect),
similarly to unbinding index buffer in IndexedMesh
*/
class MAGNUM_EXPORT Mesh {
friend class IndexedMesh;

Loading…
Cancel
Save