diff options
Diffstat (limited to 'platform/x11/os_x11.cpp')
-rw-r--r-- | platform/x11/os_x11.cpp | 77 |
1 files changed, 63 insertions, 14 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index e4a72e0715..a62bd714d2 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -274,21 +274,70 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a opengl_api_type = ContextGL_X11::GLES_2_0_COMPATIBLE; } - context_gl = memnew(ContextGL_X11(x11_display, x11_window, current_videomode, opengl_api_type)); - context_gl->initialize(); + bool editor = Engine::get_singleton()->is_editor_hint(); + bool gl_initialization_error = false; - switch (opengl_api_type) { - case ContextGL_X11::GLES_2_0_COMPATIBLE: { - RasterizerGLES2::register_config(); - RasterizerGLES2::make_current(); - } break; - case ContextGL_X11::GLES_3_0_COMPATIBLE: { - RasterizerGLES3::register_config(); - RasterizerGLES3::make_current(); - } break; + context_gl = NULL; + while (!context_gl) { + context_gl = memnew(ContextGL_X11(x11_display, x11_window, current_videomode, opengl_api_type)); + + if (context_gl->initialize() != OK) { + memdelete(context_gl); + context_gl = NULL; + + if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) { + if (p_video_driver == VIDEO_DRIVER_GLES2) { + gl_initialization_error = true; + break; + } + + p_video_driver = VIDEO_DRIVER_GLES2; + opengl_api_type = ContextGL_X11::GLES_2_0_COMPATIBLE; + } else { + gl_initialization_error = true; + break; + } + } + } + + while (true) { + if (opengl_api_type == ContextGL_X11::GLES_3_0_COMPATIBLE) { + 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; + opengl_api_type = ContextGL_X11::GLES_2_0_COMPATIBLE; + continue; + } else { + gl_initialization_error = true; + break; + } + } + } + + if (opengl_api_type == ContextGL_X11::GLES_2_0_COMPATIBLE) { + 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; // FIXME TODO - FIX IF DRIVER DETECTION HAPPENS AND GLES2 MUST BE USED + video_driver_index = p_video_driver; context_gl->set_use_vsync(current_videomode.use_vsync); @@ -339,8 +388,6 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a set_window_always_on_top(true); } - AudioDriverManager::initialize(p_audio_driver); - ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE); ERR_FAIL_COND_V(x11_window == 0, ERR_UNAVAILABLE); @@ -510,6 +557,8 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a visual_server->init(); + AudioDriverManager::initialize(p_audio_driver); + input = memnew(InputDefault); window_has_focus = true; // Set focus to true at init |