Files
MapLibreParticleLab/platform/qt/src/headless_backend_qt.cpp
2019-04-05 11:49:17 +02:00

39 lines
751 B
C++

#include <mbgl/gl/headless_backend.hpp>
#include <QGLWidget>
#include <QOpenGLContext>
#include <cassert>
namespace mbgl {
namespace gl {
class QtBackendImpl final : public HeadlessBackend::Impl {
public:
~QtBackendImpl() = default;
gl::ProcAddress getExtensionFunctionPointer(const char* name) {
QOpenGLContext* thisContext = QOpenGLContext::currentContext();
return thisContext->getProcAddress(name);
}
void activateContext() {
widget.makeCurrent();
}
void deactivateContext() {
widget.doneCurrent();
}
private:
QGLWidget widget;
};
void HeadlessBackend::createImpl() {
assert(!impl);
impl = std::make_unique<QtBackendImpl>();
}
} // namespace gl
} // namespace mbgl