bkaradzic / bgfx

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
https://bkaradzic.github.io/bgfx/overview.html
BSD 2-Clause "Simplified" License
15.05k stars 1.94k forks source link

feat: add module map #3275

Closed okwasniewski closed 7 months ago

okwasniewski commented 7 months ago

This PR adds a module map that allows the use of BGFX together with Swift C++ interop (https://www.swift.org/documentation/cxx-interop/#creating-a-clang-module).

Example: CleanShot 2024-04-04 at 11 55 41@2x

bkaradzic commented 7 months ago

This would make sense if we had swift bindings directory to maybe put it there. But otherwise it really makes no sense to add this to repo.

okwasniewski commented 7 months ago

Hey @bkaradzic,

Maybe I didn't explain my motivation correctly. We are working on extending bgfx support for rendering on Apple Vision Pro in Immersive Spaces. Having module maps is not going to benefit only Swift C++ Interop this is a general feature of Clang modules (https://clang.llvm.org/docs/Modules.html#module-maps) which can improve build times, provide a better structure and as mentioned before allow Swift users to use BGFX without any other bindings. I saw other projects with Swift bindings (https://github.com/SwiftGFX/SwiftBGFX) but they are unmantained and this allows to use bgfx with Swift code without any additional bindings.

bkaradzic commented 7 months ago

Yeah, I would prefer that file is located in bindings/swift directory or something similar. Not where C/C++ includes are.

matthargett commented 7 months ago

Would bindings/C++ work as a location, since this is still a purely C++ language feature being used for interop? That is, this should also work in GCC and VC++ when their C++2a support std flag is enabled.

bkaradzic commented 7 months ago

Currently bgfx is C++17 only.

Basically we don't need this feature...