#pragma once #include #include struct xcb_connection_t; class IBoxed { friend struct BoxDeleter; private: virtual void destroy() = 0; }; struct BoxDeleter { void operator()(IBoxed* obj) { obj->destroy(); } }; template using Box = std::unique_ptr; struct alignas(16) Vec4 { float x, y, z, w; }; namespace ffi { struct RedrawArgs { float cam_yaw; float cam_pitch; float cam_distance; float cam_fovy; }; } // namespace ffi using ffi::RedrawArgs; class ICore : public IBoxed { public: virtual void configure(std::uint32_t width, std::uint32_t height) = 0; virtual void redraw(const RedrawArgs& args) = 0; }; class ICoreFactory : public IBoxed { private: virtual ICore* new_xcb(xcb_connection_t* connection, std::uint32_t window, std::uint32_t width, std::uint32_t height) const = 0; public: Box from_xcb(xcb_connection_t* connection, std::uint32_t window, std::uint32_t width, std::uint32_t height) const { return Box{new_xcb(connection, window, width, height)}; } };