DirectXTK.NET is a .NET wrapper for the DirectX Tool Kit, built using C++/CLI for Silk.NET and DirectX 11.
Currently only methods are wrapped that allow you to quickly load textures for your Silk.NET DirectX 11 project:
- Texture Creation with WICTextureLoader: Load textures from files and obtain shader resource views.
- Texture Creation with DDSTextureLoader: Load textures from *.dds files and obtain shader resource views.
- Texture Saving: Save textures to DDS or WIC formats.
To use DirectXTK.NET, follow these steps:
- Install via NuGet: Add the package to your project using the .NET CLI:
Or, search for
dotnet add package DirectXTK.NET
DirectXTK.NET
in the NuGet Package Manager in Visual Studio. - Initialize DirectX: Create and initialize a DirectX 11 device and context using Silk.NET.
- Use the package: Use the
WICTextureHelper
class to create and save textures or theDDSTextureHelper
class to load.dds
textures.
A simple example that shows how to create and save a texture with DirectXTK.NET:
WICTextureHelper.CreateTextureFromFile(device, @"Resources\stone.dds", texture.GetAddressOf(), textureSrv.GetAddressOf());
DDSTextureHelper.CreateDDSTextureFromFile(device, devCtx, @"Resources\sky.dds", 0, Usage.Immutable, (uint)BindFlag.ShaderResource, 0, ResourceMiscFlag.Texturecube, DDSLoaderFlag.Default, texture.GetAddressOf(), textureSrv.GetAddressOf(), DDSAlphaMode.Unknown);
WICTextureHelper.SaveWICTextureToFile(devCtx, texture, @"Resources\stone_out.png", ContainerFormat.Png, PixelFormat.Format32bppBGRA, true);
The sample can also be found in the repository under DirectXTKSample.
If you have specific feature requests or need additional methods, feel free to open an issue.