imgui_impl_sdlrenderer2.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // dear imgui: Renderer Backend for SDL_Renderer for SDL2
  2. // (Requires: SDL 2.0.17+)
  3. // Note that SDL_Renderer is an _optional_ component of SDL2, which IMHO is now largely obsolete.
  4. // For a multi-platform app consider using other technologies:
  5. // - SDL3+SDL_GPU: SDL_GPU is SDL3 new graphics abstraction API. You will need to update to SDL3.
  6. // - SDL2+DirectX, SDL2+OpenGL, SDL2+Vulkan: combine SDL with dedicated renderers.
  7. // If your application wants to render any non trivial amount of graphics other than UI,
  8. // please be aware that SDL_Renderer currently offers a limited graphic API to the end-user
  9. // and it might be difficult to step out of those boundaries.
  10. // Implemented features:
  11. // [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
  12. // [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
  13. // [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
  14. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
  15. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
  16. // Learn about Dear ImGui:
  17. // - FAQ https://dearimgui.com/faq
  18. // - Getting Started https://dearimgui.com/getting-started
  19. // - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
  20. // - Introduction, links and more at the top of imgui.cpp
  21. #pragma once
  22. #ifndef IMGUI_DISABLE
  23. #include "imgui.h" // IMGUI_IMPL_API
  24. struct SDL_Renderer;
  25. // Follow "Getting Started" link and check examples/ folder to learn about using backends!
  26. IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_Init(SDL_Renderer* renderer);
  27. IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_Shutdown();
  28. IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_NewFrame();
  29. IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer* renderer);
  30. // Called by Init/NewFrame/Shutdown
  31. IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_CreateFontsTexture();
  32. IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_DestroyFontsTexture();
  33. IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_CreateDeviceObjects();
  34. IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_DestroyDeviceObjects();
  35. // [BETA] Selected render state data shared with callbacks.
  36. // This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplSDLRenderer2_RenderDrawData() call.
  37. // (Please open an issue if you feel you need access to more data)
  38. struct ImGui_ImplSDLRenderer2_RenderState
  39. {
  40. SDL_Renderer* Renderer;
  41. };
  42. #endif // #ifndef IMGUI_DISABLE