mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-30 19:29:52 +02:00
Remove emscripten-only vsync fps limit type
This was ill-designed: "vsync" should be a draw cap limit, if anything. We can't currently think of a way to allow both vsync and a different arbitrary fps limit without banishing the simulation to another thread, so this gets shelved now.
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
struct FpsLimitVsync
|
|
||||||
{
|
|
||||||
};
|
|
||||||
struct FpsLimitNone
|
struct FpsLimitNone
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
@@ -11,7 +8,7 @@ struct FpsLimitExplicit
|
|||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
};
|
};
|
||||||
using FpsLimit = std::variant<FpsLimitVsync, FpsLimitNone, FpsLimitExplicit>;
|
using FpsLimit = std::variant<FpsLimitNone, FpsLimitExplicit>;
|
||||||
|
|
||||||
struct DrawLimitDisplay
|
struct DrawLimitDisplay
|
||||||
{
|
{
|
||||||
@@ -23,4 +20,5 @@ struct DrawLimitExplicit
|
|||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
};
|
};
|
||||||
|
// TODO: DrawLimitVsync
|
||||||
using DrawLimit = std::variant<DrawLimitDisplay, DrawLimitNone, DrawLimitExplicit>;
|
using DrawLimit = std::variant<DrawLimitDisplay, DrawLimitNone, DrawLimitExplicit>;
|
||||||
|
@@ -204,7 +204,7 @@ void SDLClose()
|
|||||||
void SDLSetScreen()
|
void SDLSetScreen()
|
||||||
{
|
{
|
||||||
auto newFrameOps = ui::Engine::Ref().windowFrameOps;
|
auto newFrameOps = ui::Engine::Ref().windowFrameOps;
|
||||||
auto newVsyncHint = std::holds_alternative<FpsLimitVsync>(ui::Engine::Ref().GetFpsLimit());
|
auto newVsyncHint = false; // TODO: DrawLimitVsync
|
||||||
if (FORCE_WINDOW_FRAME_OPS == forceWindowFrameOpsEmbedded)
|
if (FORCE_WINDOW_FRAME_OPS == forceWindowFrameOpsEmbedded)
|
||||||
{
|
{
|
||||||
newFrameOps.resizable = false;
|
newFrameOps.resizable = false;
|
||||||
|
@@ -22,13 +22,13 @@ void SetFpsLimit(FpsLimit newFpsLimit)
|
|||||||
emscripten_set_main_loop(MainLoopBody, 0, 0);
|
emscripten_set_main_loop(MainLoopBody, 0, 0);
|
||||||
mainLoopSet = true;
|
mainLoopSet = true;
|
||||||
}
|
}
|
||||||
if (std::get_if<FpsLimitVsync>(&newFpsLimit))
|
// if (std::get_if<FpsLimitVsync>(&newFpsLimit)) // TODO: DrawLimitVsync
|
||||||
{
|
// {
|
||||||
emscripten_set_main_loop_timing(EM_TIMING_RAF, 1);
|
// emscripten_set_main_loop_timing(EM_TIMING_RAF, 1);
|
||||||
std::cerr << "implicit fps limit via vsync" << std::endl;
|
// std::cerr << "implicit fps limit via vsync" << std::endl;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
auto delay = 0;
|
auto delay = 0;
|
||||||
if (auto *fpsLimitExplicit = std::get_if<FpsLimitExplicit>(&newFpsLimit))
|
if (auto *fpsLimitExplicit = std::get_if<FpsLimitExplicit>(&newFpsLimit))
|
||||||
{
|
{
|
||||||
@@ -36,7 +36,7 @@ void SetFpsLimit(FpsLimit newFpsLimit)
|
|||||||
}
|
}
|
||||||
emscripten_set_main_loop_timing(EM_TIMING_SETTIMEOUT, delay);
|
emscripten_set_main_loop_timing(EM_TIMING_SETTIMEOUT, delay);
|
||||||
std::cerr << "explicit fps limit: " << delay << "ms delays" << std::endl;
|
std::cerr << "explicit fps limit: " << delay << "ms delays" << std::endl;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFpsLimit()
|
void UpdateFpsLimit()
|
||||||
|
@@ -2564,11 +2564,7 @@ void GameView::OnDraw()
|
|||||||
fpsInfo << "\nSimulation";
|
fpsInfo << "\nSimulation";
|
||||||
fpsInfo << "\n FPS cap: ";
|
fpsInfo << "\n FPS cap: ";
|
||||||
auto fpsLimit = ui::Engine::Ref().GetFpsLimit();
|
auto fpsLimit = ui::Engine::Ref().GetFpsLimit();
|
||||||
if (std::holds_alternative<FpsLimitVsync>(fpsLimit))
|
if (std::holds_alternative<FpsLimitNone>(fpsLimit))
|
||||||
{
|
|
||||||
fpsInfo << "vsync";
|
|
||||||
}
|
|
||||||
else if (std::holds_alternative<FpsLimitNone>(fpsLimit))
|
|
||||||
{
|
{
|
||||||
fpsInfo << "none";
|
fpsInfo << "none";
|
||||||
}
|
}
|
||||||
|
@@ -201,11 +201,7 @@ static int fpsCap(lua_State *L)
|
|||||||
if (acount == 0)
|
if (acount == 0)
|
||||||
{
|
{
|
||||||
auto fpsLimit = ui::Engine::Ref().GetFpsLimit();
|
auto fpsLimit = ui::Engine::Ref().GetFpsLimit();
|
||||||
if (std::holds_alternative<FpsLimitVsync>(fpsLimit))
|
if (std::holds_alternative<FpsLimitNone>(fpsLimit))
|
||||||
{
|
|
||||||
lua_pushliteral(L, "vsync");
|
|
||||||
}
|
|
||||||
else if (std::holds_alternative<FpsLimitNone>(fpsLimit))
|
|
||||||
{
|
{
|
||||||
lua_pushnumber(L, 2);
|
lua_pushnumber(L, 2);
|
||||||
}
|
}
|
||||||
@@ -215,11 +211,6 @@ static int fpsCap(lua_State *L)
|
|||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (lua_isstring(L, 1) && byteStringEqualsLiteral(tpt_lua_toByteString(L, 1), "vsync"))
|
|
||||||
{
|
|
||||||
ui::Engine::Ref().SetFpsLimit(FpsLimitVsync{});
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
float fpscap = luaL_checknumber(L, 1);
|
float fpscap = luaL_checknumber(L, 1);
|
||||||
if (fpscap < 2)
|
if (fpscap < 2)
|
||||||
{
|
{
|
||||||
@@ -254,6 +245,7 @@ static int drawCap(lua_State *L)
|
|||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
// if (lua_isstring(L, 1) && byteStringEqualsLiteral(tpt_lua_toByteString(L, 1), "vsync")) // TODO: DrawLimitVsync
|
||||||
if (lua_isstring(L, 1) && byteStringEqualsLiteral(tpt_lua_toByteString(L, 1), "display"))
|
if (lua_isstring(L, 1) && byteStringEqualsLiteral(tpt_lua_toByteString(L, 1), "display"))
|
||||||
{
|
{
|
||||||
ui::Engine::Ref().SetDrawingFrequencyLimit(DrawLimitDisplay{});
|
ui::Engine::Ref().SetDrawingFrequencyLimit(DrawLimitDisplay{});
|
||||||
|
Reference in New Issue
Block a user