12 #ifndef hifi_QOpenGLContextWrapper_h
13 #define hifi_QOpenGLContextWrapper_h
23 #if defined(Q_OS_ANDROID)
25 #include <QtPlatformHeaders/QEGLNativeContext>
26 using QGLNativeContext = QEGLNativeContext;
27 #elif defined(Q_OS_WIN)
28 class QWGLNativeContext;
29 using QGLNativeContext = QWGLNativeContext;
31 using QGLNativeContext =
void*;
34 class QOpenGLContextWrapper {
36 using Pointer = std::shared_ptr<QOpenGLContextWrapper>;
37 using NativeContextPointer = std::shared_ptr<QGLNativeContext>;
38 static Pointer currentContextWrapper();
41 QOpenGLContextWrapper();
42 QOpenGLContextWrapper(QOpenGLContext* context);
43 virtual ~QOpenGLContextWrapper();
44 void setFormat(
const QSurfaceFormat& format);
46 void swapBuffers(QSurface* surface);
47 bool makeCurrent(QSurface* surface);
49 void setShareContext(QOpenGLContext* otherContext);
50 void moveToThread(QThread* thread);
52 NativeContextPointer getNativeContext()
const;
54 static QOpenGLContext* currentContext();
55 static uint32_t currentContextVersion();
57 QOpenGLContext* getContext() {
63 bool _ownContext {
false };
64 QOpenGLContext* _context {
nullptr };
67 bool isCurrentContext(QOpenGLContext* context);