Browse Source

Saving vertex attribute parameters only if not using VAOs.

Same reasoning as in previous commit.
pull/7/head
Vladimír Vondruš 13 years ago
parent
commit
dfb9491433
  1. 14
      src/Mesh.cpp
  2. 18
      src/Mesh.h

14
src/Mesh.cpp

@ -113,8 +113,6 @@ void Mesh::bindVAO(GLuint vao) {
}
void Mesh::bind() {
CORRADE_ASSERT((_vertexCount != 0) || !attributes.empty(), "Mesh: attributes are bound but vertex count is zero", );
(this->*bindImplementation)();
}
@ -187,7 +185,9 @@ void Mesh::destroyImplementationVAO() {
#endif
}
void Mesh::attributePointerImplementationDefault(const Attribute&) {}
void Mesh::attributePointerImplementationDefault(const Attribute& attribute) {
attributes.push_back(attribute);
}
void Mesh::attributePointerImplementationVAO(const Attribute& attribute) {
bindVAO(vao);
@ -202,7 +202,9 @@ void Mesh::attributePointerImplementationDSA(const Attribute& attribute) {
#endif
#ifndef MAGNUM_TARGET_GLES2
void Mesh::attributePointerImplementationDefault(const IntegerAttribute&) {}
void Mesh::attributePointerImplementationDefault(const IntegerAttribute& attribute) {
integerAttributes.push_back(attribute);
}
void Mesh::attributePointerImplementationVAO(const IntegerAttribute& attribute) {
bindVAO(vao);
@ -217,7 +219,9 @@ void Mesh::attributePointerImplementationDSA(const IntegerAttribute& attribute)
#endif
#ifndef MAGNUM_TARGET_GLES
void Mesh::attributePointerImplementationDefault(const LongAttribute&) {}
void Mesh::attributePointerImplementationDefault(const LongAttribute& attribute) {
longAttributes.push_back(attribute);
}
void Mesh::attributePointerImplementationVAO(const LongAttribute& attribute) {
bindVAO(vao);

18
src/Mesh.h

@ -678,8 +678,8 @@ class MAGNUM_EXPORT Mesh {
inline void addInterleavedVertexBufferInternal(Buffer*, GLsizei, GLintptr) {}
template<GLuint location, class T> inline void addVertexAttribute(typename std::enable_if<std::is_same<typename Implementation::AttributeTraits<T>::AttributeType, GLfloat>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute<location, T>& attribute, GLintptr offset, GLsizei stride) {
for(GLuint i = 0; i != Implementation::Attribute<T>::vectorCount(); ++i) {
attributes.push_back({
for(GLuint i = 0; i != Implementation::Attribute<T>::vectorCount(); ++i)
(this->*attributePointerImplementation)(Attribute{
buffer,
location+i,
Implementation::Attribute<T>::components(attribute.dataOptions()),
@ -688,14 +688,11 @@ class MAGNUM_EXPORT Mesh {
offset,
stride
});
(this->*attributePointerImplementation)(attributes.back());
}
}
#ifndef MAGNUM_TARGET_GLES2
template<GLuint location, class T> inline void addVertexAttribute(typename std::enable_if<std::is_integral<typename Implementation::AttributeTraits<T>::AttributeType>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute<location, T>& attribute, GLintptr offset, GLsizei stride) {
integerAttributes.push_back({
(this->*attributeIPointerImplementation)(IntegerAttribute{
buffer,
location,
Implementation::Attribute<T>::components(),
@ -703,14 +700,12 @@ class MAGNUM_EXPORT Mesh {
offset,
stride
});
(this->*attributeIPointerImplementation)(integerAttributes.back());
}
#ifndef MAGNUM_TARGET_GLES
template<GLuint location, class T> inline void addVertexAttribute(typename std::enable_if<std::is_same<typename Implementation::AttributeTraits<T>::AttributeType, GLdouble>::value, Buffer*>::type buffer, const AbstractShaderProgram::Attribute<location, T>& attribute, GLintptr offset, GLsizei stride) {
for(GLuint i = 0; i != Implementation::Attribute<T>::vectorCount(); ++i) {
longAttributes.push_back({
for(GLuint i = 0; i != Implementation::Attribute<T>::vectorCount(); ++i)
(this->*attributeLPointerImplementation)(LongAttribute{
buffer,
location+i,
Implementation::Attribute<T>::components(),
@ -718,9 +713,6 @@ class MAGNUM_EXPORT Mesh {
offset,
stride
});
(this->*attributeLPointerImplementation)(longAttributes.back());
}
}
#endif
#endif

Loading…
Cancel
Save