[Backend switcher] Fix the crash

This commit is contained in:
Duy Tran Khanh 2021-03-06 15:46:53 +07:00
parent ede68c6d0c
commit 032c06c364
4 changed files with 14 additions and 4 deletions

View File

@ -6,7 +6,7 @@ import net.kdt.pojavlaunch.*;
public class LauncherPreferences public class LauncherPreferences
{ {
public static SharedPreferences DEFAULT_PREF; public static SharedPreferences DEFAULT_PREF;
public static String PREF_RENDERER = "2"; public static String PREF_RENDERER = "opengles2";
public static boolean PREF_VERTYPE_RELEASE = true; public static boolean PREF_VERTYPE_RELEASE = true;
public static boolean PREF_VERTYPE_SNAPSHOT = false; public static boolean PREF_VERTYPE_SNAPSHOT = false;
public static boolean PREF_VERTYPE_OLDALPHA = false; public static boolean PREF_VERTYPE_OLDALPHA = false;
@ -29,7 +29,7 @@ public class LauncherPreferences
public static boolean PREF_DISABLE_GESTURES = false; public static boolean PREF_DISABLE_GESTURES = false;
public static float PREF_MOUSESPEED = 1f; public static float PREF_MOUSESPEED = 1f;
public static void loadPreferences() { public static void loadPreferences() {
PREF_RENDERER = DEFAULT_PREF.getString("renderer", "2"); PREF_RENDERER = DEFAULT_PREF.getString("renderer", "opengles2");
PREF_BUTTONSIZE = DEFAULT_PREF.getInt("buttonscale", 100); PREF_BUTTONSIZE = DEFAULT_PREF.getInt("buttonscale", 100);
PREF_MOUSESCALE = DEFAULT_PREF.getInt("mousescale", 100); PREF_MOUSESCALE = DEFAULT_PREF.getInt("mousescale", 100);
PREF_MOUSESPEED = ((float)DEFAULT_PREF.getInt("mousespeed",100))/100f; PREF_MOUSESPEED = ((float)DEFAULT_PREF.getInt("mousespeed",100))/100f;

View File

@ -252,8 +252,12 @@ public class JREUtils
if (glesMajor < 3) { if (glesMajor < 3) {
//fallback to 2 since it's the minimum for the entire app //fallback to 2 since it's the minimum for the entire app
envMap.put("LIBGL_ES","2"); envMap.put("LIBGL_ES","2");
} else if (LauncherPreferences.PREF_RENDERER.startsWith("opengles")) {
envMap.put("LIBGL_ES", LauncherPreferences.PREF_RENDERER.replace("opengles", ""));
} else { } else {
envMap.put("LIBGL_ES", LauncherPreferences.PREF_RENDERER); // TODO if can: other backends such as Vulkan.
// Sure, they should provide GLES 3 support.
envMap.put("LIBGL_ES", "3");
} }
} }
for (Map.Entry<String, String> env : envMap.entrySet()) { for (Map.Entry<String, String> env : envMap.entrySet()) {

View File

@ -11,4 +11,9 @@
<item name="2">@string/mcl_setting_renderer_gles2</item> <item name="2">@string/mcl_setting_renderer_gles2</item>
<item name="3">@string/mcl_setting_renderer_gles3</item> <item name="3">@string/mcl_setting_renderer_gles3</item>
</string-array> </string-array>
<string-array name="renderer_values">
<item>opengles2</item>
<item>opengles3</item>
</string-array>
</resources> </resources>

View File

@ -15,7 +15,8 @@
android:title="@string/mcl_setting_category_renderer" android:title="@string/mcl_setting_category_renderer"
android:key="renderer" android:key="renderer"
android:defaultValue="2" android:defaultValue="2"
android:entries="@array/renderer" /> android:entries="@array/renderer"
android:entryValues="renderer_values"/>
<net.kdt.pojavlaunch.prefs.CustomSeekBarPreference <net.kdt.pojavlaunch.prefs.CustomSeekBarPreference
android:key="timeLongPressTrigger" android:key="timeLongPressTrigger"