Skip to content

Commit

Permalink
Fix[RendererPlugin]: fix Mesa lib not work
Browse files Browse the repository at this point in the history
  • Loading branch information
ShirosakiMio committed Nov 21, 2024
1 parent 101100a commit 91f695d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
18 changes: 15 additions & 3 deletions FCLauncher/src/main/java/com/tungsten/fclauncher/FCLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,21 @@ private static void addRendererEnv(FCLConfig config, HashMap<String, String> env
envMap.put("LIBEGL_NAME", RendererPlugin.getSelected().getEglName());
RendererPlugin.getSelected().getBoatEnv().forEach(env -> {
String[] split = env.split("=");
envMap.put(split[0], split[1]);
if (split[0].equals("LIB_MESA_NAME")) {
envMap.put(split[0], RendererPlugin.getSelected().getPath() + "/" + split[1]);
} else {
envMap.put(split[0], split[1]);
}
});
} else {
envMap.put("POJAVEXEC_EGL", RendererPlugin.getSelected().getEglName());
RendererPlugin.getSelected().getPojavEnv().forEach(env -> {
String[] split = env.split("=");
envMap.put(split[0], split[1]);
if (split[0].equals("LIB_MESA_NAME")) {
envMap.put(split[0], RendererPlugin.getSelected().getPath() + "/" + split[1]);
} else {
envMap.put(split[0], split[1]);
}
});
}
return;
Expand Down Expand Up @@ -315,7 +323,11 @@ private static void setupGraphicAndSoundEngine(FCLConfig config, FCLBridge bridg
String nativeDir = config.getContext().getApplicationInfo().nativeLibraryDir;

bridge.dlopen(nativeDir + "/libopenal.so");
bridge.dlopen(nativeDir + "/" + config.getRenderer().getGlLibName());
if (config.getRenderer() == FCLConfig.Renderer.RENDERER_CUSTOM) {
bridge.dlopen(RendererPlugin.getSelected().getPath() + "/" + RendererPlugin.getSelected().getGlName());
} else {
bridge.dlopen(nativeDir + "/" + config.getRenderer().getGlLibName());
}
}

private static void launch(FCLConfig config, FCLBridge bridge, String task) throws IOException {
Expand Down
6 changes: 5 additions & 1 deletion FCLauncher/src/main/jni/glfw/osmesa_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ GLFWbool _glfwInitOSMesa(void)
if (_glfw.osmesa.handle)
return GLFW_TRUE;

_glfw.osmesa.handle = _glfw_dlopen(getenv("LIBGL_NAME"));
char *lib_name = getenv("LIB_MESA_NAME");
if (!lib_name) {
lib_name = getenv("LIBGL_NAME");
}
_glfw.osmesa.handle = _glfw_dlopen(lib_name);

const char *renderer = getenv("LIBGL_STRING");

Expand Down
6 changes: 5 additions & 1 deletion FCLauncher/src/main/jni/pojav/ctxbridges/osmesa_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ bool dlsym_OSMesa() {
if (pojav_environ->config_renderer == RENDERER_VIRGL) {
dl_handle = dlopen("libOSMesa_81.so", RTLD_LOCAL | RTLD_LAZY);
} else {
dl_handle = dlopen("libOSMesa_8.so", RTLD_LOCAL | RTLD_LAZY);
char *lib_name = getenv("LIB_MESA_NAME");
if (!lib_name) {
lib_name = "libOSMesa_8.so";
}
dl_handle = dlopen(lib_name, RTLD_LOCAL | RTLD_LAZY);
}
if (dl_handle == NULL) return false;
OSMesaGetProcAddress_p = dlsym(dl_handle, "OSMesaGetProcAddress");
Expand Down

0 comments on commit 91f695d

Please sign in to comment.