summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-07-07 19:13:16 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-07-08 13:11:25 +0200
commit4f26c8122a57cd5fe35a10dc2e125500179a75a5 (patch)
tree02381c3db2adedcc6afa721137a6fb318ec915dd /include
parentaaa30c8a19bd608baf4c190f794258919365c36d (diff)
downloadqtlocation-mapboxgl-4f26c8122a57cd5fe35a10dc2e125500179a75a5.tar.gz
[core] track texture state to avoid redundand binds
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/gl/gl_values.hpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/include/mbgl/gl/gl_values.hpp b/include/mbgl/gl/gl_values.hpp
index b15ef18f48..29a5281cca 100644
--- a/include/mbgl/gl/gl_values.hpp
+++ b/include/mbgl/gl/gl_values.hpp
@@ -3,6 +3,7 @@
#include <cstdint>
#include <tuple>
#include <array>
+#include <cassert>
#include <mbgl/gl/gl.hpp>
#include <mbgl/util/color.hpp>
@@ -258,15 +259,15 @@ struct LineWidth {
};
struct ActiveTexture {
- using Type = GLint;
+ using Type = uint8_t;
static const Type Default;
static void Set(const Type& value) {
- MBGL_CHECK_ERROR(glActiveTexture(value));
+ MBGL_CHECK_ERROR(glActiveTexture(GL_TEXTURE0 + value));
}
static Type Get() {
- Type activeTexture;
+ GLint activeTexture;
MBGL_CHECK_ERROR(glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTexture));
- return activeTexture;
+ return activeTexture - GL_TEXTURE0;
}
};
@@ -305,5 +306,18 @@ struct RasterPos {
#endif // GL_ES_VERSION_2_0
+struct BindTexture {
+ using Type = GLuint;
+ static const Type Default;
+ static void Set(const Type& value) {
+ MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, value));
+ }
+ static Type Get() {
+ GLint texture;
+ MBGL_CHECK_ERROR(glGetIntegerv(GL_TEXTURE_BINDING_2D, &texture));
+ return texture;
+ }
+};
+
} // namespace gl
} // namespace mbgl