diff options
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/context_gl_win.cpp | 7 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 111 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 2 |
3 files changed, 69 insertions, 51 deletions
diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp index 59435b04ea..794f6df31f 100644 --- a/platform/windows/context_gl_win.cpp +++ b/platform/windows/context_gl_win.cpp @@ -108,28 +108,24 @@ Error ContextGL_Win::initialize() { hDC = GetDC(hWnd); if (!hDC) { - MessageBox(NULL, "Can't Create A GL Device Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return ERR_CANT_CREATE; // Return FALSE } pixel_format = ChoosePixelFormat(hDC, &pfd); if (!pixel_format) // Did Windows Find A Matching Pixel Format? { - MessageBox(NULL, "Can't Find A Suitable pixel_format.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return ERR_CANT_CREATE; // Return FALSE } BOOL ret = SetPixelFormat(hDC, pixel_format, &pfd); if (!ret) // Are We Able To Set The Pixel Format? { - MessageBox(NULL, "Can't Set The pixel_format.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return ERR_CANT_CREATE; // Return FALSE } hRC = wglCreateContext(hDC); if (!hRC) // Are We Able To Get A Rendering Context? { - MessageBox(NULL, "Can't Create A Temporary GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return ERR_CANT_CREATE; // Return FALSE } @@ -151,7 +147,6 @@ Error ContextGL_Win::initialize() { if (wglCreateContextAttribsARB == NULL) //OpenGL 3.0 is not supported { - MessageBox(NULL, "Cannot get Proc Address for CreateContextAttribs", "ERROR", MB_OK | MB_ICONEXCLAMATION); wglDeleteContext(hRC); return ERR_CANT_CREATE; } @@ -159,7 +154,6 @@ Error ContextGL_Win::initialize() { HGLRC new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs); if (!new_hRC) { wglDeleteContext(hRC); - MessageBox(NULL, "Can't Create An OpenGL 3.3 Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return ERR_CANT_CREATE; // Return false } wglMakeCurrent(hDC, NULL); @@ -168,7 +162,6 @@ Error ContextGL_Win::initialize() { if (!wglMakeCurrent(hDC, hRC)) // Try To Activate The Rendering Context { - MessageBox(NULL, "Can't Activate The GL 3.3 Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return ERR_CANT_CREATE; // Return FALSE } } diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index fa8717a4b8..7009df8e57 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -190,28 +190,6 @@ BOOL WINAPI HandlerRoutine(_In_ DWORD dwCtrlType) { } } -BOOL CALLBACK _CloseWindowsEnum(HWND hWnd, LPARAM lParam) { - DWORD dwID; - - GetWindowThreadProcessId(hWnd, &dwID); - - if (dwID == (DWORD)lParam) { - PostMessage(hWnd, WM_CLOSE, 0, 0); - } - - return TRUE; -} - -bool _close_gracefully(const PROCESS_INFORMATION &pi, const DWORD dwStopWaitMsec) { - if (!EnumWindows(_CloseWindowsEnum, pi.dwProcessId)) - return false; - - if (WaitForSingleObject(pi.hProcess, dwStopWaitMsec) != WAIT_OBJECT_0) - return false; - - return true; -} - void OS_Windows::initialize_debugging() { SetConsoleCtrlHandler(HandlerRoutine, TRUE); @@ -1273,21 +1251,74 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int } #if defined(OPENGL_ENABLED) + + bool gles3_context = true; if (p_video_driver == VIDEO_DRIVER_GLES2) { - gl_context = memnew(ContextGL_Win(hWnd, false)); - gl_context->initialize(); + gles3_context = false; + } - RasterizerGLES2::register_config(); - RasterizerGLES2::make_current(); - } else { - gl_context = memnew(ContextGL_Win(hWnd, true)); - gl_context->initialize(); + bool editor = Engine::get_singleton()->is_editor_hint(); + bool gl_initialization_error = false; + + gl_context = NULL; + while (!gl_context) { + gl_context = memnew(ContextGL_Win(hWnd, gles3_context)); + + if (gl_context->initialize() != OK) { + memdelete(gl_context); + gl_context = NULL; + + if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) { + if (p_video_driver == VIDEO_DRIVER_GLES2) { + gl_initialization_error = true; + break; + } - RasterizerGLES3::register_config(); - RasterizerGLES3::make_current(); + p_video_driver = VIDEO_DRIVER_GLES2; + gles3_context = false; + } else { + gl_initialization_error = true; + break; + } + } } - video_driver_index = p_video_driver; // FIXME TODO - FIX IF DRIVER DETECTION HAPPENS AND GLES2 MUST BE USED + while (true) { + if (gles3_context) { + if (RasterizerGLES3::is_viable() == OK) { + RasterizerGLES3::register_config(); + RasterizerGLES3::make_current(); + break; + } else { + if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) { + p_video_driver = VIDEO_DRIVER_GLES2; + gles3_context = false; + continue; + } else { + gl_initialization_error = true; + break; + } + } + } else { + if (RasterizerGLES2::is_viable() == OK) { + RasterizerGLES2::register_config(); + RasterizerGLES2::make_current(); + break; + } else { + gl_initialization_error = true; + break; + } + } + } + + if (gl_initialization_error) { + OS::get_singleton()->alert("Your video card driver does not support any of the supported OpenGL versions.\n" + "Please update your drivers or if you have a very old or integrated GPU upgrade it.", + "Unable to initialize Video driver"); + return ERR_UNAVAILABLE; + } + + video_driver_index = p_video_driver; gl_context->set_use_vsync(video_mode.use_vsync); #endif @@ -2411,26 +2442,20 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, return OK; }; -Error OS_Windows::kill(const ProcessID &p_pid, const int p_max_wait_msec) { +Error OS_Windows::kill(const ProcessID &p_pid) { + ERR_FAIL_COND_V(!process_map->has(p_pid), FAILED); const PROCESS_INFORMATION pi = (*process_map)[p_pid].pi; process_map->erase(p_pid); - Error result; - - if (p_max_wait_msec != -1 && _close_gracefully(pi, p_max_wait_msec)) { - result = OK; - } else { - const int ret = TerminateProcess(pi.hProcess, 0); - result = ret != 0 ? OK : FAILED; - } + const int ret = TerminateProcess(pi.hProcess, 0); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); - return result; -} + return ret != 0 ? OK : FAILED; +}; int OS_Windows::get_process_id() const { return _getpid(); diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 243d4bb328..c9fa46052a 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -259,7 +259,7 @@ public: virtual uint64_t get_ticks_usec() const; virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false); - virtual Error kill(const ProcessID &p_pid, const int p_stop_max_wait_msec = -1); + virtual Error kill(const ProcessID &p_pid); virtual int get_process_id() const; virtual bool has_environment(const String &p_var) const; |