Fix CMakeLists.txt for vulkanExamples.xcodeproj build, fix macOS storyboard for resizable window, set animation rate based on display refresh period

This commit is contained in:
Stephen Saunders 2022-05-04 00:43:14 -04:00
parent d1975e91ee
commit b1f10d7393
7 changed files with 71 additions and 47 deletions

View file

@ -22,7 +22,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink,
CVOptionFlags* flagsOut,
void* target) {
//((MVKExample*)target)->renderFrame();
((MVKExample*)target)->displayLinkOutputCb(); // SRS - Call MVKExample::displayLinkOutputCb() to animate frames vs. MVKExample::renderFrame() for static image
((MVKExample*)target)->displayLinkOutputCb(); // SRS - Call displayLinkOutputCb() to animate frames vs. renderFrame() for static image
return kCVReturnSuccess;
}
@ -48,23 +48,18 @@ MVKExample* _mvkExample;
CVDisplayLinkStart(_displayLink);
}
// SRS - get the actual refresh period of the display
// SRS - Set window's initial content size and set VulkanExampleBase::refreshPeriod from the displayLink
-(void) viewWillAppear {
[super viewWillAppear];
_mvkExample->getRefreshPeriod(CVDisplayLinkGetActualOutputVideoRefreshPeriod(_displayLink));
}
// SRS - Handle window resize events (FIXME: resizeable window not yet supported at init)
-(NSSize) windowWillResize:(NSWindow*) sender toSize:(NSSize)frameSize {
CVDisplayLinkStop(_displayLink);
_mvkExample->windowWillResize(frameSize.width, frameSize.height);
return frameSize;
}
NSWindow* window = self.view.window;
NSSize viewSize;
viewSize.width = _mvkExample->width;
viewSize.height = _mvkExample->height;
[window setContentSize:viewSize];
[window center];
-(void) windowDidResize:(NSNotification*) notification {
_mvkExample->windowDidResize();
CVDisplayLinkStart(_displayLink);
_mvkExample->setRefreshPeriod(CVDisplayLinkGetActualOutputVideoRefreshPeriod(_displayLink));
}
-(void) dealloc {