blob: feaaee10c6e6c0668e03b8c6ee979d1f3cc90205 (
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
47
48
49
50
51
52
53
54
55
56
57
|
#pragma once
#include "drape/oglcontext.hpp"
#include "std/function.hpp"
#include "std/atomic.hpp"
#include <QtGui/QWindow>
#include <QtGui/QOpenGLContext>
#include <QtCore/QThread>
class QtRenderOGLContext : public dp::OGLContext
{
public:
using TRegisterThreadFn = function<void (QThread * thread)>;
using TSwapFn = function<void ()>;
QtRenderOGLContext(QOpenGLContext * nativeContext, QThread * guiThread,
TRegisterThreadFn const & regFn, TSwapFn const & swapFn);
void present() override;
void makeCurrent() override;
void doneCurrent() override;
void setDefaultFramebuffer() override;
void shutDown();
QOpenGLContext * getNativeContext() { return m_ctx; }
private:
void MoveContextOnGui();
private:
QSurface * m_surface;
QOpenGLContext * m_ctx;
QThread * m_guiThread;
TRegisterThreadFn m_regFn;
TSwapFn m_swapFn;
bool m_isRegistered;
atomic<bool> m_shutedDown;
};
class QtUploadOGLContext: public dp::OGLContext
{
public:
QtUploadOGLContext(QSurface * surface, QOpenGLContext * contextToShareWith);
~QtUploadOGLContext();
virtual void present();
virtual void makeCurrent();
virtual void setDefaultFramebuffer();
private:
QOpenGLContext * m_nativeContext;
QSurface * m_surface;
};
|