9 #ifndef hifi_gl_context_h
10 #define hifi_gl_context_h
24 class QOpenGLDebugMessage;
26 #if defined(Q_OS_WIN) && (defined(USE_GLES) || defined(USE_KHR_ROBUSTNESS))
28 #define GL_CUSTOM_CONTEXT
34 QWindow* _window {
nullptr };
35 static void destroyContext(QOpenGLContext* context);
36 #if defined(GL_CUSTOM_CONTEXT)
37 static bool USE_CUSTOM_CONTEXT;
39 uint32_t _version { 0x0401 };
44 QOpenGLContext* _qglContext {
nullptr };
47 Context(
const Context& other);
48 void qtCreate(QOpenGLContext* shareContext);
49 #if defined(GL_CUSTOM_CONTEXT)
50 void createWrapperContext();
54 static bool enableDebugLogger();
55 static void debugMessageHandler(
const QOpenGLDebugMessage &debugMessage);
56 static void setupDebugLogging(QOpenGLContext* context);
59 Context(QWindow* window);
63 QWindow* getWindow()
const {
return _window; }
65 void setWindow(QWindow* window);
67 static void makeCurrent(QOpenGLContext* context, QSurface* surface);
70 virtual void create(QOpenGLContext* shareContext =
nullptr);
71 QOpenGLContext* qglContext()
const {
return _qglContext; }
72 void moveToThread(QThread* thread);
74 static size_t evalSurfaceMemoryUsage(uint32_t width, uint32_t height, uint32_t pixelSize);
75 static size_t getSwapchainMemoryUsage();
76 static void updateSwapchainMemoryUsage(
size_t prevSize,
size_t newSize);
79 static std::atomic<size_t> _totalSwapchainMemoryUsage;
81 size_t _swapchainMemoryUsage { 0 };
82 size_t _swapchainPixelSize { 0 };
83 void updateSwapchainMemoryCounter();
86 class OffscreenContext :
public Context {
87 using Parent = Context;
89 virtual ~OffscreenContext();
90 void create(QOpenGLContext* shareContext =
nullptr)
override;