blob: 1d62afabffba7147bd963f231bd7acdf8f282cd5 (
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
37
38
|
#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
|