Skip to content

Commit c0f12e5

Browse files
committed
Update to LWJGL SNAPSHOT-3.3.4 Build 6, support all the architectures
1 parent 0f48f8d commit c0f12e5

File tree

55 files changed

+40
-56
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+40
-56
lines changed

build.gradle.kts

+23-37
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ val license: String = buildConfig["license"] as String
4545
val mcVersion: String = libs.versions.minecraft.get()
4646
val buildNumber: Int = System.getenv("CI_PIPELINE_IID")?.toIntOrNull() ?: 0
4747
val buildTime: Instant = Instant.now()
48-
49-
val yogaPlatforms: List<String> = (buildConfig["yoga_platforms"] as String).split(',')
50-
val freeTypePlatforms: List<String> = (buildConfig["freetype_platforms"] as String).split(',')
51-
val msdfgenPlatforms: List<String> = (buildConfig["msdfgen_platforms"] as String).split(',')
48+
val platforms: List<String> = (buildConfig["platforms"] as String).split(',')
5249

5350
version = "${libs.versions.pda.get()}.$buildNumber"
5451
group = buildConfig["group"] as String
@@ -116,6 +113,15 @@ repositories {
116113
maven("https://git.karmakrafts.dev/api/v4/projects/267/packages/maven")
117114
}
118115

116+
fun DependencyHandlerScope.localLwjglModule(name: String) {
117+
libraryConfig(files(projectPath / "libs" / "lwjgl-$name.jar"))
118+
compileOnly(files(projectPath / "libs" / "lwjgl-$name-javadoc.jar"))
119+
compileOnly(files(projectPath / "libs" / "lwjgl-$name-sources.jar"))
120+
platforms.forEach { platform ->
121+
libraryConfig(files(projectPath / "libs" / "lwjgl-$name-natives-$platform.jar"))
122+
}
123+
}
124+
119125
dependencies {
120126
minecraft(libs.minecraftForge)
121127
implementation(libs.kotlinForForge)
@@ -127,32 +133,9 @@ dependencies {
127133
coreLibraryConfig(libs.materialColorUtils)
128134
coreLibraryConfig(libs.lz4j)
129135

130-
libraryConfig(libs.lwjglYoga)
131-
yogaPlatforms.forEach { platform ->
132-
libs.lwjglYoga.get().apply {
133-
libraryConfig(module.group, module.name, version, classifier = "natives-$platform") {
134-
isTransitive = false
135-
}
136-
}
137-
}
138-
139-
libraryConfig(files(projectPath / "libs" / "lwjgl-freetype-3.3.4-SNAPSHOT.jar"))
140-
compileOnly(files(projectPath / "libs" / "lwjgl-freetype-3.3.4-SNAPSHOT-javadoc.jar"))
141-
compileOnly(files(projectPath / "libs" / "lwjgl-freetype-3.3.4-SNAPSHOT-sources.jar"))
142-
freeTypePlatforms.forEach { platform ->
143-
libs.lwjglFreeType.get().apply {
144-
libraryConfig(module.group, module.name, version, classifier = "natives-$platform") {
145-
isTransitive = false
146-
}
147-
}
148-
}
149-
150-
libraryConfig(files(projectPath / "libs" / "lwjgl-msdfgen-3.3.4-SNAPSHOT.jar"))
151-
compileOnly(files(projectPath / "libs" / "lwjgl-msdfgen-3.3.4-SNAPSHOT-javadoc.jar"))
152-
compileOnly(files(projectPath / "libs" / "lwjgl-msdfgen-3.3.4-SNAPSHOT-sources.jar"))
153-
msdfgenPlatforms.forEach { platform ->
154-
libraryConfig(files(projectPath / "libs" / "lwjgl-msdfgen-3.3.4-SNAPSHOT-natives-$platform.jar"))
155-
}
136+
localLwjglModule("freetype")
137+
localLwjglModule("msdfgen")
138+
localLwjglModule("yoga")
156139

157140
compileOnly(apiSourceSet.output)
158141

@@ -307,6 +290,13 @@ fun DependencyFilter.includeCoreLibs() {
307290
include(dependency(libs.lz4j.toShadowInclude()))
308291
}
309292

293+
fun DependencyFilter.includeLocalLwjglModule(name: String) {
294+
include(dependency(files(projectPath / "libs" / "lwjgl-$name.jar")))
295+
platforms.forEach { platform ->
296+
include(dependency(files(projectPath / "libs" / "lwjgl-$name-natives-$platform.jar")))
297+
}
298+
}
299+
310300
val shadowJarTask = tasks.getByName<ShadowJar>("shadowJar") {
311301
from(
312302
mainSourceSet.output,
@@ -320,13 +310,9 @@ val shadowJarTask = tasks.getByName<ShadowJar>("shadowJar") {
320310
finalizedBy("reobfShadowJar") // Lazy forward dependency
321311
dependencies {
322312
includeCoreLibs()
323-
include(dependency(libs.lwjglYoga.toShadowInclude()))
324-
include(dependency(libs.lwjglFreeType.toShadowInclude()))
325-
include(dependency(files(projectPath / "libs" / "lwjgl-freetype-3.3.4-SNAPSHOT.jar")))
326-
include(dependency(files(projectPath / "libs" / "lwjgl-msdfgen-3.3.4-SNAPSHOT.jar")))
327-
msdfgenPlatforms.forEach { platform ->
328-
include(dependency(files(projectPath / "libs" / "lwjgl-msdfgen-3.3.4-SNAPSHOT-natives-$platform.jar")))
329-
}
313+
includeLocalLwjglModule("freetype")
314+
includeLocalLwjglModule("msdfgen")
315+
includeLocalLwjglModule("yoga")
330316
}
331317
}
332318
val reobfShadowJarTask = reobf.create("shadowJar")

build.properties

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@ mod_name=PDA
77
group=io.karma.pda
88
mappings_channel=parchment
99
license=All Rights Reserved
10-
yoga_platforms=linux,linux-arm64,macos,macos-arm64,windows,windows-arm64
11-
freetype_platforms=linux,linux-arm64,macos,macos-arm64,windows,windows-arm64
12-
msdfgen_platforms=linux,macos,macos-arm64,windows
10+
platforms=linux,linux-arm32,linux-arm64,linux-ppc64le,linux-riscv64,macos,macos-arm64,windows,windows-arm64,windows-x86,freebsd

gradle/libs.versions.toml

-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jackson = "2.17.2" # https://mvnrepository.com/artifact/com.fasterxml.jackson.co
1616
materialColorUtils = "1.1.0.8" # https://git.karmakrafts.dev/kk/material-color-utils/-/packages/
1717
lz4j = "1.8.0" # https://mvnrepository.com/artifact/org.lz4/lz4-java
1818
kotlinForForge = "4.10.0" # https://thedarkcolour.github.io/KotlinForForge/thedarkcolour/kotlinforforge/web.html
19-
lwjgl = "3.3.3" # https://mvnrepository.com/artifact/org.lwjgl/lwjgl
2019
junit = "5.10.3" # https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
2120

2221
[libraries]
@@ -26,8 +25,6 @@ jacksonCore = { module = "com.fasterxml.jackson.core:jackson-core", version.ref
2625
jacksonAnnotationns = { module = "com.fasterxml.jackson.core:jackson-annotations", version.ref = "jackson" }
2726
jacksonDatabind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" }
2827
kotlinForForge = { module = "thedarkcolour:kotlinforforge", version.ref = "kotlinForForge" }
29-
lwjglYoga = { module = "org.lwjgl:lwjgl-yoga", version.ref = "lwjgl" }
30-
lwjglFreeType = { module = "org.lwjgl:lwjgl-freetype", version.ref = "lwjgl" }
3128
materialColorUtils = { module = "io.karma.material:material-color-utils", version.ref = "materialColorUtils" }
3229
lz4j = { module = "org.lz4:lz4-java", version.ref = "lz4j" }
3330
junitApi = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }
1.12 MB
Binary file not shown.
1010 KB
Binary file not shown.
1.2 MB
Binary file not shown.
1.43 MB
Binary file not shown.
1.14 MB
Binary file not shown.

libs/lwjgl-freetype-natives-linux.jar

1.21 MB
Binary file not shown.
1000 KB
Binary file not shown.

libs/lwjgl-freetype-natives-macos.jar

1.06 MB
Binary file not shown.
883 KB
Binary file not shown.
869 KB
Binary file not shown.
1 MB
Binary file not shown.
File renamed without changes.
-174 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-26.9 KB
Binary file not shown.

libs/lwjgl-msdfgen-3.3.4-SNAPSHOT.jar

-37.5 KB
Binary file not shown.

libs/lwjgl-msdfgen-javadoc.jar

191 KB
Binary file not shown.
79.8 KB
Binary file not shown.
58.5 KB
Binary file not shown.
67.3 KB
Binary file not shown.
86.1 KB
Binary file not shown.
66.2 KB
Binary file not shown.

libs/lwjgl-msdfgen-natives-linux.jar

88.5 KB
Binary file not shown.
84.6 KB
Binary file not shown.

libs/lwjgl-msdfgen-natives-macos.jar

108 KB
Binary file not shown.
113 KB
Binary file not shown.
131 KB
Binary file not shown.
136 KB
Binary file not shown.

libs/lwjgl-msdfgen-sources.jar

28.7 KB
Binary file not shown.

libs/lwjgl-msdfgen.jar

46.6 KB
Binary file not shown.

libs/lwjgl-yoga-javadoc.jar

179 KB
Binary file not shown.

libs/lwjgl-yoga-natives-freebsd.jar

55.2 KB
Binary file not shown.
43.5 KB
Binary file not shown.
48.5 KB
Binary file not shown.
55.9 KB
Binary file not shown.
49.8 KB
Binary file not shown.

libs/lwjgl-yoga-natives-linux.jar

65 KB
Binary file not shown.
46.8 KB
Binary file not shown.

libs/lwjgl-yoga-natives-macos.jar

59.2 KB
Binary file not shown.
96.5 KB
Binary file not shown.
101 KB
Binary file not shown.

libs/lwjgl-yoga-natives-windows.jar

115 KB
Binary file not shown.

libs/lwjgl-yoga-sources.jar

26.2 KB
Binary file not shown.

libs/lwjgl-yoga.jar

39.1 KB
Binary file not shown.

src/main/java/io/karma/pda/mod/client/render/graphics/font/DefaultFontAtlas.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private void buildAndMeasureShapes(final MSDFFont fontResource, final StitchCont
150150
context.shapes.put(c, MemoryUtil.NULL);
151151
continue;
152152
}
153-
final var boundsBuffer = MSDFGenBounds.malloc(1, stack);
153+
final var boundsBuffer = MSDFGenBounds.malloc(stack);
154154
MSDFUtils.throwIfError(MSDFGen.msdf_shape_get_bounds(shape, boundsBuffer));
155155
final var width = boundsBuffer.r() - boundsBuffer.l();
156156
if (context.maxWidth < width) {
@@ -186,7 +186,7 @@ private void renderShapes(final MSDFFont fontResource, final StitchContext conte
186186
final var totalSpriteBorder = spriteBorder << 1;
187187
final var actualSpriteSize = spriteSize - totalSpriteBorder;
188188

189-
final var boundsBuffer = MSDFGenBounds.malloc(1, stack);
189+
final var boundsBuffer = MSDFGenBounds.malloc(stack);
190190
MSDFUtils.throwIfError(MSDFGen.msdf_shape_get_bounds(shape, boundsBuffer));
191191
final var bbWidth = boundsBuffer.r() - boundsBuffer.l();
192192
final var bbHeight = boundsBuffer.t() - boundsBuffer.b();

src/main/java/io/karma/pda/mod/client/render/graphics/font/MSDFFont.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.lwjgl.util.freetype.FT_GlyphSlot;
2222
import org.lwjgl.util.freetype.FreeType;
2323
import org.lwjgl.util.msdfgen.MSDFGen;
24+
import org.lwjgl.util.msdfgen.MSDFGenExt;
2425

2526
import java.io.IOException;
2627
import java.io.InputStream;
@@ -50,7 +51,7 @@ public final class MSDFFont implements AutoCloseable {
5051
LibFFI.ffi_type_pointer);
5152

5253
static {
53-
MSDFUtils.throwIfError(MSDFGen.msdf_ft_set_load_callback(nameAddress -> FreeType.getLibrary().getFunctionAddress(
54+
MSDFUtils.throwIfError(MSDFGenExt.msdf_ft_set_load_callback(nameAddress -> FreeType.getLibrary().getFunctionAddress(
5455
MemoryUtil.memASCII(nameAddress))));
5556
}
5657

@@ -112,8 +113,7 @@ public MSDFFont(final InputStream stream) throws IOException {
112113

113114
// Setup msdfgen to use LWJGL FreeType bindings
114115
final var fontAddressBuffer = stack.mallocPointer(1);
115-
MSDFUtils.throwIfError(MSDFGen.msdf_ft_adopt_font(MemoryUtil.memByteBuffer(face.address(), face.sizeof()),
116-
fontAddressBuffer));
116+
MSDFUtils.throwIfError(MSDFGenExt.msdf_ft_adopt_font(face.address(), fontAddressBuffer));
117117
font = Checks.check(fontAddressBuffer.get());
118118
}
119119
}
@@ -130,7 +130,10 @@ public long createGlyphShape(final int c) {
130130
try (final var stack = MemoryStack.stackPush()) {
131131
final var addressBuffer = stack.mallocPointer(1);
132132
// Convert raw Java character to unicode codepoint to properly support surrogate pairs
133-
MSDFUtils.throwIfError(MSDFGen.msdf_ft_font_load_glyph(font, c, addressBuffer));
133+
MSDFUtils.throwIfError(MSDFGenExt.msdf_ft_font_load_glyph(font,
134+
c,
135+
MSDFGenExt.MSDF_FONT_SCALING_NONE,
136+
addressBuffer));
134137
final var shape = Checks.check(addressBuffer.get());
135138
MSDFUtils.throwIfError(MSDFGen.msdf_shape_normalize(shape));
136139
MSDFUtils.rewindShapeIfNeeded(shape);
@@ -187,7 +190,7 @@ public FT_Face getFace() {
187190
@Override
188191
public void close() throws Exception {
189192
stream.close();
190-
MSDFGen.msdf_ft_font_destroy(font);
193+
MSDFGenExt.msdf_ft_font_destroy(font);
191194
PDAMod.LOGGER.debug("Freed font instance at 0x{}", Long.toHexString(font));
192195
FreeType.FT_Done_Face(face);
193196
PDAMod.LOGGER.debug("Freed font face instance at 0x{}", Long.toHexString(face.address()));

src/main/java/io/karma/pda/mod/client/util/MSDFUtils.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ private MSDFUtils() {}
2626

2727
public static void rewindShapeIfNeeded(final long shape) {
2828
try (final var stack = MemoryStack.stackPush()) {
29-
final var bounds = MSDFGenBounds.malloc(1, stack);
29+
final var bounds = MSDFGenBounds.malloc(stack);
3030
MSDFUtils.throwIfError(MSDFGen.msdf_shape_get_bounds(shape, bounds));
3131
final var outerPoint = new Vector2d(bounds.l() - (bounds.r() - bounds.l()) - 1,
3232
bounds.b() - (bounds.t() - bounds.b()) - 1);
3333
final var distanceBuffer = stack.mallocDouble(1);
3434
MSDFUtils.throwIfError(MSDFGen.msdf_shape_one_shot_distance(shape,
35-
MSDFGenVector2.malloc(1, stack).x(outerPoint.x).y(outerPoint.y),
35+
MSDFGenVector2.malloc(stack).x(outerPoint.x).y(outerPoint.y),
3636
distanceBuffer));
3737
if (distanceBuffer.get() > 0.0) {
3838
PDAMod.LOGGER.debug("Shape wound incorrectly, correcting winding order");
@@ -81,7 +81,7 @@ public static void scaleShape(final long shape, final double scale) {
8181
final var pointCount = pointCountBuffer.get();
8282
for (long k = 0; k < pointCount; k++) {
8383
try (final var pointStack = MemoryStack.stackPush()) {
84-
final var pos = MSDFGenVector2.malloc(1, pointStack);
84+
final var pos = MSDFGenVector2.malloc(pointStack);
8585
throwIfError(MSDFGen.msdf_segment_get_point(segment, k, pos));
8686
pos.x(pos.x() * scale);
8787
pos.y(pos.y() * scale);
@@ -114,7 +114,7 @@ public static void throwIfError(final int result) {
114114
}
115115
}
116116

117-
public static void blitBitmapToImage(final MSDFGenBitmap.Buffer bitmap, final BufferedImage image, final int dstX,
117+
public static void blitBitmapToImage(final MSDFGenBitmap bitmap, final BufferedImage image, final int dstX,
118118
final int dstY) {
119119
if (image.getType() != BufferedImage.TYPE_INT_ARGB) {
120120
throw new IllegalArgumentException("Invalid target image format");
@@ -157,9 +157,9 @@ public static void renderShapeToImage(final int type, final int width, final int
157157
final double yOffset, final double range, final BufferedImage dst,
158158
final int dstX, final int dstY) {
159159
try (final var stack = MemoryStack.stackPush()) {
160-
final var bitmap = MSDFGenBitmap.malloc(1, stack);
160+
final var bitmap = MSDFGenBitmap.malloc(stack);
161161
throwIfError(MSDFGen.msdf_bitmap_alloc(type, width, height, bitmap));
162-
final var transform = MSDFGenTransform.malloc(1, stack);
162+
final var transform = MSDFGenTransform.malloc(stack);
163163
transform.scale().set(xScale, yScale);
164164
transform.translation().set(xOffset, yOffset);
165165
transform.distance_mapping().set(-0.5 * range, 0.5 * range);

0 commit comments

Comments
 (0)