microsoft / DirectXTK12

The DirectX Tool Kit (aka DirectXTK12) is a collection of helper classes for writing DirectX 12 code in C++
https://walbourn.github.io/directx-tool-kit-for-directx-12/
MIT License
1.5k stars 395 forks source link

Make namespace configurable (avoid conflict with D3D11 DirectXTK) #135

Closed fredemmott closed 2 years ago

fredemmott commented 2 years ago

For example, it is useful for an OpenXR API Layer to be able to operate seamlessly with games that use either D3D11 or D3D12, which in turn makes it useful to be able to use both the Direct3D 11 and Direct3D 12 versions of DirectXTK in the same library.

One way to do this would be to add a cmake option, then use configure_file() to generate a config.h specifying the namespace as a #define, defaulting to DirectX, but making it so I could e.g. specify that I want it built with DirectX12 instead.

walbourn commented 2 years ago

Operator overloading should make most of the functions with the same name already distinct for linkage.

I could add a build option that removes the shared modules in cmake.

What other conflicts have you encountered

walbourn commented 2 years ago

Here's a proposed solution:

https://github.com/microsoft/DirectXTK/pull/333

https://github.com/microsoft/DirectXTK12/pull/136

fredemmott commented 2 years ago

The conflict I was hitting was for classes like DirectX::SpriteBatch - where, for example, DirectX::SpriteBatch::~SpriteBatch() is defined in each library

walbourn commented 2 years ago

The inline namespace should fix this at least at link time.