Changeset 5081b9a in opengl-game
- Timestamp:
- Apr 7, 2021, 2:29:16 AM (4 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- db2d995
- Parents:
- e469aed
- git-author:
- Dmitry Portnoy <dportnoy@…> (04/07/21 02:25:11)
- git-committer:
- Dmitry Portnoy <dportnoy@…> (04/07/21 02:29:16)
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sdl-game.cpp
re469aed r5081b9a 196 196 while (!done) { 197 197 198 prevTime = curTime; 198 199 curTime = duration<float, seconds::period>(steady_clock::now() - startTime).count(); 200 elapsedTime = curTime - prevTime; 199 201 200 202 if (curTime - fpsStartTime >= 1.0f) { … … 215 217 216 218 ImGui_ImplSDL2_ProcessEvent(&sdlEvent); 217 if (io.WantCaptureMouse && 218 (e.type == UI_EVENT_MOUSEBUTTONDOWN || e.type == UI_EVENT_MOUSEBUTTONUP || e.type == UI_EVENT_UNKNOWN)) { 219 if (sdlEvent.type == SDL_MOUSEWHEEL || sdlEvent.type == SDL_MOUSEBUTTONDOWN || sdlEvent.type == SDL_MOUSEBUTTONUP) { 219 if ((e.type == UI_EVENT_MOUSEBUTTONDOWN || e.type == UI_EVENT_MOUSEBUTTONUP || e.type == UI_EVENT_UNKNOWN) && 220 io.WantCaptureMouse) { 221 if (sdlEvent.type == SDL_MOUSEWHEEL || sdlEvent.type == SDL_MOUSEBUTTONDOWN || 222 sdlEvent.type == SDL_MOUSEBUTTONUP) { 220 223 continue; 221 224 } 222 225 } 223 if (io.WantCaptureKeyboard && 224 (e.type == UI_EVENT_KEYDOWN || e.type == UI_EVENT_KEYUP)) { 226 if ((e.type == UI_EVENT_KEYDOWN || e.type == UI_EVENT_KEYUP) && io.WantCaptureKeyboard) { 225 227 if (sdlEvent.type == SDL_KEYDOWN || sdlEvent.type == SDL_KEYUP) { 226 228 continue; … … 232 234 233 235 switch (e.type) { 234 case UI_EVENT_MOUSEMOTION: 235 // Currently unused 236 break; 237 case UI_EVENT_WINDOW: 238 // Currently unused 239 break; 240 case UI_EVENT_QUIT: 241 cout << "Quit event detected" << endl; 242 done = true; 243 break; 244 case UI_EVENT_UNHANDLED: 245 cout << "Unhandled event type: 0x" << hex << sdlEvent.type << dec << endl; 246 break; 247 case UI_EVENT_UNKNOWN: 248 default: 249 cout << "Unknown event type: 0x" << hex << sdlEvent.type << dec << endl; 250 break; 236 case UI_EVENT_QUIT: 237 cout << "Quit event detected" << endl; 238 done = true; 239 break; 240 case UI_EVENT_WINDOWRESIZE: 241 cout << "Window resize event detected" << endl; 242 shouldRecreateSwapChain = true; 243 break; 244 case UI_EVENT_KEYUP: 245 // START UNREVIEWED SECTION 246 // END UNREVIEWED SECTION 247 break; 248 case UI_EVENT_WINDOW: 249 case UI_EVENT_MOUSEBUTTONDOWN: 250 case UI_EVENT_MOUSEBUTTONUP: 251 case UI_EVENT_MOUSEMOTION: 252 break; 253 case UI_EVENT_UNHANDLED: 254 cout << "Unhandled event type: 0x" << hex << sdlEvent.type << dec << endl; 255 break; 256 case UI_EVENT_UNKNOWN: 257 default: 258 cout << "Unknown event type: 0x" << hex << sdlEvent.type << dec << endl; 259 break; 251 260 } 252 261 } -
sdl-game.hpp
re469aed r5081b9a 122 122 // TODO: Make a separate singleton Timer class 123 123 time_point<steady_clock> startTime; 124 float fpsStartTime, curTime ;124 float fpsStartTime, curTime, prevTime, elapsedTime; 125 125 126 126 int frameCount; -
vulkan-game.cpp
re469aed r5081b9a 661 661 662 662 ImGui_ImplSDL2_ProcessEvent(&sdlEvent); 663 if (io.WantCaptureMouse && 664 (e.type == UI_EVENT_MOUSEBUTTONDOWN || e.type == UI_EVENT_MOUSEBUTTONUP || e.type == UI_EVENT_UNKNOWN)) { 665 if (sdlEvent.type == SDL_MOUSEWHEEL || sdlEvent.type == SDL_MOUSEBUTTONDOWN || sdlEvent.type == SDL_MOUSEBUTTONUP) { 663 if ((e.type == UI_EVENT_MOUSEBUTTONDOWN || e.type == UI_EVENT_MOUSEBUTTONUP || e.type == UI_EVENT_UNKNOWN) && 664 io.WantCaptureMouse) { 665 if (sdlEvent.type == SDL_MOUSEWHEEL || sdlEvent.type == SDL_MOUSEBUTTONDOWN || 666 sdlEvent.type == SDL_MOUSEBUTTONUP) { 666 667 continue; 667 668 } 668 669 } 669 if (io.WantCaptureKeyboard && 670 (e.type == UI_EVENT_KEYDOWN || e.type == UI_EVENT_KEYUP)) { 670 if ((e.type == UI_EVENT_KEYDOWN || e.type == UI_EVENT_KEYUP) && io.WantCaptureKeyboard) { 671 671 if (sdlEvent.type == SDL_KEYDOWN || sdlEvent.type == SDL_KEYUP) { 672 672 continue; … … 681 681 cout << "Quit event detected" << endl; 682 682 done = true; 683 break;684 case UI_EVENT_WINDOW:685 cout << "Window event detected" << endl;686 // Currently unused687 683 break; 688 684 case UI_EVENT_WINDOWRESIZE: … … 764 760 } 765 761 break; 762 case UI_EVENT_WINDOW: 766 763 case UI_EVENT_MOUSEBUTTONDOWN: 767 764 case UI_EVENT_MOUSEBUTTONUP: 768 765 case UI_EVENT_MOUSEMOTION: 769 766 break; 767 case UI_EVENT_UNHANDLED: 768 cout << "Unhandled event type: 0x" << hex << sdlEvent.type << dec << endl; 769 break; 770 770 case UI_EVENT_UNKNOWN: 771 //cout << "Unknown event type: 0x" << hex << e.unknown.eventType << dec << endl; 771 default: 772 cout << "Unknown event type: 0x" << hex << sdlEvent.type << dec << endl; 772 773 break; 773 default:774 cout << "Unhandled UI event: " << e.type << endl;775 774 } 776 775 … … 1574 1573 1575 1574 for (size_t i = 0; i < swapChainImageCount; i++) { 1576 if (vkCreateSemaphore(device, &semaphoreInfo, nullptr, &imageAcquiredSemaphores[i]) != VK_SUCCESS) { 1577 throw runtime_error("failed to create image acquired sempahore for a frame!"); 1578 } 1579 1580 if (vkCreateSemaphore(device, &semaphoreInfo, nullptr, &renderCompleteSemaphores[i]) != VK_SUCCESS) { 1581 throw runtime_error("failed to create render complete sempahore for a frame!"); 1582 } 1583 1584 if (vkCreateFence(device, &fenceInfo, nullptr, &inFlightFences[i]) != VK_SUCCESS) { 1585 throw runtime_error("failed to create fence for a frame!"); 1586 } 1575 VKUTIL_CHECK_RESULT(vkCreateSemaphore(device, &semaphoreInfo, nullptr, &imageAcquiredSemaphores[i]), 1576 "failed to create image acquired sempahore for a frame!"); 1577 1578 VKUTIL_CHECK_RESULT(vkCreateSemaphore(device, &semaphoreInfo, nullptr, &renderCompleteSemaphores[i]), 1579 "failed to create render complete sempahore for a frame!"); 1580 1581 VKUTIL_CHECK_RESULT(vkCreateFence(device, &fenceInfo, nullptr, &inFlightFences[i]), 1582 "failed to create fence for a frame!"); 1587 1583 } 1588 1584 }
Note:
See TracChangeset
for help on using the changeset viewer.