simpler draw range adjustment (it is mostly useless with vsync anyway)

This commit is contained in:
milek7
2019-03-18 23:27:09 +01:00
parent 4b3bea9ea3
commit 62a3d2f92c
4 changed files with 20 additions and 32 deletions

View File

@@ -75,10 +75,19 @@ global_settings::ConfigParse(cParser &Parser) {
}
else if (token == "heightbase")
{
Parser.getTokens(1, false);
Parser >> fDistanceFactor;
}
else if (token == "targetfps")
{
Parser.getTokens(1, false);
Parser >> targetfps;
}
else if (token == "basedrawrange")
{
Parser.getTokens(1);
Parser >> BaseDrawRange;
}
else if (token == "fullscreen")
{
Parser.getTokens();

View File

@@ -104,7 +104,8 @@ struct global_settings {
int iWindowWidth{ 800 };
int iWindowHeight{ 600 };
float fDistanceFactor{ iWindowHeight / 768.f }; // baza do przeliczania odległości dla LoD
float fDistanceFactor{ 1.0f }; // baza do przeliczania odległości dla LoD
float targetfps { 0.0f };
bool bFullScreen{ false };
bool VSync{ false };
bool bWireFrame{ false };

View File

@@ -64,8 +64,7 @@ void window_resize_callback( GLFWwindow *window, int w, int h ) {
// NOTE: we have two variables which basically do the same thing as we don't have dynamic fullscreen toggle
// TBD, TODO: merge them?
Global.iWindowWidth = w;
Global.iWindowHeight = h;
Global.fDistanceFactor = std::max( 0.5f, h / 768.0f ); // not sure if this is really something we want to use
Global.iWindowHeight = h;
glViewport( 0, 0, w, h );
}

View File

@@ -3674,35 +3674,14 @@ void opengl_renderer::Update(double const Deltatime)
m_framerate = 1000.f / (Timer::subsystem.mainloop_total.average());
// adjust draw ranges etc, based on recent performance
auto const framerate = 1000.f / Timer::subsystem.gfx_color.average();
// TODO: it doesn't make much sense with vsync
float targetfactor;
if (framerate > 90.0)
{
targetfactor = 3.0f;
}
else if (framerate > 60.0)
{
targetfactor = 1.5f;
}
else if (framerate > 30.0)
{
targetfactor = 1.25;
}
else
{
targetfactor = std::max(Global.iWindowHeight / 768.f, 1.f);
}
if (targetfactor > Global.fDistanceFactor)
{
Global.fDistanceFactor = std::min(targetfactor, Global.fDistanceFactor + 0.05f);
}
else if (targetfactor < Global.fDistanceFactor)
{
Global.fDistanceFactor = std::max(targetfactor, Global.fDistanceFactor - 0.05f);
if (Global.targetfps != 0.0f) {
float fps_diff = Global.targetfps - m_framerate;
if (fps_diff > 0.0f)
Global.fDistanceFactor = std::max(0.5f, Global.fDistanceFactor - 0.05f);
else
Global.fDistanceFactor = std::min(3.0f, Global.fDistanceFactor + 0.05f);
}
if ((true == Global.ResourceSweep) && (true == simulation::is_ready))