#pragma once #include #include #include #if __APPLE__ #include "TargetConditionals.h" #if TARGET_OS_IPHONE #include #include #elif TARGET_IPHONE_SIMULATOR #include #include #elif TARGET_OS_MAC #include #include #include #else #error Unsupported Apple platform #endif #elif __ANDROID__ || MBGL_USE_GLES2 #define GL_GLEXT_PROTOTYPES #include #include #else #define GL_GLEXT_PROTOTYPES #include #include #endif namespace mbgl { namespace gl { struct Error : std::runtime_error { using std::runtime_error::runtime_error; }; void checkError(const char *cmd, const char *file, int line); #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& functions(); typedef std::pair Probe; std::vector probes; void (*ptr)(); }; template class ExtensionFunction; template class ExtensionFunction : protected ExtensionFunctionBase { public: ExtensionFunction(std::initializer_list probes_) { probes = probes_; ExtensionFunctionBase::functions().push_back(this); } explicit operator bool() const { return ptr; } R operator()(Args... args) const { return (*reinterpret_cast(ptr))(std::forward(args)...); } }; using glProc = void (*)(); void InitializeExtensions(glProc (*getProcAddress)(const char *)); extern ExtensionFunction BindVertexArray; extern ExtensionFunction DeleteVertexArrays; extern ExtensionFunction GenVertexArrays; } // namespace gl } // namespace mbgl #ifdef GL_ES_VERSION_2_0 #define glClearDepth glClearDepthf #define glDepthRange glDepthRangef #endif