Attempt to add support for force-loading libraries for mesa

This commit is contained in:
JFronny 2021-11-11 17:59:35 +01:00
parent 56a16f5ee1
commit 8cfae1564c
No known key found for this signature in database
GPG Key ID: BEC5ACBBD4EE17E5
7 changed files with 49 additions and 13 deletions

View File

@ -4,6 +4,31 @@ A FOSS Launcher for Minecraft written in Java
Inceptum is a WIP minecraft launcher\
Since it is very bare-bones currently, I would not recommend using it
# Downloads
You can download builds for [Windows](https://gitlab.com/JFronny/inceptum/-/jobs/artifacts/master/raw/wrapper.exe?job=build_test) and a [Cross-Platform Jar](https://gitlab.com/JFronny/inceptum/-/jobs/artifacts/master/raw/wrapper.jar?job=build_test) \
The windows build uses FabricInstallers code to automatically launch using the java install of the minecraft launcher if present.\
# Installation
On most modern systems, simply launching the wrapper and waiting for it to download the latest Inceptum version will be enough.\
It will be placed in your config directory (~/.config/Inceptum, %APPDATA%\Inceptum or ~/Library/Application Support/Inceptum).\
On some older systems without OpenGL drivers, Inceptum won't run by default. For these, look at the next section
# Using Mesa
THIS METHOD WILL ONLY WORK ON WINDOWS! If you use linux, just install Mesa from your package manager\
Steps:
- Download a Mesa build from [here](https://github.com/pal1000/mesa-dist-win/releases/latest) (choose release-msvc.7z)
- Unpack the following files into your Inceptum directory as follows:
- x64\dxil.dll to natives\forceload\dxil.dll
- x64\libglapi.dll to natives\forceload\libglapi.dll
- x64\opengl32.dll to natives\forceload\opengl32.dll
- Launch Inceptum as normal
# Using a portable JVM
- Download an [Adoptium JVM build](https://api.adoptium.net/v3/binary/latest/17/ga/windows/x64/jdk/hotspot/normal/eclipse?project=jdk)
- Extract the directory inside the zip file into your wrappers directory
- Create a batch script (launch.bat) with the following content, adjust the JVM path if necessary: `.\jdk-17.0.1+12\bin\java -jar latest-windows.jar`
- Launch the batch script instead of the jar
## Licenses
Inceptum utilizes code/libraries/assets from:
- [ATLauncher](https://github.com/ATLauncher/ATLauncher): Microsoft authentication

View File

@ -44,7 +44,7 @@ if (flavor == 'custom') {
}
dependencies {
implementation 'com.google.code.gson:gson:2.8.8'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'org.slf4j:slf4j-api:1.7.32'
implementation 'ch.qos.logback:logback-classic:1.2.6'
implementation 'net.freeutils:jlhttp:2.6'

View File

@ -20,7 +20,6 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Set;
@ -83,6 +82,14 @@ public class Inceptum {
if (!Files.exists(INSTANCE_DIR)) Files.createDirectories(INSTANCE_DIR);
if (!Files.exists(ASSETS_DIR)) Files.createDirectories(ASSETS_DIR);
if (!Files.exists(LIBRARIES_DIR)) Files.createDirectories(LIBRARIES_DIR);
if (Files.exists(NATIVES_DIR.resolve("forceload"))) {
Inceptum.LOGGER.info("Force-Loading libraries:");
Utils.ls(NATIVES_DIR.resolve("forceload"), path -> {
//TODO provide a way to inject mesa into minecraft
Inceptum.LOGGER.info("Loading " + path);
System.load(path.toString());
});
}
cmd.invoke(arg);
}

View File

@ -7,7 +7,6 @@ import imgui.gl3.ImGuiImplGl3;
import imgui.glfw.ImGuiImplGlfw;
import io.gitlab.jfronny.inceptum.model.inceptum.CommandArguments;
import io.gitlab.jfronny.inceptum.util.api.account.AccountManager;
import io.gitlab.jfronny.inceptum.windows.MainWindow;
import io.gitlab.jfronny.inceptum.windows.Window;
import org.lwjgl.glfw.Callbacks;
import org.lwjgl.glfw.GLFW;
@ -38,10 +37,10 @@ public class InceptumGui {
public static void main(CommandArguments args, Runnable exec) {
AccountManager.loadAccounts();
Inceptum.LOGGER.info("Initializing UI");
InceptumGui.init();
init();
exec.run();
InceptumGui.run();
InceptumGui.dispose();
run();
dispose();
}
public static void open(Window window) {

View File

@ -110,11 +110,9 @@ public class HttpUtils {
throw new IOException("Could not send request", e);
}
if (res.statusCode() == 200) return res.body();
if (res.statusCode() == 302 && url.startsWith("https://edge.forgecdn.net/") && method == Method.GET) {
Optional<String> location = res.headers().firstValue("location");
if (location.isPresent()) {
return HttpUtils.get(location.get())._send(accept, responseBodyHandler);
}
Optional<String> location = res.headers().firstValue("location");
if (location.isPresent() && (res.statusCode() == 302 || res.statusCode() == 307) && method == Method.GET) {
return HttpUtils.get(location.get())._send(accept, responseBodyHandler);
}
throw new IOException("Unexpected return method: " + res.statusCode() + " (URL=" + url + ")\n" + res.body());
}

View File

@ -0,0 +1,5 @@
package io.gitlab.jfronny.inceptum.util;
public interface ThrowingFunction<TIn, TOut, TEx extends Throwable> {
TOut apply(TIn var) throws TEx;
}

View File

@ -8,6 +8,7 @@ import io.gitlab.jfronny.inceptum.model.inceptum.InceptumVersion;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
public class MetaHolder {
@ -21,9 +22,10 @@ public class MetaHolder {
.registerTypeAdapter(ComparableVersion.class, new ComparableVersionAdapter())
.create()
.fromJson(isr, InceptumVersion.class);
BASE_PATH = VERSION.isPublic
Path runDir = getDir().resolve("run");
BASE_PATH = VERSION.isPublic && !Files.exists(runDir)
? getConfigPath().resolve("Inceptum")
: getDir().resolve("run");
: runDir;
} catch (IOException e) {
throw new RuntimeException("Could not get version info", e);
}