Skip to content

Commit c5b1170

Browse files
committed
feat: use platform OpenGL if running on Wine
The Direct3D11 backend of ANGLE seems to have some trouble with the stock Wine runtime where textures can fade into black like the big class/ascendancy art in the middle of the tree at particular zoom levels and also for error dialog boxes. This can be mitigated by using the DXVK runtime with a Vulkan driver. A cleaner more in-box workaround is to use the Desktop OpenGL backend of ANGLE if we detect that the Windows version of SimpleGraphic runs on top of Wine.
1 parent 886159d commit c5b1170

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

engine/system/win/sys_video.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@ void sys_IVideo::FreeHandle(sys_IVideo* hnd)
9898
delete (sys_video_c*)hnd;
9999
}
100100

101+
102+
using WineGetVersionFun = const char* ();
103+
static bool RunningOnWine()
104+
{
105+
#ifdef _WIN32
106+
HMODULE mod = GetModuleHandleA("ntdll.dll");
107+
if (!mod)
108+
return false;
109+
auto ptr = GetProcAddress(mod, "wine_get_version");
110+
return !!ptr;
111+
#endif
112+
return false;
113+
}
114+
101115
sys_video_c::sys_video_c(sys_IMain* sysHnd)
102116
: sys((sys_main_c*)sysHnd)
103117
{
@@ -107,7 +121,10 @@ sys_video_c::sys_video_c(sys_IMain* sysHnd)
107121

108122
strcpy(curTitle, CFG_TITLE);
109123

110-
glfwInitHint(GLFW_ANGLE_PLATFORM_TYPE, GLFW_ANGLE_PLATFORM_TYPE_D3D11);
124+
const int platformType = RunningOnWine()
125+
? GLFW_ANGLE_PLATFORM_TYPE_OPENGL
126+
: GLFW_ANGLE_PLATFORM_TYPE_D3D11;
127+
glfwInitHint(GLFW_ANGLE_PLATFORM_TYPE, platformType);
111128
glfwInit();
112129
}
113130

0 commit comments

Comments
 (0)