The Metal renderer - MadLadSquad/UImGuiRendererExamples GitHub Wiki
The Metal renderer uses Apple's Metal API, which is exclusive to Apple's family of operating systems.
Testing the Metal renderer
Add the following line to Config/cmake/UImGuiDemo.cmake
:
set(IMGUI_BUILD_WITH_METAL ON)
In Source/Instance.hpp
you can include it like this:
#ifdef __APPLE__
#include <UImGuiRendererExamples/metal/metal.hpp>
#endif
And create an instance of the UImGuiRendererExamples::MetalRenderer
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 __APPLE__
.customRenderer = &metalRenderer,
#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 __APPLE__
#include <UImGuiRendererExamples/metal/metal.hpp>
#include <UImGuiRendererExamples/metal/metal_texture.hpp>
#endif
Create an instance of UImGuiRendererExamples::MetalTexture
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 __APPLE__
.customRenderer = &metalRenderer,
.customTexture = &metalTexture
#endif
UIMGUI_INIT_INFO_DEFAULT_DIRS,
};
}