Skip to content

Commit

Permalink
Add natives
Browse files Browse the repository at this point in the history
  • Loading branch information
hackermdch committed Sep 22, 2024
1 parent 781d575 commit 09c60f4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
15 changes: 9 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[submodule "animerenderer/src/main/resources/natives/saba"]
path = animerenderer/src/main/resources/natives/saba
url = https://github.com/PrimogemStudio/saba-native-binary
[submodule "animerenderer/src/main/resources/natives/live2d"]
path = animerenderer/src/main/resources/natives/live2d
url = https://github.com/PrimogemStudio/live2d-native-binary
[submodule "animerenderer/src/main/resources/natives/saba"]
path = animerenderer/src/main/resources/natives/saba
url = https://github.com/PrimogemStudio/saba-native-binary
[submodule "animerenderer/src/main/resources/natives/live2d"]
path = animerenderer/src/main/resources/natives/live2d
url = https://github.com/PrimogemStudio/live2d-native-binary
[submodule "flutter-ui/src/main/resources/natives"]
path = flutter-ui/src/main/resources/natives
url = https://github.com/PrimogemStudio/flutter-minecraft-prebuilt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,36 @@

import org.lwjgl.system.NativeType;

import java.io.FileOutputStream;
import java.lang.ref.Cleaner;
import java.util.Objects;

public final class FlutterNative {
static {
System.load("D:/engine/src/out/host_release/flutter_minecraft.dll");
var os = System.getProperty("os.name");
var path = "";
var name = "";
if (os.contains("Windows")) {
path = "/natives/flutter_minecraft.dll";
name = "flutter_minecraft.dll";
} else if (os.contains("Linux")) {
path = "/natives/libflutter_minecraft.so";
name = "libflutter_minecraft.so";
} else if (os.contains("Mac")) {
path = "/natives/libflutter_minecraft.dylib";
name = "libflutter_minecraft.dylib";
} else {
throw new RuntimeException("Unsupported OS: " + os);
}
var lib = System.getProperty("java.io.tmpdir") + "/" + name;
try (var in = FlutterNative.class.getResourceAsStream(path)) {
try (var out = new FileOutputStream(lib)) {
out.write(Objects.requireNonNull(in).readAllBytes());
}
System.load(lib);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}

static Cleaner cleaner = Cleaner.create();
Expand Down
1 change: 1 addition & 0 deletions flutter-ui/src/main/resources/natives
Submodule natives added at aaee0f
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ fun main() {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3)
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3)
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE)
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE)
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE)
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE)
val window = glfwCreateWindow(800, 600, "Flutter", 0, 0)
Expand Down

0 comments on commit 09c60f4

Please sign in to comment.