blob: ad3fa42290dce3a7d59b1551c57f53a4c0afaec6 (
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
39
40
41
42
43
44
45
46
|
#include <mbgl/gl/headless_backend.hpp>
#include <QGLWidget>
#if QT_VERSION >= 0x050000
#include <QOpenGLContext>
#else
#include <QGLContext>
#endif
#include <cassert>
namespace mbgl {
class QtBackendImpl : public HeadlessBackend::Impl {
public:
~QtBackendImpl() final = default;
gl::ProcAddress getExtensionFunctionPointer(const char* name) final {
#if QT_VERSION >= 0x050000
QOpenGLContext* thisContext = QOpenGLContext::currentContext();
return thisContext->getProcAddress(name);
#else
const QGLContext* thisContext = QGLContext::currentContext();
return reinterpret_cast<gl::ProcAddress>(thisContext->getProcAddress(name));
#endif
}
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
|