@@ -1036,7 +1036,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta
1036
1036
// Convenience subset of what
1037
1037
// "Enable standard shortcut keys"
1038
1038
// does on Windows.
1039
- if (g_Config.bSystemControls ) {
1039
+ if (g_Config.bSystemControls ) {
1040
1040
bool ctrl = bool (event.key .keysym .mod & KMOD_CTRL);
1041
1041
if (ctrl && (k == SDLK_w))
1042
1042
{
@@ -1410,6 +1410,14 @@ int main(int argc, char *argv[]) {
1410
1410
int remain_argc = 1 ;
1411
1411
const char *remain_argv[256 ] = { argv[0 ] };
1412
1412
1413
+ // Option to force a specific OpenGL version (42="4.2",
1414
+ // etc.; -1 means "try them all").
1415
+ // Implemented as a workaround for https://github.com/hrydgard/ppsspp/issues/20687
1416
+ // NOTE: this is currently not persistent (doesn't
1417
+ // go to config), even though --graphics=openglX.Y
1418
+ // also sets the GPU backend which does persist.
1419
+ int force_gl_version = -1 ;
1420
+
1413
1421
Uint32 mode = 0 ;
1414
1422
for (int i = 1 ; i < argc; i++) {
1415
1423
if (!strcmp (argv[i]," --fullscreen" )) {
@@ -1435,7 +1443,27 @@ int main(int argc, char *argv[]) {
1435
1443
set_ipad = true ;
1436
1444
else if (!strcmp (argv[i]," --portrait" ))
1437
1445
portrait = true ;
1438
- else {
1446
+ else if (!strncmp (argv[i]," --graphics=" , strlen (" --graphics=" ))) {
1447
+ const char *restOfOption = argv[i] + strlen (" --graphics=" );
1448
+ double val=-1.0 ; // Yes, floating point.
1449
+ if (!strcmp (restOfOption, " vulkan" )) {
1450
+ g_Config.iGPUBackend = (int )GPUBackend::VULKAN;
1451
+ g_Config.bSoftwareRendering = false ;
1452
+ } else if (!strcmp (restOfOption, " software" )) {
1453
+ // Same as on Windows, software presently implies OpenGL.
1454
+ g_Config.iGPUBackend = (int )GPUBackend::OPENGL;
1455
+ g_Config.bSoftwareRendering = true ;
1456
+ } else if (!strcmp (restOfOption, " gles" ) || !strcmp (restOfOption, " opengl" )) {
1457
+ // NOTE: OpenGL and GLES are treated the same for
1458
+ // the purposes of option parsing.
1459
+ g_Config.iGPUBackend = (int )GPUBackend::OPENGL;
1460
+ g_Config.bSoftwareRendering = false ;
1461
+ } else if (sscanf (restOfOption, " gles%lg" , &val) == 1 || sscanf (restOfOption, " opengl%lg" , &val) == 1 ) {
1462
+ g_Config.iGPUBackend = (int )GPUBackend::OPENGL;
1463
+ g_Config.bSoftwareRendering = false ;
1464
+ force_gl_version = int (10.0 * val + 0.5 );
1465
+ }
1466
+ } else {
1439
1467
remain_argv[remain_argc++] = argv[i];
1440
1468
}
1441
1469
}
@@ -1592,7 +1620,7 @@ int main(int argc, char *argv[]) {
1592
1620
std::string error_message;
1593
1621
if (g_Config.iGPUBackend == (int )GPUBackend::OPENGL) {
1594
1622
SDLGLGraphicsContext *glctx = new SDLGLGraphicsContext ();
1595
- if (glctx->Init (window, x, y, w, h, mode, &error_message) != 0 ) {
1623
+ if (glctx->Init (window, x, y, w, h, mode, &error_message, force_gl_version ) != 0 ) {
1596
1624
// Let's try the fallback once per process run.
1597
1625
printf (" GL init error '%s' - falling back to Vulkan\n " , error_message.c_str ());
1598
1626
g_Config.iGPUBackend = (int )GPUBackend::VULKAN;
@@ -1622,7 +1650,7 @@ int main(int argc, char *argv[]) {
1622
1650
1623
1651
// NOTE : This should match the three lines above in the OpenGL case.
1624
1652
SDLGLGraphicsContext *glctx = new SDLGLGraphicsContext ();
1625
- if (glctx->Init (window, x, y, w, h, mode, &error_message) != 0 ) {
1653
+ if (glctx->Init (window, x, y, w, h, mode, &error_message, force_gl_version ) != 0 ) {
1626
1654
printf (" GL fallback failed: %s\n " , error_message.c_str ());
1627
1655
return 1 ;
1628
1656
}
@@ -1786,7 +1814,7 @@ int main(int argc, char *argv[]) {
1786
1814
1787
1815
if (g_Config.iGPUBackend == (int )GPUBackend::OPENGL) {
1788
1816
SDLGLGraphicsContext *ctx = (SDLGLGraphicsContext *)graphicsContext;
1789
- if (!ctx->Init (window, x, y, w, h, mode, &error_message)) {
1817
+ if (!ctx->Init (window, x, y, w, h, mode, &error_message, force_gl_version )) {
1790
1818
printf (" Failed to reinit graphics.\n " );
1791
1819
}
1792
1820
}
0 commit comments