Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Run a picked OpenGL program with OpenGL

Leonardo Lobato816896ddbf3d
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cpp
index 9e143e3..d473627 100644
--- a/src/homebrew/runtime_host.cpp
+++ b/src/homebrew/runtime_host.cpp
@@ -1907,6 +1907,11 @@ std::string RuntimeHost::PublishSavedSettings(Composition& c, const rt::RuntimeI
if (!setup_program.empty()) {
const auto button = [](const auto& entry) { return entry.first.rfind("button.", 0) == 0; };
run_recipe = *recipe;
+ // The recipe's graphics came from the program the game was prepared for. An OpenGL program among Direct3D ones
+ // can't draw with those, unless the player chose them or the recipe requires them.
+ if (!saved.overrides.count("graphics") && !recipe->locked.count("graphics") &&
+ rt::ProgramDrawsWithOpenGLOnly(HostPath(record.install_path).string(), setup_program))
+ run_recipe->graphics = "opengl";
std::erase_if(run_recipe->defaults, button);
std::erase_if(run_recipe->locked, [](const std::string& id) {
static const std::set<std::string> controls = {"launch_option", "program", "controller_preset", "controller",
diff --git a/src/runtime/game_probe.cpp b/src/runtime/game_probe.cpp
index 0881b59..a3f2ebb 100644
--- a/src/runtime/game_probe.cpp
+++ b/src/runtime/game_probe.cpp
@@ -425,6 +425,14 @@ std::string UnrealGameProgram(const std::string& install_root, const std::string
return FindShipping(root, folder, LowerStem(lower_file));
}
+bool ProgramDrawsWithOpenGLOnly(const std::string& install_root, const std::string& executable) {
+ const auto facts = ReadPe((fs::path(install_root) / executable).string());
+ if (!facts.valid) return false;
+ std::set<std::string> apis;
+ AddImports(facts, &apis);
+ return apis == std::set<std::string>{"opengl"};
+}
+
GameProbe ProbeGame(const std::string& install_root, const std::string& executable) {
GameProbe probe;
const fs::path root(install_root);
diff --git a/src/runtime/game_probe.h b/src/runtime/game_probe.h
index 9edc5a7..54f6819 100644
--- a/src/runtime/game_probe.h
+++ b/src/runtime/game_probe.h
@@ -39,6 +39,10 @@ inline constexpr unsigned long long kProbeScanBytes = 256ull * 1024ull * 1024ull
// executable is relative to install_root with '/' separators, as spelled on disk.
GameProbe ProbeGame(const std::string& install_root, const std::string& executable);
+// Whether a program itself draws with OpenGL and nothing else: of the graphics libraries, it imports only OpenGL's.
+// Unlike GameProbe::apis, the libraries beside it don't count, so a launcher next to the game's DLLs is not one.
+bool ProgramDrawsWithOpenGLOnly(const std::string& install_root, const std::string& executable);
+
// The program that starts an Unreal game when executable (relative to install_root, '/' separators) is its root
// launcher, which only starts that one as a child process, which the console cannot do; relative to install_root,
// as spelled on disk. Empty for any other program. GameProbe::unreal_program, without reading the programs.
diff --git a/tests/game_probe_test.cpp b/tests/game_probe_test.cpp
index 20f2fda..a916584 100644
--- a/tests/game_probe_test.cpp
+++ b/tests/game_probe_test.cpp
@@ -775,6 +775,18 @@ int main() {
CHECK(!found.truncated);
}
+ { // A program's own imports decide, not the libraries beside it: Hotline Miami's launcher sits next to cgGL.dll.
+ const auto root = fresh();
+ WritePe(root / "GL.exe", {false, {"KERNEL32.dll", "OPENGL32.dll"}});
+ WritePe(root / "Both.exe", {false, {"OPENGL32.dll", "d3d9.dll"}});
+ WritePe(root / "Launcher.exe", {false, {"KERNEL32.dll"}});
+ WritePe(root / "cgGL.dll", {false, {"OPENGL32.dll"}});
+ CHECK(ProgramDrawsWithOpenGLOnly(root.string(), "GL.exe"));
+ CHECK(!ProgramDrawsWithOpenGLOnly(root.string(), "Both.exe"));
+ CHECK(!ProgramDrawsWithOpenGLOnly(root.string(), "Launcher.exe"));
+ CHECK(!ProgramDrawsWithOpenGLOnly(root.string(), "Missing.exe"));
+ }
+
// The player's words for what was found.
CHECK(DetectedLabel("unity-il2cpp,d3d11,d3d12 graphics=dxvk") == "Unity \xC2\xB7 Direct3D 11");
CHECK(DetectedLabel("d3d9 graphics=dxvk") == "Direct3D 9");