summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-07-08 15:41:54 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-09-26 11:14:40 +0200
commitafb93d4d3adc9bfb4b3f9b78584e1c2c66c11919 (patch)
tree8a4c9924a6ff847abab1fdd8dbd6c74874e959ae /include
parentadcb449ff348a3ae5f74c38824ae43718122dafa (diff)
downloadqtlocation-mapboxgl-afb93d4d3adc9bfb4b3f9b78584e1c2c66c11919.tar.gz
[core] track VAOs and Buffers
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/gl/gl_values.hpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/mbgl/gl/gl_values.hpp b/include/mbgl/gl/gl_values.hpp
index d251e7bf52..e5ad2380d1 100644
--- a/include/mbgl/gl/gl_values.hpp
+++ b/include/mbgl/gl/gl_values.hpp
@@ -319,5 +319,37 @@ struct BindTexture {
}
};
+template <GLenum target>
+struct BindBuffer {
+ static_assert(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER,
+ "target must be one of GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER");
+ using Type = GLuint;
+ static const constexpr Type Default = 0;
+ static void Set(const Type& value) {
+ MBGL_CHECK_ERROR(glBindBuffer(target, value));
+ }
+ static Type Get() {
+ GLint binding;
+ MBGL_CHECK_ERROR(glGetIntegerv(target == GL_ARRAY_BUFFER ? GL_ARRAY_BUFFER_BINDING
+ : GL_ELEMENT_ARRAY_BUFFER_BINDING,
+ &binding));
+ return binding;
+ }
+};
+
+template <GLenum target>
+const typename BindBuffer<target>::Type BindBuffer<target>::Default;
+
+struct BindVAO {
+ using Type = GLuint;
+ static const constexpr Type Default = 0;
+ static void Set(const Type& value) {
+ if (gl::BindVertexArray) {
+ MBGL_CHECK_ERROR(gl::BindVertexArray(value));
+ }
+ }
+};
+
+
} // namespace gl
} // namespace mbgl