diff --git a/VoidLink/ImGuiRenderer.h b/VoidLink/ImGuiRenderer.h index ac5cc620..d65094a5 100644 --- a/VoidLink/ImGuiRenderer.h +++ b/VoidLink/ImGuiRenderer.h @@ -28,6 +28,7 @@ typedef void (^MetricsHandler)(int plotId, CFTimeInterval value); @property (nonatomic) BOOL enableGraphs; @property (nonatomic) float graphOpacity; @property (nonatomic) BOOL imguiRunning; +@property (nonatomic) int streamFps; @property (nonatomic) MetricsHandler _Nonnull metricsHandler; -(nonnull instancetype) initWithFrame:(CGRect)bounds diff --git a/VoidLink/ImGuiRenderer.mm b/VoidLink/ImGuiRenderer.mm index a819a163..26f4d10a 100644 --- a/VoidLink/ImGuiRenderer.mm +++ b/VoidLink/ImGuiRenderer.mm @@ -42,6 +42,9 @@ _plots = [ImGuiPlots sharedInstance].plots; + // Store stream FPS to synchronize MTKView + _streamFps = streamFps; + return self; } @@ -90,7 +93,7 @@ self.mtkView.device = self.device; self.mtkView.delegate = self; - self.mtkView.preferredFramesPerSecond = 60; // ImGui overlay will always render at this rate + self.mtkView.preferredFramesPerSecond = _streamFps; // Synchronize with stream framerate self.mtkView.opaque = NO; self.mtkView.enableSetNeedsDisplay = NO; @@ -173,7 +176,7 @@ #if TARGET_OS_SIMULATOR [commandBuffer presentDrawable:view.currentDrawable]; #else - [commandBuffer presentDrawable:view.currentDrawable afterMinimumDuration:1.0 / view.preferredFramesPerSecond]; + [commandBuffer presentDrawable:view.currentDrawable afterMinimumDuration:1.0 / _streamFps]; #endif [commandBuffer commit]; #endif