imgui_impl_metal.h 3.4 KB

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