I'm trying to set up ImGui with the SDL2 backend and software renderer. In the provided example (./examples/example_sdl2_sdlrenderer2/main.cpp
) there are these three calls at the beginning of every rendering cycle:
// Start the Dear ImGui frame
ImGui_ImplSDLRenderer2_NewFrame();
ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame();
If I comment out any one of these calls, the program crashes. If I reorder them, it crashes for some orders and works fine for other orders. So why are these three even separate calls? What is the difference between them, and why do I need all three?
I expected there to be at least some documentation on this question (specifically, on the subject of what order I'm supposed to call them in, which depends on which etc.), but there is nothing about them. There are general documentation pages for ImGui::NewFrame()
, but it's as if the other two do not exist at all.
Additional questions: Are there any circumstances in which it makes sense to use only one or two of them? Is one ordering of them preferable to another, at least sometimes?
ImGui and its backends are modular.
ImGui::NewFrame();
is to be called regardless of the used backend.ImGui_ImplSDL2_NewFrame();
is for SDL2 backend, but SDL2 supports multiple different rendering methods (OpenGL, Vulkan, builtin renderer).ImGui_ImplSDLRenderer2_NewFrame();
is for SDL2's builtin renderer.