Browse Source

Explicit offset also in Mesh::addVertexBuffer().

The offset is present in all other functions, adding it just for
consistency (although it is redundant here).
pull/7/head
Vladimír Vondruš 13 years ago
parent
commit
ea2faa91b7
  1. 4
      src/DebugTools/Implementation/AbstractBoxRenderer.cpp
  2. 8
      src/Mesh.h

4
src/DebugTools/Implementation/AbstractBoxRenderer.cpp

@ -45,7 +45,7 @@ AbstractBoxRenderer<2>::AbstractBoxRenderer() {
mesh->setPrimitive(square.primitive()) mesh->setPrimitive(square.primitive())
->setVertexCount(square.positions(0)->size()) ->setVertexCount(square.positions(0)->size())
->addVertexBuffer(buffer, Shaders::FlatShader2D::Position()); ->addVertexBuffer(buffer, 0, Shaders::FlatShader2D::Position());
ResourceManager::instance()->set(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual); ResourceManager::instance()->set(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual);
} }
@ -75,7 +75,7 @@ AbstractBoxRenderer<3>::AbstractBoxRenderer() {
mesh->setPrimitive(cube.primitive()) mesh->setPrimitive(cube.primitive())
->setVertexCount(cube.positions(0)->size()) ->setVertexCount(cube.positions(0)->size())
->addVertexBuffer(vertexBuffer, Shaders::FlatShader3D::Position()); ->addVertexBuffer(vertexBuffer, 0, Shaders::FlatShader3D::Position());
ResourceManager::instance()->set<Mesh>(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual); ResourceManager::instance()->set<Mesh>(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual);
} }

8
src/Mesh.h

@ -560,7 +560,7 @@ class MAGNUM_EXPORT Mesh {
* *
* Attribute list is combination of * Attribute list is combination of
* @ref AbstractShaderProgram::Attribute "attribute definitions" * @ref AbstractShaderProgram::Attribute "attribute definitions"
* (specified in implementation of given shader) and offsets between * (specified in implementation of given shader) and gaps between
* attribute arrays. * attribute arrays.
* *
* See @ref Mesh-configuration "class documentation" for simple usage * See @ref Mesh-configuration "class documentation" for simple usage
@ -574,7 +574,7 @@ class MAGNUM_EXPORT Mesh {
* Mesh* mesh; * Mesh* mesh;
* Buffer* buffer; * Buffer* buffer;
* mesh->addVertexBuffer(buffer, * mesh->addVertexBuffer(buffer,
* 35, // skip other data * 35, // offset of the data
* Shaders::PhongShader::Position(), // position array * Shaders::PhongShader::Position(), // position array
* sizeof(Vector2)*mesh->vertexCount(), // skip texture coordinate array * sizeof(Vector2)*mesh->vertexCount(), // skip texture coordinate array
* Shaders::PhongShader::Normal()); // normal array * Shaders::PhongShader::Normal()); // normal array
@ -603,10 +603,10 @@ class MAGNUM_EXPORT Mesh {
* @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access} * @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access}
* if @extension{APPLE,vertex_array_object} is available * if @extension{APPLE,vertex_array_object} is available
*/ */
template<class ...T> inline Mesh* addVertexBuffer(Buffer* buffer, const T&... attributes) { template<class ...T> inline Mesh* addVertexBuffer(Buffer* buffer, GLintptr offset, const T&... attributes) {
CORRADE_ASSERT(_vertexCount != 0, "Mesh: vertex count must be set before binding attributes", this); CORRADE_ASSERT(_vertexCount != 0, "Mesh: vertex count must be set before binding attributes", this);
addVertexBufferInternal(buffer, 0, attributes...); addVertexBufferInternal(buffer, offset, attributes...);
return this; return this;
} }

Loading…
Cancel
Save