diff --git a/vclib/render/include/vclib/glfw/window_manager.h b/vclib/render/include/vclib/glfw/window_manager.h index ac231aa65..3453b58de 100644 --- a/vclib/render/include/vclib/glfw/window_manager.h +++ b/vclib/render/include/vclib/glfw/window_manager.h @@ -226,6 +226,8 @@ class WindowManager } protected: + void* windowPtr() { return reinterpret_cast(mWindow); } + // callbacks virtual void glfwFramebufferSizeCallback( GLFWwindow*, diff --git a/vclib/render/include/vclib/qt/widget_manager.h b/vclib/render/include/vclib/qt/widget_manager.h index dd5f876fd..c34794418 100644 --- a/vclib/render/include/vclib/qt/widget_manager.h +++ b/vclib/render/include/vclib/qt/widget_manager.h @@ -137,6 +137,12 @@ class WidgetManager : } protected: + void* windowPtr() + { + // TODO: probably ImGui Drawer needs something else here - QWidget*? + return reinterpret_cast(winId()); + } + #if defined(VCLIB_RENDER_BACKEND_BGFX) void resizeEvent(QResizeEvent* event) override { diff --git a/vclib/render/include/vclib/render/drawers/plain_drawer.h b/vclib/render/include/vclib/render/drawers/plain_drawer.h index ce2d943a1..3889ba807 100644 --- a/vclib/render/include/vclib/render/drawers/plain_drawer.h +++ b/vclib/render/include/vclib/render/drawers/plain_drawer.h @@ -30,6 +30,9 @@ namespace vcl { template class PlainDrawer { +protected: + using DRT = DerivedRenderer; + public: PlainDrawer() = default; PlainDrawer(uint, uint) {} @@ -43,8 +46,6 @@ class PlainDrawer virtual void onDrawContent(uint viewId) {} protected: - using DRT = DerivedRenderer; - auto* derived() { return static_cast(this); } const auto* derived() const { return static_cast(this); } diff --git a/vclib/render/include/vclib/render/renderer.h b/vclib/render/include/vclib/render/renderer.h index e57c6af75..6b649e02f 100644 --- a/vclib/render/include/vclib/render/renderer.h +++ b/vclib/render/include/vclib/render/renderer.h @@ -288,6 +288,8 @@ class Renderer : /***** Member functions called by Drawer objects *****/ // Documentation is in the Renderer::DRW inner class + void* dWindowPtr() { return WindowManagerType::windowPtr(); } + vcl::Point2 dCanvasSize() const { return CanvasType::size(); } auto dCanvasFrameBuffer() const { return CanvasType::frameBuffer(); } @@ -555,6 +557,22 @@ class Renderer::DRW //friend Drawers>...; public: // TODO - remove this when C++26 is supported + /** + * @brief A Drawer object can request the window pointer of the window + * manager (the exact meaning of the window pointer depends on the window + * manager implementation). + * + * To get the window pointer, the Drawer object can call the `windowPtr()` + * function. To know the exact meaning of the window pointer, the Drawer + * object should refer to the documentation of the specific window manager + * implementation, and check the WINDOW_MANAGER_ID of the window manager, + * that is a static constant of the WindowManager class. + * + * @param r + * @return + */ + static void* windowPtr(Renderer* r) { return r->dWindowPtr(); } + /** * @brief A Drawer object can request the size of the canvas. This function * is called by the Drawer object to request the size of the canvas.