-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcimgui_impl.mm
182 lines (140 loc) · 4.68 KB
/
cimgui_impl.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#include "imgui/imgui.h"
#ifdef CIMGUI_FREETYPE
#include "./imgui/misc/freetype/imgui_freetype.h"
#endif
#include "imgui/imgui_internal.h"
#include "cimgui_impl.h"
#if CIMGUI_USE_OSX | CIMGUI_USE_METAL
#import <AppKit/AppKit.h>
#endif
#if CIMGUI_USE_METAL
#import <Metal/Metal.h>
#import <QuartzCore/QuartzCore.h>
#endif
#if CIMGUI_USE_METAL
#include "imgui/backends/imgui_impl_metal.h"
#endif
#if CIMGUI_USE_OSX
#include "imgui/backends/imgui_impl_osx.h"
#endif
// OSX Backend Implementations
#if CIMGUI_USE_OSX
#ifdef __OBJC__
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
CIMGUI_API bool CImGui_ImplOSX_Init(void *view)
{
return ImGui_ImplOSX_Init(reinterpret_cast<NSView *>(view));
}
CIMGUI_API void CImGui_ImplOSX_Shutdown()
{
ImGui_ImplOSX_Shutdown();
}
CIMGUI_API void CImGui_ImplOSX_NewFrame(void *view)
{
ImGui_ImplOSX_NewFrame(reinterpret_cast<NSView *>(view));
}
#endif
//-----------------------------------------------------------------------------
// C++ API
//-----------------------------------------------------------------------------
#ifdef IMGUI_IMPL_METAL_CPP_EXTENSIONS
// #include <AppKit/AppKit.hpp>
#ifndef __OBJC__
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
CIMGUI_API bool CImGui_ImplOSX_Init(void *view)
{
return ImGui_ImplOSX_Init(view);
}
CIMGUI_API void CImGui_ImplOSX_Shutdown()
{
ImGui_ImplOSX_Shutdown();
}
CIMGUI_API void CImGui_ImplOSX_NewFrame(void *view)
{
ImGui_ImplOSX_NewFrame(view);
}
#endif
#endif
#endif
// Metal Backend Implementations
#if CIMGUI_USE_METAL
#ifdef __OBJC__
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
CIMGUI_API bool CImGui_ImplMetal_Init(void *device)
{
return ImGui_ImplMetal_Init(reinterpret_cast<id<MTLDevice>>(device));
}
CIMGUI_API void CImGui_ImplMetal_Shutdown()
{
ImGui_ImplMetal_Shutdown();
}
CIMGUI_API void CImGui_ImplMetal_NewFrame(void *renderPassDescriptor)
{
ImGui_ImplMetal_NewFrame(reinterpret_cast<MTLRenderPassDescriptor*>(renderPassDescriptor));
}
CIMGUI_API void CImGui_ImplMetal_RenderDrawData(ImDrawData *draw_data, void *commandBuffer, void *commandEncoder)
{
ImGui_ImplMetal_RenderDrawData(draw_data, reinterpret_cast<id<MTLCommandBuffer>>(commandBuffer), reinterpret_cast<id<MTLRenderCommandEncoder>>(commandEncoder));
}
// Called by Init/NewFrame/Shutdown
CIMGUI_API bool CImGui_ImplMetal_CreateFontsTexture(void *device)
{
return ImGui_ImplMetal_CreateFontsTexture(reinterpret_cast<id<MTLDevice>>(device));
}
CIMGUI_API void CImGui_ImplMetal_DestroyFontsTexture()
{
ImGui_ImplMetal_DestroyFontsTexture();
}
CIMGUI_API bool CImGui_ImplMetal_CreateDeviceObjects(void *device)
{
return ImGui_ImplMetal_CreateDeviceObjects(reinterpret_cast<id<MTLDevice>>(device));
}
CIMGUI_API void CImGui_ImplMetal_DestroyDeviceObjects()
{
ImGui_ImplMetal_DestroyDeviceObjects();
}
#endif
//-----------------------------------------------------------------------------
// C++ API
//-----------------------------------------------------------------------------
// Enable Metal C++ binding support with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file
// More info about using Metal from C++: https://developer.apple.com/metal/cpp/
#ifdef IMGUI_IMPL_METAL_CPP
#ifndef __OBJC__
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
CIMGUI_API bool CImGui_ImplMetal_Init(MTLDevice *device)
{
return ImGui_ImplMetal_Init(reinterpret_cast<MTL::Device *>(device));
}
CIMGUI_API void CImGui_ImplMetal_Shutdown()
{
ImGui_ImplMetal_Shutdown();
}
CIMGUI_API void CImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor *renderPassDescriptor)
{
ImGui_ImplMetal_NewFrame(reinterpret_cast<MTL::RenderPassDescriptor *>(renderPassDescriptor));
}
CIMGUI_API void CImGui_ImplMetal_RenderDrawData(ImDrawData *draw_data, MTLCommandBuffer *commandBuffer, MTLRenderCommandEncoder *commandEncoder)
{
ImGui_ImplMetal_RenderDrawData(draw_data, reinterpret_cast<MTL::CommandBuffer *>(commandBuffer), reinterpret_cast<MTL::RenderCommandEncoder *>(commandEncoder));
}
// Called by Init/NewFrame/Shutdown
CIMGUI_API bool CImGui_ImplMetal_CreateFontsTexture(MTLDevice *device)
{
return ImGui_ImplMetal_CreateFontsTexture(reinterpret_cast<MTL::Device *>(device));
}
CIMGUI_API void CImGui_ImplMetal_DestroyFontsTexture()
{
ImGui_ImplMetal_DestroyFontsTexture();
}
CIMGUI_API bool CImGui_ImplMetal_CreateDeviceObjects(MTLDevice *device)
{
return ImGui_ImplMetal_CreateDeviceObjects(reinterpret_cast<MTL::Device *>(device));
}
CIMGUI_API void CImGui_ImplMetal_DestroyDeviceObjects()
{
ImGui_ImplMetal_DestroyDeviceObjects();
}
#endif
#endif
#endif