mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-01-29 04:27:50 +01:00
Expose threaded rendering as a setting
This commit is contained in:
parent
a9b84e5f26
commit
bf5f9fdcb0
@ -1728,7 +1728,7 @@ void GameController::AfterSimDraw()
|
|||||||
commandInterface->HandleEvent(AfterSimDrawEvent{});
|
commandInterface->HandleEvent(AfterSimDrawEvent{});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameController::HaveSimGraphicsEventHandlers()
|
bool GameController::ThreadedRenderingAllowed()
|
||||||
{
|
{
|
||||||
return commandInterface->HaveSimGraphicsEventHandlers();
|
return gameModel->GetThreadedRendering() && !commandInterface->HaveSimGraphicsEventHandlers();
|
||||||
}
|
}
|
||||||
|
@ -205,5 +205,5 @@ public:
|
|||||||
|
|
||||||
void BeforeSimDraw();
|
void BeforeSimDraw();
|
||||||
void AfterSimDraw();
|
void AfterSimDraw();
|
||||||
bool HaveSimGraphicsEventHandlers();
|
bool ThreadedRenderingAllowed();
|
||||||
};
|
};
|
||||||
|
@ -100,6 +100,7 @@ GameModel::GameModel():
|
|||||||
|
|
||||||
rendererSettings.gravityFieldEnabled = prefs.Get("Renderer.GravityField", false);
|
rendererSettings.gravityFieldEnabled = prefs.Get("Renderer.GravityField", false);
|
||||||
rendererSettings.decorations_enable = prefs.Get("Renderer.Decorations", true);
|
rendererSettings.decorations_enable = prefs.Get("Renderer.Decorations", true);
|
||||||
|
threadedRendering = prefs.Get("Renderer.SeparateThread", false);
|
||||||
|
|
||||||
//Load config into simulation
|
//Load config into simulation
|
||||||
edgeMode = prefs.Get("Simulation.EdgeMode", NUM_EDGEMODES, EDGE_VOID);
|
edgeMode = prefs.Get("Simulation.EdgeMode", NUM_EDGEMODES, EDGE_VOID);
|
||||||
@ -537,6 +538,11 @@ void GameModel::SetTemperatureScale(int temperatureScale)
|
|||||||
this->temperatureScale = temperatureScale;
|
this->temperatureScale = temperatureScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameModel::SetThreadedRendering(bool newThreadedRendering)
|
||||||
|
{
|
||||||
|
threadedRendering = newThreadedRendering;
|
||||||
|
}
|
||||||
|
|
||||||
void GameModel::SetAmbientAirTemperature(float ambientAirTemp)
|
void GameModel::SetAmbientAirTemperature(float ambientAirTemp)
|
||||||
{
|
{
|
||||||
this->ambientAirTemp = ambientAirTemp;
|
this->ambientAirTemp = ambientAirTemp;
|
||||||
|
@ -130,6 +130,7 @@ private:
|
|||||||
void SaveToSimParameters(const GameSave &saveData);
|
void SaveToSimParameters(const GameSave &saveData);
|
||||||
|
|
||||||
std::optional<int> queuedVote;
|
std::optional<int> queuedVote;
|
||||||
|
bool threadedRendering = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GameModel();
|
GameModel();
|
||||||
@ -144,6 +145,11 @@ public:
|
|||||||
{
|
{
|
||||||
return temperatureScale;
|
return temperatureScale;
|
||||||
}
|
}
|
||||||
|
void SetThreadedRendering(bool newThreadedRendering);
|
||||||
|
bool GetThreadedRendering() const
|
||||||
|
{
|
||||||
|
return threadedRendering;
|
||||||
|
}
|
||||||
void SetAmbientAirTemperature(float ambientAirTemp);
|
void SetAmbientAirTemperature(float ambientAirTemp);
|
||||||
float GetAmbientAirTemperature();
|
float GetAmbientAirTemperature();
|
||||||
void SetDecoSpace(int decoSpace);
|
void SetDecoSpace(int decoSpace);
|
||||||
|
@ -2153,8 +2153,8 @@ void GameView::OnDraw()
|
|||||||
{
|
{
|
||||||
Graphics * g = GetGraphics();
|
Graphics * g = GetGraphics();
|
||||||
|
|
||||||
auto wantRendererThread = !c->HaveSimGraphicsEventHandlers();
|
auto threadedRenderingAllowed = c->ThreadedRenderingAllowed();
|
||||||
if (wantRendererThread)
|
if (threadedRenderingAllowed)
|
||||||
{
|
{
|
||||||
StartRendererThread();
|
StartRendererThread();
|
||||||
WaitForRendererThread();
|
WaitForRendererThread();
|
||||||
@ -2526,7 +2526,7 @@ void GameView::OnDraw()
|
|||||||
fpsInfo << " [FIND]";
|
fpsInfo << " [FIND]";
|
||||||
if (showDebug)
|
if (showDebug)
|
||||||
{
|
{
|
||||||
if (wantRendererThread)
|
if (threadedRenderingAllowed)
|
||||||
{
|
{
|
||||||
fpsInfo << " [SRT]";
|
fpsInfo << " [SRT]";
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,11 @@ void OptionsController::SetTemperatureScale(int temperatureScale)
|
|||||||
model->SetTemperatureScale(temperatureScale);
|
model->SetTemperatureScale(temperatureScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OptionsController::SetThreadedRendering(bool newThreadedRendering)
|
||||||
|
{
|
||||||
|
model->SetThreadedRendering(newThreadedRendering);
|
||||||
|
}
|
||||||
|
|
||||||
void OptionsController::SetFullscreen(bool fullscreen)
|
void OptionsController::SetFullscreen(bool fullscreen)
|
||||||
{
|
{
|
||||||
model->SetFullscreen(fullscreen);
|
model->SetFullscreen(fullscreen);
|
||||||
|
@ -24,6 +24,7 @@ public:
|
|||||||
void SetAmbientAirTemperature(float ambientAirTemp);
|
void SetAmbientAirTemperature(float ambientAirTemp);
|
||||||
void SetEdgeMode(int edgeMode);
|
void SetEdgeMode(int edgeMode);
|
||||||
void SetTemperatureScale(int temperatureScale);
|
void SetTemperatureScale(int temperatureScale);
|
||||||
|
void SetThreadedRendering(bool newThreadedRendering);
|
||||||
void SetFullscreen(bool fullscreen);
|
void SetFullscreen(bool fullscreen);
|
||||||
void SetChangeResolution(bool newChangeResolution);
|
void SetChangeResolution(bool newChangeResolution);
|
||||||
void SetForceIntegerScaling(bool forceIntegerScaling);
|
void SetForceIntegerScaling(bool forceIntegerScaling);
|
||||||
|
@ -95,6 +95,18 @@ void OptionsModel::SetTemperatureScale(int temperatureScale)
|
|||||||
notifySettingsChanged();
|
notifySettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int OptionsModel::GetThreadedRendering()
|
||||||
|
{
|
||||||
|
return gModel->GetThreadedRendering();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OptionsModel::SetThreadedRendering(bool newThreadedRendering)
|
||||||
|
{
|
||||||
|
GlobalPrefs::Ref().Set("Renderer.SeparateThread", newThreadedRendering);
|
||||||
|
gModel->SetThreadedRendering(newThreadedRendering);
|
||||||
|
notifySettingsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
float OptionsModel::GetAmbientAirTemperature()
|
float OptionsModel::GetAmbientAirTemperature()
|
||||||
{
|
{
|
||||||
return gModel->GetSimulation()->air->ambientAirTemp;
|
return gModel->GetSimulation()->air->ambientAirTemp;
|
||||||
|
@ -31,6 +31,8 @@ public:
|
|||||||
void SetEdgeMode(int edgeMode);
|
void SetEdgeMode(int edgeMode);
|
||||||
int GetTemperatureScale();
|
int GetTemperatureScale();
|
||||||
void SetTemperatureScale(int temperatureScale);
|
void SetTemperatureScale(int temperatureScale);
|
||||||
|
int GetThreadedRendering();
|
||||||
|
void SetThreadedRendering(bool newThreadedRendering);
|
||||||
int GetGravityMode();
|
int GetGravityMode();
|
||||||
void SetGravityMode(int gravityMode);
|
void SetGravityMode(int gravityMode);
|
||||||
float GetCustomGravityX();
|
float GetCustomGravityX();
|
||||||
|
@ -318,6 +318,9 @@ OptionsView::OptionsView() : ui::Window(ui::Point(-1, -1), ui::Point(320, 340))
|
|||||||
}
|
}
|
||||||
currentY += 4; // and then undo the undo
|
currentY += 4; // and then undo the undo
|
||||||
}
|
}
|
||||||
|
threadedRendering = addCheckbox(0, "Separate rendering thread", "May increase framerate when fancy effects are in use", [this] {
|
||||||
|
c->SetThreadedRendering(threadedRendering->GetChecked());
|
||||||
|
});
|
||||||
decoSpace = addDropDown("Colour space used by decoration tools", {
|
decoSpace = addDropDown("Colour space used by decoration tools", {
|
||||||
{ "sRGB", DECOSPACE_SRGB },
|
{ "sRGB", DECOSPACE_SRGB },
|
||||||
{ "Linear", DECOSPACE_LINEAR },
|
{ "Linear", DECOSPACE_LINEAR },
|
||||||
@ -490,6 +493,7 @@ void OptionsView::NotifySettingsChanged(OptionsModel * sender)
|
|||||||
includePressure->SetChecked(sender->GetIncludePressure());
|
includePressure->SetChecked(sender->GetIncludePressure());
|
||||||
perfectCircle->SetChecked(sender->GetPerfectCircle());
|
perfectCircle->SetChecked(sender->GetPerfectCircle());
|
||||||
graveExitsConsole->SetChecked(sender->GetGraveExitsConsole());
|
graveExitsConsole->SetChecked(sender->GetGraveExitsConsole());
|
||||||
|
threadedRendering->SetChecked(sender->GetThreadedRendering());
|
||||||
momentumScroll->SetChecked(sender->GetMomentumScroll());
|
momentumScroll->SetChecked(sender->GetMomentumScroll());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ class OptionsView: public ui::Window
|
|||||||
ui::Checkbox *perfectCircle{};
|
ui::Checkbox *perfectCircle{};
|
||||||
ui::Checkbox *graveExitsConsole{};
|
ui::Checkbox *graveExitsConsole{};
|
||||||
ui::Checkbox *nativeClipoard{};
|
ui::Checkbox *nativeClipoard{};
|
||||||
|
ui::Checkbox *threadedRendering{};
|
||||||
ui::ScrollPanel *scrollPanel{};
|
ui::ScrollPanel *scrollPanel{};
|
||||||
float customGravityX, customGravityY;
|
float customGravityX, customGravityY;
|
||||||
void UpdateAmbientAirTempPreview(float airTemp, bool isValid);
|
void UpdateAmbientAirTempPreview(float airTemp, bool isValid);
|
||||||
|
@ -216,6 +216,18 @@ static int zoomScope(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int separateThread(lua_State *L)
|
||||||
|
{
|
||||||
|
auto *lsi = GetLSI();
|
||||||
|
if (lua_gettop(L))
|
||||||
|
{
|
||||||
|
lsi->gameModel->SetThreadedRendering(lua_toboolean(L, 1));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
lua_pushboolean(L, lsi->gameModel->GetThreadedRendering());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void LuaRenderer::Open(lua_State *L)
|
void LuaRenderer::Open(lua_State *L)
|
||||||
{
|
{
|
||||||
static const luaL_Reg reg[] = {
|
static const luaL_Reg reg[] = {
|
||||||
@ -234,6 +246,7 @@ void LuaRenderer::Open(lua_State *L)
|
|||||||
LFUNC(zoomScope),
|
LFUNC(zoomScope),
|
||||||
LFUNC(fireSize),
|
LFUNC(fireSize),
|
||||||
LFUNC(useDisplayPreset),
|
LFUNC(useDisplayPreset),
|
||||||
|
LFUNC(separateThread),
|
||||||
#undef LFUNC
|
#undef LFUNC
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user