Files
MapLibreParticleLab/platform/qt/test/headless_backend_qt.cpp
Thiago Marcos P. Santos f6cd017f58 [Qt] Remove legacy QOpenGL dependency from Qt5 build
OpenGL on Qt5 is offered via QtGui.
2017-03-03 17:28:07 -08:00

47 lines
974 B
C++

#include <mbgl/gl/headless_backend.hpp>
#include <QGLWidget>
#if QT_VERSION >= 0x050000
#include <QOpenGLContext>
#else
#include <QGLContext>
#endif
#include <cassert>
namespace mbgl {
struct QtImpl : public HeadlessBackend::Impl {
void activateContext() final {
widget.makeCurrent();
}
void deactivateContext() final {
widget.doneCurrent();
}
QGLWidget widget;
};
gl::glProc HeadlessBackend::initializeExtension(const char* name) {
#if QT_VERSION >= 0x050000
QOpenGLContext* thisContext = QOpenGLContext::currentContext();
return thisContext->getProcAddress(name);
#else
const QGLContext* thisContext = QGLContext::currentContext();
return reinterpret_cast<mbgl::gl::glProc>(thisContext->getProcAddress(name));
#endif
}
bool HeadlessBackend::hasDisplay() {
return true;
};
void HeadlessBackend::createContext() {
assert(!hasContext());
impl.reset(new QtImpl);
}
} // namespace mbgl