legacy-lwjgl3
A hacky over-engineered project that runs LWJGL3 on legacy-fabric minecraft versions (current only tested 1.8.9), Allowing you to use modern LWJGL features and libraries on older minecraft versions.
Credits
First things first though credits are important.
A whole lot of this code is just code from the original LWJGL 2 project modified to work with LWJGL 3, Thanks so much to the LWJGL devs for making their license so permissive.
and a big thanks to gudenau for the original F*rge mod https://github.com/gudenau/MC-LWJGL3 that did the same thing, thanks as a big portion of this code is from that project.
Read before using
this project is still currently missing many features that would make it not such a pain to use, some of the issues are:
- Manually excluding lwjgl 2 to use this (including end uses!!) <<-- | These
- scary classloader tricks used to redefine whole LWJGL classes <<-- | All
- ships lwjgl jar in jar completely bloating file sizes <<-- | Need Fixing
However, if you are like me such measly issues like those are not enough to stop you from wanting to do something like this, here is how to use it.
Using this in a dev environments will require you to manually exclude lwjgl2 dependencies from gradle, an example of doing this excludes all org.lwjgl.lwjgl group packages from all dependencies listed
❯ build.gradle
configurations.all {
exclude group: "org.lwjgl.lwjgl"
}
Past that you need to get the mod loaded somehow, I often end up falling back to modrinth for this but jitpack will have to work for now, get the built artifacts from https://jitpack.io/#Zarzelcow/legacy-lwjgl3 and paste them into your build.gradle follow the guide on their website for how to do this, just keep in mind to use modImplementation
so it gets remapped to work in a dev environment.
You also need to get the lwjgl 3 natives to your classpath which is quite simple you can either get them from https://www.lwjgl.org/customize and just add them yourself, or you can just add this to your build.gradle
❯ build.gradle
import org.gradle.internal.os.OperatingSystem
project.ext.lwjglVersion = "3.3.1"
switch (OperatingSystem.current()) {
case OperatingSystem.LINUX:
project.ext.lwjglNatives = "natives-linux"
break
case OperatingSystem.WINDOWS:
project.ext.lwjglNatives = "natives-windows"
break
}
dependencies {
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")
runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-assimp::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
}
Performance Comparisons
The intention of this project was to give developers access to LWJGL 3 features on legacy versions of minecraft and not to be a performance increasing mod but while we are here why not compare the performance difference.
The settings used to test the two versions are the same? somewhat, I couldn't get vbos turned on while using legacy-lwjgl3 for some reason so there might be some untapped potential there
JDK: temurin-17 (Adopt OpenJDK Hotspot 17)
JVM Options:
-client
-server
-DLWJGL_DISABLE_XRANDR=true
mods:
- fabricloader 0.13.3,
- java 17,
- minecraft 1.8.9
World seed: 123
Options changed from default:
- Map FPS: unlimited
- VSync: Disabled
Left is LWJGL2, Right is legacy-lwjgl3
as you can see barely any difference, LWJGL2 hovered around 165-172 while legacy-lwjgl3 hovered around 175-183.
keep in mind that's without having VBOs turned on for legacy-lwjgl3 (see above), so there might be a big difference in performance if it was to be enabled
Contributing
This project is a work in progress, if you have any suggestions or want to contribute feel free to open an issue or pull request
Seriously please I suck at code quality and need people to help me
Really i w ill accept it im begging you my code quality is so bad