9 #ifndef hifi_gl_context_h
10 #define hifi_gl_context_h
24 class QOpenGLDebugMessage;
30 QWindow* _window {
nullptr };
31 static void destroyContext(QOpenGLContext* context);
33 static bool USE_CUSTOM_CONTEXT;
35 uint32_t _version { 0x0401 };
40 QOpenGLContext* _qglContext {
nullptr };
43 Context(
const Context& other);
44 void qtCreate(QOpenGLContext* shareContext);
46 void createWrapperContext();
50 static bool enableDebugLogger();
51 static void debugMessageHandler(
const QOpenGLDebugMessage &debugMessage);
52 static void setupDebugLogging(QOpenGLContext* context);
55 Context(QWindow* window);
59 QWindow* getWindow()
const {
return _window; }
61 void setWindow(QWindow* window);
63 static void makeCurrent(QOpenGLContext* context, QSurface* surface);
66 virtual void create(QOpenGLContext* shareContext =
nullptr);
67 QOpenGLContext* qglContext()
const {
return _qglContext; }
68 void moveToThread(QThread* thread);
70 static size_t evalSurfaceMemoryUsage(uint32_t width, uint32_t height, uint32_t pixelSize);
71 static size_t getSwapchainMemoryUsage();
72 static void updateSwapchainMemoryUsage(
size_t prevSize,
size_t newSize);
75 static std::atomic<size_t> _totalSwapchainMemoryUsage;
77 size_t _swapchainMemoryUsage { 0 };
78 size_t _swapchainPixelSize { 0 };
79 void updateSwapchainMemoryCounter();
82 class OffscreenContext :
public Context {
83 using Parent = Context;
85 virtual ~OffscreenContext();
86 void create(QOpenGLContext* shareContext =
nullptr)
override;