@@ -22,10 +22,6 @@ class ISurface : public core::IReferenceCounted
2222 ISurface (core::smart_refctd_ptr<IAPIConnection>&& api) : m_api(std::move(api)) {}
2323 virtual ~ISurface () = default ;
2424
25- // impl of getSurfaceCapabilitiesForPhysicalDevice() needs this
26- virtual uint32_t getWidth () const = 0;
27- virtual uint32_t getHeight () const = 0;
28-
2925 core::smart_refctd_ptr<IAPIConnection> m_api;
3026
3127 public:
@@ -194,22 +190,25 @@ class ISurface : public core::IReferenceCounted
194190
195191 virtual bool getSurfaceCapabilitiesForPhysicalDevice (const IPhysicalDevice* physicalDevice, ISurface::SCapabilities& capabilities) const = 0;
196192
197- virtual ui::IWindow* getWindow () = 0;
198- inline const ui::IWindow* getWindow () const {return const_cast <ui::IWindow*>(const_cast <ISurface*>(this )->getWindow ());}
199-
200193 // used by some drivers
201194 virtual const void * getNativeWindowHandle () const = 0;
202195};
203196
204- // Base for use with Nabla's window wrappers
205- template <class Window , class ImmediateBase >
197+ // Base for use with Nabla's window wrappers, should maybe be called `CSurfaceWindow` instead, but oh well
198+ template <class Window , class ImmediateBase > requires (std::is_base_of_v<ui::IWindow,Window> && std::is_base_of_v<ISurface,ImmediateBase>)
206199class CSurface : public ImmediateBase
207200{
201+ using this_t = CSurface<Window, ImmediateBase>;
202+
208203 public:
209- inline ui::IWindow* getWindow () override final
204+ using window_t = Window;
205+ using immediate_base_t = ImmediateBase;
206+
207+ inline window_t * getWindow ()
210208 {
211209 return m_window.get ();
212210 }
211+ inline const window_t * getWindow () const {return const_cast <window_t *>(const_cast <this_t *>(this )->getWindow ());}
213212
214213 inline const void * getNativeWindowHandle () const override final
215214 {
@@ -218,17 +217,14 @@ class CSurface : public ImmediateBase
218217
219218 protected:
220219 template <typename ... Args>
221- CSurface (core::smart_refctd_ptr<Window >&& window, Args&&... args) : ImmediateBase (std::forward<Args>(args)...), m_window(std::move(window)) {}
220+ CSurface (core::smart_refctd_ptr<window_t >&& window, Args&&... args) : immediate_base_t (std::forward<Args>(args)...), m_window (std::move (window)) {}
222221 virtual ~CSurface () = default ;
223222
224- uint32_t getWidth () const override { return m_window->getWidth (); }
225- uint32_t getHeight () const override { return m_window->getHeight (); }
226-
227- core::smart_refctd_ptr<Window> m_window;
223+ core::smart_refctd_ptr<window_t > m_window;
228224};
229225
230- // Base to make surfaces directly from Native OS window handles
231- template <class Window , class ImmediateBase >
226+ // Base to make surfaces directly from Native OS window handles (TODO: while merging Erfan, template on the handle instead of the Window)
227+ template <class Window , class ImmediateBase > requires std::is_base_of_v<ISurface,ImmediateBase>
232228class CSurfaceNative : public ImmediateBase
233229{
234230 public:
0 commit comments