imgui_impl_metal.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. // 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. #pragma once
  15. #include "imgui.h" // IMGUI_IMPL_API
  16. #ifndef IMGUI_DISABLE
  17. //-----------------------------------------------------------------------------
  18. // ObjC API
  19. //-----------------------------------------------------------------------------
  20. #ifdef __OBJC__
  21. @class MTLRenderPassDescriptor;
  22. @protocol MTLDevice, MTLCommandBuffer, MTLRenderCommandEncoder;
  23. // Follow "Getting Started" link and check examples/ folder to learn about using backends!
  24. IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id<MTLDevice> device);
  25. IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
  26. IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor);
  27. IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* drawData,
  28. id<MTLCommandBuffer> commandBuffer,
  29. id<MTLRenderCommandEncoder> commandEncoder);
  30. // Called by Init/NewFrame/Shutdown
  31. IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device);
  32. IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
  33. // (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.
  34. IMGUI_IMPL_API void ImGui_ImplMetal_UpdateTexture(ImTextureData* tex);
  35. #endif
  36. //-----------------------------------------------------------------------------
  37. // C++ API
  38. //-----------------------------------------------------------------------------
  39. // Enable Metal C++ binding support with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file
  40. // More info about using Metal from C++: https://developer.apple.com/metal/cpp/
  41. #ifdef IMGUI_IMPL_METAL_CPP
  42. #include <Metal/Metal.hpp>
  43. #ifndef __OBJC__
  44. // Follow "Getting Started" link and check examples/ folder to learn about using backends!
  45. IMGUI_IMPL_API bool ImGui_ImplMetal_Init(MTL::Device* device);
  46. IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
  47. IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor);
  48. IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
  49. MTL::CommandBuffer* commandBuffer,
  50. MTL::RenderCommandEncoder* commandEncoder);
  51. // Called by Init/NewFrame/Shutdown
  52. IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device);
  53. IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
  54. // (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.
  55. IMGUI_IMPL_API void ImGui_ImplMetal_UpdateTexture(ImTextureData* tex);
  56. #endif
  57. #endif
  58. //-----------------------------------------------------------------------------
  59. #endif // #ifndef IMGUI_DISABLE