Skip to content

Commit

Permalink
GLFW replacement test 1
Browse files Browse the repository at this point in the history
Requires glfw3.dll in assets/borderlessmining to build;
from comp500/glfw@08b3a9e
See #19 for more details.
  • Loading branch information
comp500 committed Dec 18, 2021
1 parent e4b339e commit 0d42a0d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.12.6

# Mod Properties
mod_version = 1.1.1
mod_version = 2.0.0-alpha
maven_group = link.infra.borderlessmining
archives_base_name = borderless-mining

Expand Down
42 changes: 42 additions & 0 deletions src/main/java/link/infra/borderlessmining/GLFWReplace.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package link.infra.borderlessmining;

import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.system.Configuration;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

public class GLFWReplace implements PreLaunchEntrypoint {
private final Logger LOGGER = LogManager.getLogger("BorderlessMining 2?");

@Override
public void onPreLaunch() {
Path dllCopyPath = Paths.get(".borderlessmining", "glfw3.dll");

try {
Files.createDirectories(dllCopyPath.getParent());
InputStream stream = GLFWReplace.class.getClassLoader().getResourceAsStream("assets/borderlessmining/glfw3.dll");
if (stream == null) {
LOGGER.error("Failed to read GLFW dll");
} else {
Files.copy(stream, dllCopyPath, StandardCopyOption.REPLACE_EXISTING);
Configuration.GLFW_LIBRARY_NAME.set(dllCopyPath.toString());
String glfwVersionString = GLFW.glfwGetVersionString();
if (glfwVersionString.contains("BorderlessMining")) {
LOGGER.info("GLFW replaced, version string: " + glfwVersionString);
} else {
LOGGER.error("GLFW replacement failed! Version string: " + glfwVersionString);
}
}
} catch (IOException e) {
LOGGER.error("Failed to copy GLFW dll", e);
}
}
}
22 changes: 8 additions & 14 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,26 @@
"id": "borderlessmining",
"version": "${version}",

"name": "Borderless Mining",
"description": "Adds a windowed borderless (fullscreen) option",
"name": "Borderless Mining (GLFW replacement test)",
"description": "GLFW replacement test; see https://github.com/comp500/BorderlessMining/issues/19 for more information. Only runs on Windows!",
"authors": [
"comp500"
],
"contact": {
"homepage": "https://github.com/comp500/BorderlessMining",
"sources": "https://github.com/comp500/BorderlessMining",
"issues": "https://github.com/comp500/BorderlessMining/issues"
"homepage": "https://github.com/comp500/BorderlessMining/issues/19",
"sources": "https://github.com/comp500/BorderlessMining/tree/experiments/glfw-replacement-test",
"issues": "https://github.com/comp500/BorderlessMining/issues/19"
},

"license": "MIT",
"icon": "assets/borderlessmining/icon.png",

"environment": "client",
"entrypoints": {
"modmenu" : [
"link.infra.borderlessmining.config.ModMenuCompat"
]
"preLaunch": [
"link.infra.borderlessmining.GLFWReplace"
]
},
"mixins": [
{
"config": "borderlessmining.mixins.json",
"environment": "client"
}
],

"depends": {
"fabricloader": ">=0.7.2",
Expand Down

0 comments on commit 0d42a0d

Please sign in to comment.