blob: 3702fdf14a9cecac99f33b5a9fbc260f04ab057e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <mbgl/gl/headless_backend.hpp>
#include <QGLWidget>
#include <QOpenGLContext>
#include <cassert>
namespace mbgl {
class QtBackendImpl : public HeadlessBackend::Impl {
public:
~QtBackendImpl() final = default;
gl::ProcAddress getExtensionFunctionPointer(const char* name) final {
QOpenGLContext* thisContext = QOpenGLContext::currentContext();
return thisContext->getProcAddress(name);
}
void activateContext() final {
widget.makeCurrent();
}
void deactivateContext() final {
widget.doneCurrent();
}
private:
QGLWidget widget;
};
void HeadlessBackend::createImpl() {
assert(!impl);
impl = std::make_unique<QtBackendImpl>();
}
} // namespace mbgl
|