Added a command line option to rotate the application screen 180 degrees.

Also fixed a shader post-processing bug when rotating the application screen.
This commit is contained in:
Leon Styhre 2022-03-12 00:40:03 +01:00
parent 755b2c9f50
commit ac6cc41059
5 changed files with 15 additions and 5 deletions

Binary file not shown.

View file

@ -280,11 +280,17 @@ bool parseArgs(int argc, char* argv[])
}
else if (strcmp(argv[i], "--screenrotate") == 0) {
if (i >= argc - 1) {
std::cerr << "Error: No screenrotate value supplied.\n";
return false;
}
std::string rotateValue {argv[i + 1]};
if (rotateValue != "on" && rotateValue != "off" && rotateValue != "1" &&
rotateValue != "0") {
std::cerr << "Error: Invalid screenrotate value supplied.\n";
return false;
}
int rotate = atoi(argv[i + 1]);
Settings::getInstance()->setInt("ScreenRotate", rotate);
bool screenRotate {(rotateValue == "on" || rotateValue == "1") ? true : false};
Settings::getInstance()->setBool("ScreenRotate", screenRotate);
++i;
}
else if (strcmp(argv[i], "--vsync") == 0) {
@ -358,6 +364,7 @@ bool parseArgs(int argc, char* argv[])
"Options:\n"
" --display [index 1-4] Display/monitor to use\n"
" --resolution [width] [height] Application resolution\n"
" --screenrotate [1/on or 0/off] Rotate application screen 180 degrees\n"
" --vsync [1/on or 0/off] Turn VSync on or off (default is on)\n"
" --max-vram [size] Max VRAM to use (in mebibytes) before swapping\n"
" --no-splash Don't show the splash screen during startup\n"

View file

@ -33,6 +33,7 @@ namespace
"IgnoreGamelist", // --ignore-gamelist
"SplashScreen", // --no-splash
"Debug", // --debug
"ScreenRotate", // --screenrotate [1/on or 0/off]
"VSync", // --vsync [1/on or 0/off]
"ForceFull", // --force-full
"ForceKiosk", // --force-kiosk
@ -44,7 +45,6 @@ namespace
"ScreenHeight", // set via --screensize [width] [height]
"ScreenOffsetX", // Set via --screenoffset [X] [Y]
"ScreenOffsetY", // Set via --screenoffset [X] [Y]
"ScreenRotate", // --screenrotate [0-3]
// These options are not configurable from the command-line:
"DebugGrid",
@ -259,6 +259,7 @@ void Settings::setDefaults()
mBoolMap["ForceKiosk"] = {false, false};
mBoolMap["IgnoreGamelist"] = {false, false};
mBoolMap["SplashScreen"] = {true, true};
mBoolMap["ScreenRotate"] = {false, false};
mBoolMap["VSync"] = {true, true};
mIntMap["WindowWidth"] = {0, 0};
mIntMap["WindowHeight"] = {0, 0};
@ -268,7 +269,6 @@ void Settings::setDefaults()
mIntMap["ScreenHeight"] = {0, 0};
mIntMap["ScreenOffsetX"] = {0, 0};
mIntMap["ScreenOffsetY"] = {0, 0};
mIntMap["ScreenRotate"] = {0, 0};
//
// Settings that can be changed in es_settings.xml

View file

@ -142,7 +142,7 @@ namespace Renderer
screenOffsetY = Settings::getInstance()->getInt("ScreenOffsetY") ?
Settings::getInstance()->getInt("ScreenOffsetY") :
0;
screenRotated = Settings::getInstance()->getInt("ScreenRotate") == 2;
screenRotated = Settings::getInstance()->getBool("ScreenRotate");
// Prevent the application window from minimizing when switching windows (when launching
// games or when manually switching windows using the task switcher).

View file

@ -550,6 +550,9 @@ namespace Renderer
GL_CHECK_ERROR(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0));
}
if (getScreenRotated())
setMatrix(getIdentity());
GL_CHECK_ERROR(glBindFramebuffer(GL_READ_FRAMEBUFFER, 0));
}