1 #include "qmapboxgl_renderer_backend.hpp" 2 3 #include <QtGlobal> 4 5 #if QT_VERSION >= 0x050000 6 #include <QOpenGLContext> 7 #else 8 #include <QGLContext> 9 #endif 10 updateAssumedState()11void QMapboxGLRendererBackend::updateAssumedState() 12 { 13 assumeFramebufferBinding(ImplicitFramebufferBinding); 14 assumeViewport(0, 0, m_size); 15 } 16 bind()17void QMapboxGLRendererBackend::bind() 18 { 19 assert(mbgl::BackendScope::exists()); 20 21 setFramebufferBinding(m_fbo); 22 setViewport(0, 0, m_size); 23 } 24 getFramebufferSize() const25mbgl::Size QMapboxGLRendererBackend::getFramebufferSize() const 26 { 27 return m_size; 28 } 29 updateFramebuffer(quint32 fbo,const mbgl::Size & size)30void QMapboxGLRendererBackend::updateFramebuffer(quint32 fbo, const mbgl::Size &size) 31 { 32 m_fbo = fbo; 33 m_size = size; 34 } 35 36 /*! 37 Initializes an OpenGL extension function such as Vertex Array Objects (VAOs), 38 required by Mapbox GL Native engine. 39 */ getExtensionFunctionPointer(const char * name)40mbgl::gl::ProcAddress QMapboxGLRendererBackend::getExtensionFunctionPointer(const char* name) 41 { 42 #if QT_VERSION >= 0x050000 43 QOpenGLContext* thisContext = QOpenGLContext::currentContext(); 44 return thisContext->getProcAddress(name); 45 #else 46 const QGLContext* thisContext = QGLContext::currentContext(); 47 return reinterpret_cast<mbgl::gl::ProcAddress>(thisContext->getProcAddress(name)); 48 #endif 49 } 50