diff options
Diffstat (limited to 'include/mbgl/gl')
-rw-r--r-- | include/mbgl/gl/gl.hpp | 47 |
1 files changed, 3 insertions, 44 deletions
diff --git a/include/mbgl/gl/gl.hpp b/include/mbgl/gl/gl.hpp index c849a935c2..a499d731d6 100644 --- a/include/mbgl/gl/gl.hpp +++ b/include/mbgl/gl/gl.hpp @@ -1,8 +1,6 @@ #pragma once -#include <string> #include <stdexcept> -#include <vector> #if __APPLE__ #include "TargetConditionals.h" @@ -38,51 +36,12 @@ struct Error : std::runtime_error { void checkError(const char *cmd, const char *file, int line); +} // namespace gl +} // namespace mbgl + #ifndef NDEBUG #define MBGL_CHECK_ERROR(cmd) ([&]() { struct __MBGL_C_E { ~__MBGL_C_E() { ::mbgl::gl::checkError(#cmd, __FILE__, __LINE__); } } __MBGL_C_E; return cmd; }()) #else #define MBGL_CHECK_ERROR(cmd) (cmd) #endif -class ExtensionFunctionBase { -public: - static std::vector<ExtensionFunctionBase*>& functions(); - typedef std::pair<const char *, const char *> Probe; - std::vector<Probe> probes; - void (*ptr)(); -}; - -template <class> -class ExtensionFunction; - -template <class R, class... Args> -class ExtensionFunction<R (Args...)> : protected ExtensionFunctionBase { -public: - ExtensionFunction(std::initializer_list<Probe> probes_) { - probes = probes_; - ExtensionFunctionBase::functions().push_back(this); - } - - explicit operator bool() const { - return ptr; - } - - R operator()(Args... args) const { - return (*reinterpret_cast<R (*)(Args...)>(ptr))(std::forward<Args>(args)...); - } -}; - -using glProc = void (*)(); -void InitializeExtensions(glProc (*getProcAddress)(const char *)); - -extern ExtensionFunction<void (GLuint array)> - BindVertexArray; - -extern ExtensionFunction<void (GLsizei n, const GLuint* arrays)> - DeleteVertexArrays; - -extern ExtensionFunction<void (GLsizei n, GLuint* arrays)> - GenVertexArrays; - -} // namespace gl -} // namespace mbgl |