imgui_impl_metal.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
  6. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
  7. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
  8. // Learn about Dear ImGui:
  9. // - FAQ https://dearimgui.com/faq
  10. // - Getting Started https://dearimgui.com/getting-started
  11. // - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
  12. // - Introduction, links and more at the top of imgui.cpp
  13. #pragma once
  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. // Follow "Getting Started" link and check examples/ folder to learn about using backends!
  23. IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id<MTLDevice> device);
  24. IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
  25. IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor);
  26. IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* drawData,
  27. id<MTLCommandBuffer> commandBuffer,
  28. id<MTLRenderCommandEncoder> commandEncoder);
  29. // Called by Init/NewFrame/Shutdown
  30. IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(id<MTLDevice> device);
  31. IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture();
  32. IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device);
  33. IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
  34. #endif
  35. //-----------------------------------------------------------------------------
  36. // C++ API
  37. //-----------------------------------------------------------------------------
  38. // Enable Metal C++ binding support with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file
  39. // More info about using Metal from C++: https://developer.apple.com/metal/cpp/
  40. #ifdef IMGUI_IMPL_METAL_CPP
  41. #include <Metal/Metal.hpp>
  42. #ifndef __OBJC__
  43. // Follow "Getting Started" link and check examples/ folder to learn about using backends!
  44. IMGUI_IMPL_API bool ImGui_ImplMetal_Init(MTL::Device* device);
  45. IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
  46. IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor);
  47. IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
  48. MTL::CommandBuffer* commandBuffer,
  49. MTL::RenderCommandEncoder* commandEncoder);
  50. // Called by Init/NewFrame/Shutdown
  51. IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(MTL::Device* device);
  52. IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture();
  53. IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device);
  54. IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
  55. #endif
  56. #endif
  57. //-----------------------------------------------------------------------------
  58. #endif // #ifndef IMGUI_DISABLE