imgui_impl_metal.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
  10. // Read online: https://github.com/ocornut/imgui/tree/master/docs
  11. #include "imgui.h" // IMGUI_IMPL_API
  12. //-----------------------------------------------------------------------------
  13. // ObjC API
  14. //-----------------------------------------------------------------------------
  15. #ifdef __OBJC__
  16. @class MTLRenderPassDescriptor;
  17. @protocol MTLDevice, MTLCommandBuffer, MTLRenderCommandEncoder;
  18. IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id<MTLDevice> device);
  19. IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
  20. IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor);
  21. IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* drawData,
  22. id<MTLCommandBuffer> commandBuffer,
  23. id<MTLRenderCommandEncoder> commandEncoder);
  24. // Called by Init/NewFrame/Shutdown
  25. IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(id<MTLDevice> device);
  26. IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture();
  27. IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device);
  28. IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
  29. #endif
  30. //-----------------------------------------------------------------------------
  31. // C++ API
  32. //-----------------------------------------------------------------------------
  33. // Enable Metal C++ binding support with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file
  34. // More info about using Metal from C++: https://developer.apple.com/metal/cpp/
  35. #ifdef IMGUI_IMPL_METAL_CPP
  36. #include <Metal/Metal.hpp>
  37. #ifndef __OBJC__
  38. IMGUI_IMPL_API bool ImGui_ImplMetal_Init(MTL::Device* device);
  39. IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
  40. IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor);
  41. IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
  42. MTL::CommandBuffer* commandBuffer,
  43. MTL::RenderCommandEncoder* commandEncoder);
  44. // Called by Init/NewFrame/Shutdown
  45. IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(MTL::Device* device);
  46. IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture();
  47. IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device);
  48. IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
  49. #endif
  50. #endif