diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-08-27 16:54:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-27 16:54:22 +0200 |
commit | c1f687c6818883f70c2b7f85577c51ed5ad65c08 (patch) | |
tree | 68bf6b19674bd54ab6662a12cfd6aee37a4a4d83 /platform/android | |
parent | 78bb53f85d97d3a5b66d9005732c3c07c1f0e636 (diff) | |
parent | 08f452d1a95d7f171472c33a60983d95adf1665d (diff) |
Merge pull request #21387 from hpvb/fix-15324
Fall back to GLES2 if GLES3 is not working
Diffstat (limited to 'platform/android')
-rw-r--r-- | platform/android/os_android.cpp | 64 |
1 files changed, 50 insertions, 14 deletions
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index c8bdf98923..74c40bde72 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -62,12 +62,19 @@ public: int OS_Android::get_video_driver_count() const { - return 1; + return 2; } const char *OS_Android::get_video_driver_name(int p_driver) const { - return "GLES2"; + switch (p_driver) { + case VIDEO_DRIVER_GLES3: + return "GLES3"; + case VIDEO_DRIVER_GLES2: + return "GLES2"; + } + ERR_EXPLAIN("Invalid video driver index " + itos(p_driver)); + ERR_FAIL_V(NULL); } int OS_Android::get_audio_driver_count() const { @@ -132,26 +139,55 @@ Error OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int bool use_gl3 = get_gl_version_code_func() >= 0x00030000; use_gl3 = use_gl3 && (GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES3"); - use_gl2 = !use_gl3; - - if (gfx_init_func) - gfx_init_func(gfx_init_ud, use_gl2); + bool gl_initialization_error = false; + + while (true) { + if (use_gl3) { + if (RasterizerGLES3::is_viable() == OK) { + if (gfx_init_func) + gfx_init_func(gfx_init_ud, false); + RasterizerGLES3::register_config(); + RasterizerGLES3::make_current(); + break; + } else { + if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best") { + p_video_driver = VIDEO_DRIVER_GLES2; + use_gl3 = false; + continue; + } else { + gl_initialization_error = true; + break; + } + } + } else { + if (RasterizerGLES2::is_viable() == OK) { + if (gfx_init_func) + gfx_init_func(gfx_init_ud, true); + RasterizerGLES2::register_config(); + RasterizerGLES2::make_current(); + break; + } else { + gl_initialization_error = true; + break; + } + } + } - if (use_gl2) { - RasterizerGLES2::register_config(); - RasterizerGLES2::make_current(); - video_driver_index = VIDEO_DRIVER_GLES2; - } else { - RasterizerGLES3::register_config(); - RasterizerGLES3::make_current(); - video_driver_index = VIDEO_DRIVER_GLES3; + if (gl_initialization_error) { + OS::get_singleton()->alert("Your device does not support any of the supported OpenGL versions.\n" + "Please try updating your Android version.", + "Unable to initialize Video driver"); + return ERR_UNAVAILABLE; } + video_driver_index = p_video_driver; + visual_server = memnew(VisualServerRaster); /* if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { visual_server = memnew(VisualServerWrapMT(visual_server, false)); };*/ + visual_server->init(); // visual_server->cursor_set_visible(false, 0); |