Changeset 6053b24 in opengl-game for sdl-game.cpp
- Timestamp:
- Feb 14, 2021, 6:53:53 PM (4 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- db1b548
- Parents:
- 8d96e95
- git-author:
- Dmitry Portnoy <dportnoy@…> (02/14/21 18:53:48)
- git-committer:
- Dmitry Portnoy <dportnoy@…> (02/14/21 18:53:53)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sdl-game.cpp
r8d96e95 r6053b24 154 154 done = false; 155 155 while (!done) { 156 // Poll and handle events (inputs, window resize, etc.) 157 // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. 158 // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. 159 // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. 160 // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. 161 SDL_Event event; 162 while (SDL_PollEvent(&event)) { 163 ImGui_ImplSDL2_ProcessEvent(&event); 164 if (event.type == SDL_QUIT) 156 157 gui->processEvents(); 158 159 UIEvent uiEvent; 160 while (gui->pollEvent(&uiEvent)) { 161 GameEvent& e = uiEvent.event; 162 SDL_Event sdlEvent = uiEvent.rawEvent.sdl; 163 164 ImGui_ImplSDL2_ProcessEvent(&sdlEvent); 165 if (io.WantCaptureMouse && 166 (e.type == UI_EVENT_MOUSEBUTTONDOWN || e.type == UI_EVENT_MOUSEBUTTONUP || e.type == UI_EVENT_UNKNOWN)) { 167 if (sdlEvent.type == SDL_MOUSEWHEEL || sdlEvent.type == SDL_MOUSEBUTTONDOWN || sdlEvent.type == SDL_MOUSEBUTTONUP) { 168 continue; 169 } 170 } 171 if (io.WantCaptureKeyboard && 172 (e.type == UI_EVENT_KEYDOWN || e.type == UI_EVENT_KEYUP)) { 173 if (sdlEvent.type == SDL_KEYDOWN || sdlEvent.type == SDL_KEYUP) { 174 continue; 175 } 176 } 177 if (io.WantTextInput) { 178 // show onscreen keyboard if on mobile 179 } 180 181 if (e.type == UI_EVENT_QUIT) { 165 182 done = true; 166 if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window)) 167 done = true; 183 } 168 184 } 169 185
Note:
See TracChangeset
for help on using the changeset viewer.