Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StdGL: Move gamma calculation to shaders if shaders are enabled #93

Merged
merged 17 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/C4Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ void C4ConfigGraphics::CompileFunc(StdCompiler *pComp)
#endif

pComp->Value(mkNamingAdapt(ShowFolderMaps, "ShowFolderMaps", true));
pComp->Value(mkNamingAdapt(UseShaderGamma, "UseShaderGamma", true));
}

void C4ConfigSound::CompileFunc(StdCompiler *pComp)
Expand Down
1 change: 1 addition & 0 deletions src/C4Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class C4ConfigGraphics
int PositionY;
#endif
bool ShowFolderMaps; // if true, folder maps are shown
bool UseShaderGamma; // whether to use shader-based gamma correction

void CompileFunc(StdCompiler *pComp);
};
Expand Down
2 changes: 1 addition & 1 deletion src/C4Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,7 @@ bool C4Game::SaveGameTitle(C4Group &hGroup)
0.0f, 0.0f, float(Application.DDraw->lpBack->Wdt), float(Application.DDraw->lpBack->Hgt),
surface.get(), 0, 0, surfaceWidth, surfaceHeight);

if (!surface->SavePNG(Config.AtTempPath(C4CFN_TempTitle), false, true, false))
if (!surface->SavePNG(Config.AtTempPath(C4CFN_TempTitle), false, !Config.Graphics.Shader, false))
{
return false;
}
Expand Down
7 changes: 5 additions & 2 deletions src/C4GraphicsSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,10 @@ bool C4GraphicsSystem::DoSaveScreenshot(bool fSaveAll, const char *szFilename)
// transfer each pixel - slooow...
for (int32_t iY2 = 0; iY2 < bkHgt2; ++iY2)
for (int32_t iX2 = 0; iX2 < bkWdt2; ++iX2)
bmp.SetPixel24(iRealX + iX2, iRealY + iY2, Application.DDraw->ApplyGammaTo(Application.DDraw->lpBack->GetPixDw(iX2, iY2, false, scale)));
{
const std::uint32_t pixel{Application.DDraw->lpBack->GetPixDw(iX2, iY2, false, scale)};
bmp.SetPixel24(iRealX + iX2, iRealY + iY2, Config.Graphics.Shader ? pixel : Application.DDraw->ApplyGammaTo(pixel));
}
// done; unlock
Application.DDraw->lpBack->Unlock();
}
Expand All @@ -597,7 +600,7 @@ bool C4GraphicsSystem::DoSaveScreenshot(bool fSaveAll, const char *szFilename)
return true;
}
// Save primary surface
return Application.DDraw->lpBack->SavePNG(szFilename, false, true, false, scale);
return Application.DDraw->lpBack->SavePNG(szFilename, false, !Config.Graphics.Shader, false, scale);
}

void C4GraphicsSystem::DeactivateDebugOutput()
Expand Down
1 change: 1 addition & 0 deletions src/StdDDraw2.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ class CStdShaderProgram
bool AddShader(CStdShader *shader);

virtual void Link() = 0;
virtual void Validate() = 0;
void Select();
static void Deselect();
virtual void Clear();
Expand Down
Loading
Loading