| 1 |
// dear imgui: Renderer Backend for Metal |
| 2 |
// This needs to be used along with a Platform Backend (e.g. OSX) |
| 3 |
|
| 4 |
// Implemented features: |
| 5 |
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID! |
| 6 |
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset). |
| 7 |
|
| 8 |
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. |
| 9 |
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. |
| 10 |
// Learn about Dear ImGui: |
| 11 |
// - FAQ https://dearimgui.com/faq |
| 12 |
// - Getting Started https://dearimgui.com/getting-started |
| 13 |
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder). |
| 14 |
// - Introduction, links and more at the top of imgui.cpp |
| 15 |
|
| 16 |
#include "imgui.h" // IMGUI_IMPL_API |
| 17 |
#ifndef IMGUI_DISABLE |
| 18 |
|
| 19 |
//----------------------------------------------------------------------------- |
| 20 |
// ObjC API |
| 21 |
//----------------------------------------------------------------------------- |
| 22 |
|
| 23 |
#ifdef __OBJC__ |
| 24 |
|
| 25 |
@class MTLRenderPassDescriptor; |
| 26 |
@protocol MTLDevice, MTLCommandBuffer, MTLRenderCommandEncoder; |
| 27 |
|
| 28 |
// Follow "Getting Started" link and check examples/ folder to learn about using backends! |
| 29 |
IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id<MTLDevice> device); |
| 30 |
IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown(); |
| 31 |
IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor); |
| 32 |
IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* drawData, |
| 33 |
id<MTLCommandBuffer> commandBuffer, |
| 34 |
id<MTLRenderCommandEncoder> commandEncoder); |
| 35 |
|
| 36 |
// Called by Init/NewFrame/Shutdown |
| 37 |
IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(id<MTLDevice> device); |
| 38 |
IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture(); |
| 39 |
IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device); |
| 40 |
IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects(); |
| 41 |
|
| 42 |
#endif |
| 43 |
|
| 44 |
//----------------------------------------------------------------------------- |
| 45 |
// C++ API |
| 46 |
//----------------------------------------------------------------------------- |
| 47 |
|
| 48 |
// Enable Metal C++ binding support with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file |
| 49 |
// More info about using Metal from C++: https://developer.apple.com/metal/cpp/ |
| 50 |
|
| 51 |
#ifdef IMGUI_IMPL_METAL_CPP |
| 52 |
#include <Metal/Metal.hpp> |
| 53 |
#ifndef __OBJC__ |
| 54 |
|
| 55 |
// Follow "Getting Started" link and check examples/ folder to learn about using backends! |
| 56 |
IMGUI_IMPL_API bool ImGui_ImplMetal_Init(MTL::Device* device); |
| 57 |
IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown(); |
| 58 |
IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor); |
| 59 |
IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, |
| 60 |
MTL::CommandBuffer* commandBuffer, |
| 61 |
MTL::RenderCommandEncoder* commandEncoder); |
| 62 |
|
| 63 |
// Called by Init/NewFrame/Shutdown |
| 64 |
IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(MTL::Device* device); |
| 65 |
IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture(); |
| 66 |
IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device); |
| 67 |
IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects(); |
| 68 |
|
| 69 |
#endif |
| 70 |
#endif |
| 71 |
|
| 72 |
//----------------------------------------------------------------------------- |
| 73 |
|
| 74 |
#endif // #ifndef IMGUI_DISABLE |