summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/attribute.cpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-05-04 01:31:43 +0200
committerLauren Budorick <lauren@mapbox.com>2018-05-03 16:31:43 -0700
commitc3346f473ac7e3d49219c8dbc381d92f8fe3f017 (patch)
tree7e7d1c1569c849192209b0c5f5a58ef7736896a1 /src/mbgl/gl/attribute.cpp
parentf6da3ba9be27ff9b279730603c517c4cb5e57007 (diff)
downloadqtlocation-mapboxgl-c3346f473ac7e3d49219c8dbc381d92f8fe3f017.tar.gz
[core] Don't crash when attribute count is exceeded
Diffstat (limited to 'src/mbgl/gl/attribute.cpp')
-rw-r--r--src/mbgl/gl/attribute.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/mbgl/gl/attribute.cpp b/src/mbgl/gl/attribute.cpp
index bb5b2ddc34..b2d05fe665 100644
--- a/src/mbgl/gl/attribute.cpp
+++ b/src/mbgl/gl/attribute.cpp
@@ -1,14 +1,20 @@
#include <mbgl/gl/attribute.hpp>
+#include <mbgl/gl/context.hpp>
#include <mbgl/gl/gl.hpp>
namespace mbgl {
namespace gl {
-void bindAttributeLocation(ProgramID id, AttributeLocation location, const char* name) {
- if (location >= MAX_ATTRIBUTES) {
- throw gl::Error("too many vertex attributes");
+void bindAttributeLocation(Context& context, ProgramID id, AttributeLocation location, const char* name) {
+ // We're using sequentially numberered attribute locations starting with 0. Therefore we can use
+ // the location as a proxy for the number of attributes.
+ if (location >= context.maximumVertexBindingCount) {
+ // Don't bind the location on this hardware since it exceeds the limit (otherwise we'd get
+ // an OpenGL error). This means we'll see rendering errors, and possibly slow rendering due
+ // to unbound attributes.
+ } else {
+ MBGL_CHECK_ERROR(glBindAttribLocation(id, location, name));
}
- MBGL_CHECK_ERROR(glBindAttribLocation(id, location, name));
}
std::set<std::string> getActiveAttributes(ProgramID id) {