4 KB、79行 生 Blame 履歴
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 texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
6// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
7// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
8// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
9
10// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
11// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
12// Learn about Dear ImGui:
13// - FAQ https://dearimgui.com/faq
14// - Getting Started https://dearimgui.com/getting-started
15// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
16// - Introduction, links and more at the top of imgui.cpp
17
18#pragma once
19#include "imgui.h" // IMGUI_IMPL_API
20#ifndef IMGUI_DISABLE
21
22//-----------------------------------------------------------------------------
23// ObjC API
24//-----------------------------------------------------------------------------
25
26#ifdef __OBJC__
27
28@class MTLRenderPassDescriptor;
29@protocol MTLDevice, MTLCommandBuffer, MTLRenderCommandEncoder;
30
31// Follow "Getting Started" link and check examples/ folder to learn about using backends!
32IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id<MTLDevice> device);
33IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
34IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor);
35IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* drawData,
36 id<MTLCommandBuffer> commandBuffer,
37 id<MTLRenderCommandEncoder> commandEncoder);
38
39// Called by Init/NewFrame/Shutdown
40IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device);
41IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
42
43// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
44IMGUI_IMPL_API void ImGui_ImplMetal_UpdateTexture(ImTextureData* tex);
45
46#endif
47
48//-----------------------------------------------------------------------------
49// C++ API
50//-----------------------------------------------------------------------------
51
52// Enable Metal C++ binding support with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file
53// More info about using Metal from C++: https://developer.apple.com/metal/cpp/
54
55#ifdef IMGUI_IMPL_METAL_CPP
56#include <Metal/Metal.hpp>
57#ifndef __OBJC__
58
59// Follow "Getting Started" link and check examples/ folder to learn about using backends!
60IMGUI_IMPL_API bool ImGui_ImplMetal_Init(MTL::Device* device);
61IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
62IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor);
63IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
64 MTL::CommandBuffer* commandBuffer,
65 MTL::RenderCommandEncoder* commandEncoder);
66
67// Called by Init/NewFrame/Shutdown
68IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device);
69IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
70
71// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
72IMGUI_IMPL_API void ImGui_ImplMetal_UpdateTexture(ImTextureData* tex);
73
74#endif
75#endif
76
77//-----------------------------------------------------------------------------
78
79#endif // #ifndef IMGUI_DISABLE