The DirectX 12 renderer uses Microsoft’s DirectX 12, which is exclusive to Windows-based operating systems.
Testing the DirectX 12 renderer
Add the following line to Config/cmake/UImGuiDemo.cmake:
set(IMGUI_BUILD_WITH_DX12 ON)
In Source/Instance.hpp, you can include it like this:
#ifdef _WIN32
#include <UImGuiRendererExamples/dx12/dx12.hpp>
#endif
And create an instance of the UImGuiRendererExamples::DX12Renderer as a member variable inside the UImGuiDemo::Instance class.
After that, in Source/Instance.cpp, make sure your constructor looks like this:
UImGuiDemo::Instance::Instance() noexcept
{
initInfo =
{
.titlebarComponents = { reinterpret_cast<UImGui::TitlebarComponent*>(&title) },
.windowComponents = { reinterpret_cast<UImGui::WindowComponent*>(&demoWindow) },
#ifdef _WIN32
.customRenderer = &dx12Renderer,
#endif
UIMGUI_INIT_INFO_DEFAULT_DIRS,
};
}
Testing the custom texture renderer
A custom texture renderer is also provided. To use it, include the following in Source/Instance.hpp:
#ifdef _WIN32
#include <UImGuiRendererExamples/dx12/dx12.hpp>
#include <UImGuiRendererExamples/dx12/dx12_texture.hpp>
#endif
Create an instance of UImGuiRendererExamples::DX12Texture as a member variable inside the UImGuiDemo::Instance class and then pass the instance to the init info:
UImGuiDemo::Instance::Instance() noexcept
{
initInfo =
{
.titlebarComponents = { reinterpret_cast<UImGui::TitlebarComponent*>(&title) },
.windowComponents = { reinterpret_cast<UImGui::WindowComponent*>(&demoWindow) },
#ifdef _WIN32
.customRenderer = &dx12Renderer,
.customTexture = &dx12Texture,
#endif
UIMGUI_INIT_INFO_DEFAULT_DIRS,
};
}