imgui_impl_sdlrenderer2.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
  12. // [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
  13. // [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
  14. // [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
  15. // Missing features:
  16. // [ ] Renderer: Multi-viewport support (multiple windows).
  17. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
  18. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
  19. // Learn about Dear ImGui:
  20. // - FAQ https://dearimgui.com/faq
  21. // - Getting Started https://dearimgui.com/getting-started
  22. // - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
  23. // - Introduction, links and more at the top of imgui.cpp
  24. #pragma once
  25. #ifndef IMGUI_DISABLE
  26. #include "imgui.h" // IMGUI_IMPL_API
  27. struct SDL_Renderer;
  28. // Follow "Getting Started" link and check examples/ folder to learn about using backends!
  29. IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_Init(SDL_Renderer* renderer);
  30. IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_Shutdown();
  31. IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_NewFrame();
  32. IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer* renderer);
  33. // Called by Init/NewFrame/Shutdown
  34. IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_CreateDeviceObjects();
  35. IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_DestroyDeviceObjects();
  36. // (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.
  37. IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_UpdateTexture(ImTextureData* tex);
  38. // [BETA] Selected render state data shared with callbacks.
  39. // This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplSDLRenderer2_RenderDrawData() call.
  40. // (Please open an issue if you feel you need access to more data)
  41. struct ImGui_ImplSDLRenderer2_RenderState
  42. {
  43. SDL_Renderer* Renderer;
  44. };
  45. #endif // #ifndef IMGUI_DISABLE