diff --git a/source-code/source/plugins/Launcher/dllmain.cpp b/source-code/source/plugins/Launcher/dllmain.cpp index 155d49d..60bd1e1 100644 --- a/source-code/source/plugins/Launcher/dllmain.cpp +++ b/source-code/source/plugins/Launcher/dllmain.cpp @@ -9,13 +9,6 @@ using namespace System::Windows::Forms; [STAThread] int showUI() { SetProcessDPIAware(); - - // trick Optimus into switching to the NVIDIA GPU - HMODULE nvcudaModule = LoadLibraryW(L"nvcuda.dll"); - // cuInit actually returns a CUresult, but we don't really care about it - void(WINAPI * cuInit)(unsigned int flags) = (void(WINAPI*)(unsigned int flags))GetProcAddress(nvcudaModule, "cuInit"); - if (cuInit != NULL) cuInit(0); - Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); Application::Run(gcnew Launcher::ui()); diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index f2a38c7..a3999df 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -257,4 +257,14 @@ void PrependFile(LPCSTR newStr, LPCWSTR fileName) fileStream.seekg(0, std::ios::beg); fileStream << outStr; fileStream.close(); -} \ No newline at end of file +} + + +// used to trick Optimus into switching to the NVIDIA GPU +HMODULE nvcudaModule = LoadLibraryW(L"nvcuda.dll"); +// cuInit actually returns a CUresult, but we don't really care about it +void(WINAPI * cuInit)(unsigned int flags) = (void(WINAPI*)(unsigned int flags))GetProcAddress(nvcudaModule, "cuInit"); + +// needed to close the OpenGL window (freeglut only) +HMODULE glutModule = LoadLibraryW(L"glut32.dll"); +void(__stdcall * glutMainLoopEventDynamic)() = (void(__stdcall*)())GetProcAddress(glutModule, "glutMainLoopEventDynamic"); \ No newline at end of file diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index b3f2537..4cdf656 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -112,18 +112,27 @@ namespace Launcher { this->panel_Components->ResumeLayout(false); this->panel_Components->PerformLayout(); + + + // trick Optimus into switching to the NVIDIA GPU + if (cuInit != NULL) cuInit(0); + int argc = 1; char* argv[1] = { (char*)"" }; + glutInit(&argc, argv); - int window = glutCreateWindow("glut"); + int window = glutCreateWindow("glut"); // a context must be created to use glGetString + String^ vendor = gcnew String((char*)glGetString(GL_VENDOR)); String^ renderer = gcnew String((char*)glGetString(GL_RENDERER)); String^ version = gcnew String((char*)glGetString(GL_VERSION)); - glutDestroyWindow(window); - glutMainLoopEvent(); + + glutDestroyWindow(window); // destroy the window so it doesn't remain on screen + if (glutMainLoopEventDynamic != NULL) glutMainLoopEventDynamic(); // freeglut needs this + this->labelGPU->Text = "Vendor: " + vendor + "\nRenderer: " + renderer + "\nOpenGL: " + version; - if (vendor != "NVIDIA Corporation") SkinnedMessageBox::Show(this, "Your graphics card is not supported! Only NVIDIA GPUs are currently supported.", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Warning); - else if ((int)(version[0]) - 48 < 3) SkinnedMessageBox::Show(this, "Your GPU is too old. The game might not render PVs correctly!", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Warning); + if (!vendor->Contains("NVIDIA")) SkinnedMessageBox::Show(this, "Your graphics card is not supported! Only NVIDIA GPUs are currently supported.", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Warning); + else if (version[0] < '3') SkinnedMessageBox::Show(this, "Your GPU is too old. The game might not render PVs correctly!", "PD Launcher", MessageBoxButtons::OK, MessageBoxIcon::Warning); } protected: @@ -474,15 +483,6 @@ private: System::Void InternalResEnabledChangedHandler(System::Object^ sender, S private: System::Void DisplayTypeChangedHandler(System::Object^ sender, System::EventArgs^ e) { int idx = ((ComboBox^)ComboBox::FromHandle(DisplayModeDropdown->mainControlHandle))->SelectedIndex; - if (idx == 0 || idx == 2) // windowed or fullscreen - { - ((Control^)Control::FromHandle(DisplayResolutionOption->mainControlHandle))->Enabled = true; - } - else - { - ((Control^)Control::FromHandle(DisplayResolutionOption->mainControlHandle))->Enabled = false; - } - if (idx == 2) // fullscreen { for (ConfigOptionBase* option : screenResolutionArray)