imgui_impl_wgpu.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // dear imgui: Renderer for WebGPU
  2. // This needs to be used along with a Platform Binding (e.g. GLFW)
  3. // (Please note that WebGPU is currently experimental, will not run on non-beta browsers, and may break.)
  4. // Implemented features:
  5. // [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID!
  6. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
  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. #include <webgpu/webgpu.h>
  18. // Initialization data, for ImGui_ImplWGPU_Init()
  19. struct ImGui_ImplWGPU_InitInfo
  20. {
  21. WGPUDevice Device;
  22. int NumFramesInFlight = 3;
  23. WGPUTextureFormat RenderTargetFormat = WGPUTextureFormat_Undefined;
  24. WGPUTextureFormat DepthStencilFormat = WGPUTextureFormat_Undefined;
  25. WGPUMultisampleState PipelineMultisampleState = {};
  26. ImGui_ImplWGPU_InitInfo()
  27. {
  28. PipelineMultisampleState.count = 1;
  29. PipelineMultisampleState.mask = UINT32_MAX;
  30. PipelineMultisampleState.alphaToCoverageEnabled = false;
  31. }
  32. };
  33. // Follow "Getting Started" link and check examples/ folder to learn about using backends!
  34. IMGUI_IMPL_API bool ImGui_ImplWGPU_Init(ImGui_ImplWGPU_InitInfo* init_info);
  35. IMGUI_IMPL_API void ImGui_ImplWGPU_Shutdown();
  36. IMGUI_IMPL_API void ImGui_ImplWGPU_NewFrame();
  37. IMGUI_IMPL_API void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder);
  38. // Use if you want to reset your rendering device without losing Dear ImGui state.
  39. IMGUI_IMPL_API void ImGui_ImplWGPU_InvalidateDeviceObjects();
  40. IMGUI_IMPL_API bool ImGui_ImplWGPU_CreateDeviceObjects();
  41. #endif // #ifndef IMGUI_DISABLE