imgui_sdl
imgui_sdl copied to clipboard
Input from imgui in example.cpp doesn't work
Input doesn't handle events properly. I used code from example.cpp.
The simplest way to get inputs to work reliably is to use the built-in backend (https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_sdl.cpp). Now the problem is the generic ImGui_ImplSDL2_Init is not public - only ImGui_ImplSDL2_InitForOpenGL etc. But at least as of now, these do not do anything really, just forward to ImGui_ImplSDL2_Init. So, to get inputs, resize events etc. working, that's all you need:
ImGui_ImplSDL2_InitForOpenGL(window, nullptr);
(...)
SDL_Event event;
while (SDL_PollEvent(&event)) ImGui_ImplSDL2_ProcessEvent(&event);
(...)
ImGui_ImplSDL2_NewFrame(window);
ImGui::NewFrame();