aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Barker <jesse.barker@linaro.org>2012-10-22 10:01:50 -0700
committerJesse Barker <jesse.barker@linaro.org>2012-10-22 10:01:50 -0700
commitc46d126bc97e839f135419d6ea4aaade3732ab97 (patch)
tree67fdd12296606508f31e5bba303a8a1a10b92457
parent4abe76b5de3f8346bf4d03e2c842aa0c181e5408 (diff)
downloadglmark2-c46d126bc97e839f135419d6ea4aaade3732ab97.tar.gz
Mesh: Fix for a situation encountered during the development of SceneShadow.
In cases where a mesh will do "double duty" but not be used the same way in all cases (in SceneShadow, the shader for the depth pass would ignore the "normal" attribute), the GL can return a -1 for the attribute location, even if it is declared in the shader (compilers are free to optimize away unused attributes, etc.). So, we check for this and don't try to enable attributes whose location is -1.
-rw-r--r--src/mesh.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mesh.cpp b/src/mesh.cpp
index bcc36e6..9ccbcc6 100644
--- a/src/mesh.cpp
+++ b/src/mesh.cpp
@@ -543,6 +543,8 @@ void
Mesh::render_array()
{
for (size_t i = 0; i < vertex_format_.size(); i++) {
+ if (attrib_locations_[i] < 0)
+ continue;
glEnableVertexAttribArray(attrib_locations_[i]);
glVertexAttribPointer(attrib_locations_[i], vertex_format_[i].first,
GL_FLOAT, GL_FALSE, vertex_stride_,
@@ -552,6 +554,8 @@ Mesh::render_array()
glDrawArrays(GL_TRIANGLES, 0, vertices_.size());
for (size_t i = 0; i < vertex_format_.size(); i++) {
+ if (attrib_locations_[i] < 0)
+ continue;
glDisableVertexAttribArray(attrib_locations_[i]);
}
}
@@ -566,6 +570,8 @@ void
Mesh::render_vbo()
{
for (size_t i = 0; i < vertex_format_.size(); i++) {
+ if (attrib_locations_[i] < 0)
+ continue;
glEnableVertexAttribArray(attrib_locations_[i]);
glBindBuffer(GL_ARRAY_BUFFER, vbos_[i]);
glVertexAttribPointer(attrib_locations_[i], vertex_format_[i].first,
@@ -576,6 +582,8 @@ Mesh::render_vbo()
glDrawArrays(GL_TRIANGLES, 0, vertices_.size());
for (size_t i = 0; i < vertex_format_.size(); i++) {
+ if (attrib_locations_[i] < 0)
+ continue;
glDisableVertexAttribArray(attrib_locations_[i]);
}
}