imgui_impl_metal.h 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
  5. // [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
  6. // [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
  7. // [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
  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. #pragma once
  16. #include "imgui.h" // IMGUI_IMPL_API
  17. #ifndef IMGUI_DISABLE
  18. //-----------------------------------------------------------------------------
  19. // ObjC API
  20. //-----------------------------------------------------------------------------
  21. #ifdef __OBJC__
  22. @class MTLRenderPassDescriptor;
  23. @protocol MTLDevice, MTLCommandBuffer, MTLRenderCommandEncoder;
  24. // Follow "Getting Started" link and check examples/ folder to learn about using backends!
  25. IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id<MTLDevice> device);
  26. IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
  27. IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor);
  28. IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* drawData,
  29. id<MTLCommandBuffer> commandBuffer,
  30. id<MTLRenderCommandEncoder> commandEncoder);
  31. // Called by Init/NewFrame/Shutdown
  32. IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device);
  33. IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
  34. // (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = NULL to handle this manually.
  35. IMGUI_IMPL_API void ImGui_ImplMetal_UpdateTexture(ImTextureData* tex);
  36. #endif
  37. //-----------------------------------------------------------------------------
  38. // C++ API
  39. //-----------------------------------------------------------------------------
  40. // Enable Metal C++ binding support with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file
  41. // More info about using Metal from C++: https://developer.apple.com/metal/cpp/
  42. #ifdef IMGUI_IMPL_METAL_CPP
  43. #include <Metal/Metal.hpp>
  44. #ifndef __OBJC__
  45. // Follow "Getting Started" link and check examples/ folder to learn about using backends!
  46. IMGUI_IMPL_API bool ImGui_ImplMetal_Init(MTL::Device* device);
  47. IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
  48. IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor);
  49. IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
  50. MTL::CommandBuffer* commandBuffer,
  51. MTL::RenderCommandEncoder* commandEncoder);
  52. // Called by Init/NewFrame/Shutdown
  53. IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device);
  54. IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
  55. // (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = NULL to handle this manually.
  56. IMGUI_IMPL_API void ImGui_ImplMetal_UpdateTexture(ImTextureData* tex);
  57. #endif
  58. #endif
  59. //-----------------------------------------------------------------------------
  60. #endif // #ifndef IMGUI_DISABLE