Files
MapLibreParticleLab/platform/qt/src/mbgl/headless_backend_qt.cpp
Tadej Novak 5b3d936521 [qt] Rename QMapboxGL to QMapLibreGL (#338)
* Rename QMapboxGL to QMapLibreGL

* Add missing QDebug includes

* Fix Qt CMake config

* Fix geojson warning

* Remove redundant OpenGL dependency

* Put everything under QMapLibreGL namespace

* Reorganise headers

Co-authored-by: Rinigus <rinigus.git@gmail.com>
2022-07-03 20:30:46 +02:00

46 lines
1019 B
C++

#include <mbgl/gl/headless_backend.hpp>
#include <QOffscreenSurface>
#include <QOpenGLContext>
#include <cassert>
namespace mbgl {
namespace gl {
class QtBackendImpl final : public HeadlessBackend::Impl {
public:
QtBackendImpl() {
// QtBackendImpl must be created in the main/GUI thread on platforms
// that have a QWindow-based QOffscreenSurface.
surface.create();
context.create();
}
~QtBackendImpl() = default;
gl::ProcAddress getExtensionFunctionPointer(const char* name) {
QOpenGLContext* thisContext = QOpenGLContext::currentContext();
return thisContext->getProcAddress(name);
}
void activateContext() {
context.makeCurrent(&surface);
}
void deactivateContext() {
context.doneCurrent();
}
private:
QOpenGLContext context;
QOffscreenSurface surface;
};
void HeadlessBackend::createImpl() {
assert(!impl);
impl = std::make_unique<QtBackendImpl>();
}
} // namespace gl
} // namespace mbgl