mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 02:40:00 +01:00
RenderingManager: FPS software limiter even with VSYNC
V-sync on multiple windows is not always performing well. So limiting to 61 FPS works with both VSYNC at 60FPS or without VSYNC. This means the settings for VSYNC is useless (removed from Settings panel).
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of vimix - video live mixer
|
* This file is part of vimix - video live mixer
|
||||||
*
|
*
|
||||||
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@gmail.com>
|
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@gmail.com>
|
||||||
@@ -311,6 +311,13 @@ void Rendering::pushBackDrawCallback(RenderingCallback function)
|
|||||||
|
|
||||||
void Rendering::draw()
|
void Rendering::draw()
|
||||||
{
|
{
|
||||||
|
// Poll and handle events (inputs, window resize, etc.)
|
||||||
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||||
|
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
||||||
|
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||||
|
glfwPollEvents();
|
||||||
|
|
||||||
// change windows fullscreen mode if requested
|
// change windows fullscreen mode if requested
|
||||||
main_.toggleFullscreen_();
|
main_.toggleFullscreen_();
|
||||||
output_.toggleFullscreen_();
|
output_.toggleFullscreen_();
|
||||||
@@ -338,28 +345,21 @@ void Rendering::draw()
|
|||||||
request_screenshot_ = false;
|
request_screenshot_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// software framerate limiter < 61 FPS
|
||||||
|
{
|
||||||
|
static GTimer *timer = g_timer_new ();
|
||||||
|
double elapsed = g_timer_elapsed (timer, NULL) * 1000000.0;
|
||||||
|
if ( (elapsed < 16390.0) && (elapsed > 0.0) )
|
||||||
|
g_usleep( 16390 - (gulong)elapsed );
|
||||||
|
g_timer_start(timer);
|
||||||
|
}
|
||||||
|
|
||||||
// swap GL buffers
|
// swap GL buffers
|
||||||
glfwSwapBuffers(main_.window());
|
glfwSwapBuffers(main_.window());
|
||||||
|
|
||||||
// draw output window (and swap buffer output)
|
// draw output window (and swap buffer output)
|
||||||
output_.draw( Mixer::manager().session()->frame() );
|
output_.draw( Mixer::manager().session()->frame() );
|
||||||
|
|
||||||
// software framerate limiter 60FPS if not v-sync
|
|
||||||
if ( Settings::application.render.vsync < 1 ) {
|
|
||||||
static GTimer *timer = g_timer_new ();
|
|
||||||
double elapsed = g_timer_elapsed (timer, NULL) * 1000000.0;
|
|
||||||
if ( (elapsed < 16000.0) && (elapsed > 0.0) )
|
|
||||||
g_usleep( 16000 - (gulong)elapsed );
|
|
||||||
g_timer_start(timer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Poll and handle events (inputs, window resize, etc.)
|
|
||||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
|
||||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
|
||||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
|
||||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
|
||||||
glfwPollEvents();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rendering::terminate()
|
void Rendering::terminate()
|
||||||
@@ -983,13 +983,13 @@ void RenderingWindow::draw(FrameBuffer *fb)
|
|||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// restore attribs
|
||||||
|
Rendering::manager().popAttrib();
|
||||||
|
|
||||||
// swap buffer
|
// swap buffer
|
||||||
glfwSwapBuffers(window_);
|
glfwSwapBuffers(window_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore attribs
|
|
||||||
Rendering::manager().popAttrib();
|
|
||||||
|
|
||||||
// give back context ownership
|
// give back context ownership
|
||||||
glfwMakeContextCurrent(master_);
|
glfwMakeContextCurrent(master_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7281,9 +7281,9 @@ void Navigator::RenderMainPannelSettings()
|
|||||||
static bool multi = (Settings::application.render.multisampling > 0);
|
static bool multi = (Settings::application.render.multisampling > 0);
|
||||||
static bool gpu = Settings::application.render.gpu_decoding;
|
static bool gpu = Settings::application.render.gpu_decoding;
|
||||||
bool change = false;
|
bool change = false;
|
||||||
change |= ImGuiToolkit::ButtonSwitch( "Vertical synchronization", &vsync);
|
|
||||||
change |= ImGuiToolkit::ButtonSwitch( "Blit framebuffer", &blit);
|
change |= ImGuiToolkit::ButtonSwitch( "Blit framebuffer", &blit);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
change |= ImGuiToolkit::ButtonSwitch( "Vertical synchronization", &vsync);
|
||||||
change |= ImGuiToolkit::ButtonSwitch( "Antialiasing framebuffer", &multi);
|
change |= ImGuiToolkit::ButtonSwitch( "Antialiasing framebuffer", &multi);
|
||||||
#endif
|
#endif
|
||||||
// hardware support deserves more explanation
|
// hardware support deserves more explanation
|
||||||
|
|||||||
Reference in New Issue
Block a user