When, on Windows, the application tries to automatically switch to MESA OpenGL library and the system opengl32.dll is not unloaded, prompt the user with a dialog asking to rerun using the --sw-renderer option
This commit is contained in:
parent
f8ec5fc9e7
commit
6047eec609
1 changed files with 32 additions and 17 deletions
|
@ -66,16 +66,25 @@ public:
|
||||||
return this->success;
|
return this->success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unload_opengl_dll()
|
bool unload_opengl_dll()
|
||||||
{
|
{
|
||||||
if (this->hOpenGL) {
|
if (this->hOpenGL != nullptr) {
|
||||||
BOOL released = FreeLibrary(this->hOpenGL);
|
if (::FreeLibrary(this->hOpenGL) != FALSE) {
|
||||||
if (released)
|
if (::GetModuleHandle(L"opengl32.dll") == nullptr) {
|
||||||
printf("System OpenGL library released\n");
|
printf("System OpenGL library successfully released\n");
|
||||||
|
this->hOpenGL = nullptr;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("System OpenGL library released but not removed\n");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
printf("System OpenGL library NOT released\n");
|
printf("System OpenGL library NOT released\n");
|
||||||
this->hOpenGL = nullptr;
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const
|
bool is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const
|
||||||
|
@ -270,20 +279,26 @@ int wmain(int argc, wchar_t **argv)
|
||||||
// https://wiki.qt.io/Cross_compiling_Mesa_for_Windows
|
// https://wiki.qt.io/Cross_compiling_Mesa_for_Windows
|
||||||
// http://download.qt.io/development_releases/prebuilt/llvmpipe/windows/
|
// http://download.qt.io/development_releases/prebuilt/llvmpipe/windows/
|
||||||
if (load_mesa) {
|
if (load_mesa) {
|
||||||
opengl_version_check.unload_opengl_dll();
|
bool res = opengl_version_check.unload_opengl_dll();
|
||||||
wchar_t path_to_mesa[MAX_PATH + 1] = { 0 };
|
if (!res) {
|
||||||
wcscpy(path_to_mesa, path_to_exe);
|
MessageBox(nullptr, L"PrusaSlicer was unable to automatically switch to MESA OpenGL library\nPlease, try to run the application using the '--sw-renderer' option.\n",
|
||||||
wcscat(path_to_mesa, L"mesa\\opengl32.dll");
|
L"PrusaSlicer Warning", MB_OK);
|
||||||
printf("Loading MESA OpenGL library: %S\n", path_to_mesa);
|
return -1;
|
||||||
HINSTANCE hInstance_OpenGL = LoadLibraryExW(path_to_mesa, nullptr, 0);
|
}
|
||||||
if (hInstance_OpenGL == nullptr) {
|
else {
|
||||||
printf("MESA OpenGL library was not loaded\n");
|
wchar_t path_to_mesa[MAX_PATH + 1] = { 0 };
|
||||||
} else
|
wcscpy(path_to_mesa, path_to_exe);
|
||||||
printf("MESA OpenGL library was loaded sucessfully\n");
|
wcscat(path_to_mesa, L"mesa\\opengl32.dll");
|
||||||
|
printf("Loading MESA OpenGL library: %S\n", path_to_mesa);
|
||||||
|
HINSTANCE hInstance_OpenGL = LoadLibraryExW(path_to_mesa, nullptr, 0);
|
||||||
|
if (hInstance_OpenGL == nullptr)
|
||||||
|
printf("MESA OpenGL library was not loaded\n");
|
||||||
|
else
|
||||||
|
printf("MESA OpenGL library was loaded sucessfully\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* SLIC3R_GUI */
|
#endif /* SLIC3R_GUI */
|
||||||
|
|
||||||
|
|
||||||
wchar_t path_to_slic3r[MAX_PATH + 1] = { 0 };
|
wchar_t path_to_slic3r[MAX_PATH + 1] = { 0 };
|
||||||
wcscpy(path_to_slic3r, path_to_exe);
|
wcscpy(path_to_slic3r, path_to_exe);
|
||||||
wcscat(path_to_slic3r, L"PrusaSlicer.dll");
|
wcscat(path_to_slic3r, L"PrusaSlicer.dll");
|
||||||
|
|
Loading…
Reference in a new issue