@@ -257,10 +257,6 @@ VkPipelineShaderStageCreateInfo VulkanExampleBase::loadShader(std::string fileNa
257257void VulkanExampleBase::nextFrame ()
258258{
259259 auto tStart = std::chrono::high_resolution_clock::now ();
260- if (viewUpdated)
261- {
262- viewUpdated = false ;
263- }
264260 render ();
265261 frameCounter++;
266262 auto tEnd = std::chrono::high_resolution_clock::now ();
@@ -272,10 +268,6 @@ void VulkanExampleBase::nextFrame()
272268#endif
273269 frameTimer = (float )tDiff / 1000 .0f ;
274270 camera.update (frameTimer);
275- if (camera.moving ())
276- {
277- viewUpdated = true ;
278- }
279271 // Convert to clamped timer value
280272 if (!paused)
281273 {
@@ -450,20 +442,12 @@ void VulkanExampleBase::renderLoop()
450442 while (!quit)
451443 {
452444 auto tStart = std::chrono::high_resolution_clock::now ();
453- if (viewUpdated)
454- {
455- viewUpdated = false ;
456- }
457445 render ();
458446 frameCounter++;
459447 auto tEnd = std::chrono::high_resolution_clock::now ();
460448 auto tDiff = std::chrono::duration<double , std::milli>(tEnd - tStart).count ();
461449 frameTimer = tDiff / 1000 .0f ;
462450 camera.update (frameTimer);
463- if (camera.moving ())
464- {
465- viewUpdated = true ;
466- }
467451 // Convert to clamped timer value
468452 if (!paused)
469453 {
@@ -486,10 +470,6 @@ void VulkanExampleBase::renderLoop()
486470 while (!quit)
487471 {
488472 auto tStart = std::chrono::high_resolution_clock::now ();
489- if (viewUpdated)
490- {
491- viewUpdated = false ;
492- }
493473 DFBWindowEvent event;
494474 while (!event_buffer->GetEvent (event_buffer, DFB_EVENT (&event)))
495475 {
@@ -501,10 +481,6 @@ void VulkanExampleBase::renderLoop()
501481 auto tDiff = std::chrono::duration<double , std::milli>(tEnd - tStart).count ();
502482 frameTimer = tDiff / 1000 .0f ;
503483 camera.update (frameTimer);
504- if (camera.moving ())
505- {
506- viewUpdated = true ;
507- }
508484 // Convert to clamped timer value
509485 if (!paused)
510486 {
@@ -527,10 +503,6 @@ void VulkanExampleBase::renderLoop()
527503 while (!quit)
528504 {
529505 auto tStart = std::chrono::high_resolution_clock::now ();
530- if (viewUpdated)
531- {
532- viewUpdated = false ;
533- }
534506
535507 while (!configured)
536508 {
@@ -553,10 +525,6 @@ void VulkanExampleBase::renderLoop()
553525 auto tDiff = std::chrono::duration<double , std::milli>(tEnd - tStart).count ();
554526 frameTimer = tDiff / 1000 .0f ;
555527 camera.update (frameTimer);
556- if (camera.moving ())
557- {
558- viewUpdated = true ;
559- }
560528 // Convert to clamped timer value
561529 if (!paused)
562530 {
@@ -585,10 +553,6 @@ void VulkanExampleBase::renderLoop()
585553 while (!quit)
586554 {
587555 auto tStart = std::chrono::high_resolution_clock::now ();
588- if (viewUpdated)
589- {
590- viewUpdated = false ;
591- }
592556 xcb_generic_event_t *event;
593557 while ((event = xcb_poll_for_event (connection)))
594558 {
@@ -601,10 +565,6 @@ void VulkanExampleBase::renderLoop()
601565 auto tDiff = std::chrono::duration<double , std::milli>(tEnd - tStart).count ();
602566 frameTimer = tDiff / 1000 .0f ;
603567 camera.update (frameTimer);
604- if (camera.moving ())
605- {
606- viewUpdated = true ;
607- }
608568 // Convert to clamped timer value
609569 if (!paused)
610570 {
@@ -634,20 +594,12 @@ void VulkanExampleBase::renderLoop()
634594 while (!quit)
635595 {
636596 auto tStart = std::chrono::high_resolution_clock::now ();
637- if (viewUpdated)
638- {
639- viewUpdated = false ;
640- }
641597 render ();
642598 frameCounter++;
643599 auto tEnd = std::chrono::high_resolution_clock::now ();
644600 auto tDiff = std::chrono::duration<double , std::milli>(tEnd - tStart).count ();
645601 frameTimer = tDiff / 1000 .0f ;
646602 camera.update (frameTimer);
647- if (camera.moving ())
648- {
649- viewUpdated = true ;
650- }
651603 // Convert to clamped timer value
652604 timer += timerSpeed * frameTimer;
653605 if (timer > 1.0 )
@@ -764,7 +716,6 @@ void VulkanExampleBase::prepareFrame(bool waitForFence)
764716
765717void VulkanExampleBase::submitFrame (bool skipQueueSubmit)
766718{
767- // @todo: make this an argument
768719 if (!skipQueueSubmit) {
769720 const VkPipelineStageFlags waitPipelineStage{ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT };
770721 VkSubmitInfo submitInfo{ .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO };
@@ -1399,7 +1350,6 @@ void VulkanExampleBase::handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
13991350 {
14001351 short wheelDelta = GET_WHEEL_DELTA_WPARAM (wParam);
14011352 camera.translate (glm::vec3 (0 .0f , 0 .0f , (float )wheelDelta * 0 .005f ));
1402- viewUpdated = true ;
14031353 break ;
14041354 }
14051355 case WM_MOUSEMOVE:
@@ -1878,26 +1828,8 @@ static CVReturn displayLinkOutputCallback(CVDisplayLinkRef displayLink, const CV
18781828 short wheelDelta = [event deltaY];
18791829 vulkanExample->camera .translate (glm::vec3 (0 .0f , 0 .0f ,
18801830 -(float )wheelDelta * 0 .05f * vulkanExample->camera .movementSpeed ));
1881- vulkanExample->viewUpdated = true ;
18821831}
18831832
1884- // SRS - Window resizing already handled by windowResize() in VulkanExampleBase::submitFrame()
1885- // - handling window resize events here is redundant and can cause thread interaction problems
1886- /*
1887- - (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize
1888- {
1889- CVDisplayLinkStop(displayLink);
1890- vulkanExample->windowWillResize(frameSize.width, frameSize.height);
1891- return frameSize;
1892- }
1893-
1894- - (void)windowDidResize:(NSNotification *)notification
1895- {
1896- vulkanExample->windowDidResize();
1897- CVDisplayLinkStart(displayLink);
1898- }
1899- */
1900-
19011833- (void )windowWillEnterFullScreen:(NSNotification *)notification
19021834{
19031835 vulkanExample->settings .fullscreen = true ;
@@ -2193,34 +2125,27 @@ void VulkanExampleBase::handleEvent(const DFBWindowEvent *event)
21932125 }
21942126}
21952127#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
2196- /* static*/ void VulkanExampleBase::registryGlobalCb (void *data,
2197- wl_registry *registry, uint32_t name, const char *interface,
2198- uint32_t version)
2128+ /* static*/ void VulkanExampleBase::registryGlobalCb (void *data, wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
21992129{
22002130 VulkanExampleBase *self = reinterpret_cast <VulkanExampleBase *>(data);
22012131 self->registryGlobal (registry, name, interface, version);
22022132}
22032133
2204- /* static*/ void VulkanExampleBase::seatCapabilitiesCb (void *data, wl_seat *seat,
2205- uint32_t caps)
2134+ /* static*/ void VulkanExampleBase::seatCapabilitiesCb (void *data, wl_seat *seat, uint32_t caps)
22062135{
22072136 VulkanExampleBase *self = reinterpret_cast <VulkanExampleBase *>(data);
22082137 self->seatCapabilities (seat, caps);
22092138}
22102139
2211- /* static*/ void VulkanExampleBase::pointerEnterCb (void *data,
2212- wl_pointer *pointer, uint32_t serial, wl_surface *surface,
2213- wl_fixed_t sx, wl_fixed_t sy)
2140+ /* static*/ void VulkanExampleBase::pointerEnterCb (void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy)
22142141{
22152142}
22162143
2217- /* static*/ void VulkanExampleBase::pointerLeaveCb (void *data,
2218- wl_pointer *pointer, uint32_t serial, wl_surface *surface)
2144+ /* static*/ void VulkanExampleBase::pointerLeaveCb (void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface)
22192145{
22202146}
22212147
2222- /* static*/ void VulkanExampleBase::pointerMotionCb (void *data,
2223- wl_pointer *pointer, uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
2148+ /* static*/ void VulkanExampleBase::pointerMotionCb (void *data, wl_pointer *pointer, uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
22242149{
22252150 VulkanExampleBase *self = reinterpret_cast <VulkanExampleBase *>(data);
22262151 self->pointerMotion (pointer, time, sx, sy);
@@ -2230,16 +2155,13 @@ void VulkanExampleBase::pointerMotion(wl_pointer *pointer, uint32_t time, wl_fix
22302155 handleMouseMove (wl_fixed_to_int (sx), wl_fixed_to_int (sy));
22312156}
22322157
2233- /* static*/ void VulkanExampleBase::pointerButtonCb (void *data,
2234- wl_pointer *pointer, uint32_t serial, uint32_t time, uint32_t button,
2235- uint32_t state)
2158+ /* static*/ void VulkanExampleBase::pointerButtonCb (void *data, wl_pointer *pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
22362159{
22372160 VulkanExampleBase *self = reinterpret_cast <VulkanExampleBase *>(data);
22382161 self->pointerButton (pointer, serial, time, button, state);
22392162}
22402163
2241- void VulkanExampleBase::pointerButton (struct wl_pointer *pointer,
2242- uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
2164+ void VulkanExampleBase::pointerButton (struct wl_pointer *pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
22432165{
22442166 switch (button)
22452167 {
@@ -2257,56 +2179,44 @@ void VulkanExampleBase::pointerButton(struct wl_pointer *pointer,
22572179 }
22582180}
22592181
2260- /* static*/ void VulkanExampleBase::pointerAxisCb (void *data,
2261- wl_pointer *pointer, uint32_t time, uint32_t axis,
2262- wl_fixed_t value)
2182+ /* static*/ void VulkanExampleBase::pointerAxisCb (void *data, wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value)
22632183{
22642184 VulkanExampleBase *self = reinterpret_cast <VulkanExampleBase *>(data);
22652185 self->pointerAxis (pointer, time, axis, value);
22662186}
22672187
2268- void VulkanExampleBase::pointerAxis (wl_pointer *pointer, uint32_t time,
2269- uint32_t axis, wl_fixed_t value)
2188+ void VulkanExampleBase::pointerAxis (wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value)
22702189{
22712190 double d = wl_fixed_to_double (value);
22722191 switch (axis)
22732192 {
22742193 case REL_X:
22752194 camera.translate (glm::vec3 (0 .0f , 0 .0f , d * 0 .005f ));
2276- viewUpdated = true ;
22772195 break ;
22782196 default :
22792197 break ;
22802198 }
22812199}
22822200
2283- /* static*/ void VulkanExampleBase::keyboardKeymapCb (void *data,
2284- struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size)
2201+ /* static*/ void VulkanExampleBase::keyboardKeymapCb (void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size)
22852202{
22862203}
22872204
2288- /* static*/ void VulkanExampleBase::keyboardEnterCb (void *data,
2289- struct wl_keyboard *keyboard, uint32_t serial,
2290- struct wl_surface *surface, struct wl_array *keys)
2205+ /* static*/ void VulkanExampleBase::keyboardEnterCb (void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys)
22912206{
22922207}
22932208
2294- /* static*/ void VulkanExampleBase::keyboardLeaveCb (void *data,
2295- struct wl_keyboard *keyboard, uint32_t serial,
2296- struct wl_surface *surface)
2209+ /* static*/ void VulkanExampleBase::keyboardLeaveCb (void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface)
22972210{
22982211}
22992212
2300- /* static*/ void VulkanExampleBase::keyboardKeyCb (void *data,
2301- struct wl_keyboard *keyboard, uint32_t serial, uint32_t time,
2302- uint32_t key, uint32_t state)
2213+ /* static*/ void VulkanExampleBase::keyboardKeyCb (void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
23032214{
23042215 VulkanExampleBase *self = reinterpret_cast <VulkanExampleBase *>(data);
23052216 self->keyboardKey (keyboard, serial, time, key, state);
23062217}
23072218
2308- void VulkanExampleBase::keyboardKey (struct wl_keyboard *keyboard,
2309- uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
2219+ void VulkanExampleBase::keyboardKey (struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
23102220{
23112221 switch (key)
23122222 {
@@ -2340,9 +2250,7 @@ void VulkanExampleBase::keyboardKey(struct wl_keyboard *keyboard,
23402250 keyPressed (key);
23412251}
23422252
2343- /* static*/ void VulkanExampleBase::keyboardModifiersCb (void *data,
2344- struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed,
2345- uint32_t mods_latched, uint32_t mods_locked, uint32_t group)
2253+ /* static*/ void VulkanExampleBase::keyboardModifiersCb (void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group)
23462254{
23472255}
23482256
@@ -2386,8 +2294,7 @@ static const struct xdg_wm_base_listener xdg_wm_base_listener = {
23862294 xdg_wm_base_ping,
23872295};
23882296
2389- void VulkanExampleBase::registryGlobal (wl_registry *registry, uint32_t name,
2390- const char *interface, uint32_t version)
2297+ void VulkanExampleBase::registryGlobal (wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
23912298{
23922299 if (strcmp (interface, " wl_compositor" ) == 0 )
23932300 {
@@ -2411,8 +2318,7 @@ void VulkanExampleBase::registryGlobal(wl_registry *registry, uint32_t name,
24112318 }
24122319}
24132320
2414- /* static*/ void VulkanExampleBase::registryGlobalRemoveCb (void *data,
2415- struct wl_registry *registry, uint32_t name)
2321+ /* static*/ void VulkanExampleBase::registryGlobalRemoveCb (void *data, struct wl_registry *registry, uint32_t name)
24162322{
24172323}
24182324
@@ -2464,8 +2370,7 @@ void VulkanExampleBase::setSize(int width, int height)
24642370}
24652371
24662372static void
2467- xdg_surface_handle_configure (void *data, struct xdg_surface *surface,
2468- uint32_t serial)
2373+ xdg_surface_handle_configure (void *data, struct xdg_surface *surface, uint32_t serial)
24692374{
24702375 VulkanExampleBase *base = (VulkanExampleBase *) data;
24712376
@@ -2479,9 +2384,7 @@ static const struct xdg_surface_listener xdg_surface_listener = {
24792384
24802385
24812386static void
2482- xdg_toplevel_handle_configure (void *data, struct xdg_toplevel *toplevel,
2483- int32_t width, int32_t height,
2484- struct wl_array *states)
2387+ xdg_toplevel_handle_configure (void *data, struct xdg_toplevel *toplevel, int32_t width, int32_t height, struct wl_array *states)
24852388{
24862389 VulkanExampleBase *base = (VulkanExampleBase *) data;
24872390
@@ -2914,7 +2817,6 @@ void VulkanExampleBase::handleEvent()
29142817 }
29152818 if (val != 0 ) {
29162819 camera.translate (glm::vec3 (0 .0f , 0 .0f , (float )val * 0 .005f ));
2917- viewUpdated = true ;
29182820 }
29192821
29202822 rc = screen_get_event_property_iv (screen_event, SCREEN_PROPERTY_POSITION, pos);
@@ -3278,15 +3180,12 @@ void VulkanExampleBase::handleMouseMove(int32_t x, int32_t y)
32783180
32793181 if (mouseState.buttons .left ) {
32803182 camera.rotate (glm::vec3 (dy * camera.rotationSpeed , -dx * camera.rotationSpeed , 0 .0f ));
3281- viewUpdated = true ;
32823183 }
32833184 if (mouseState.buttons .right ) {
32843185 camera.translate (glm::vec3 (-0 .0f , 0 .0f , dy * .005f ));
3285- viewUpdated = true ;
32863186 }
32873187 if (mouseState.buttons .middle ) {
32883188 camera.translate (glm::vec3 (-dx * 0 .005f , -dy * 0 .005f , 0 .0f ));
3289- viewUpdated = true ;
32903189 }
32913190 mouseState.position = glm::vec2 ((float )x, (float )y);
32923191}
0 commit comments