Skip to content

Commit d0b3984

Browse files
committed
Add text renderer
1 parent d6d91d0 commit d0b3984

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

+1358
-342
lines changed

.idea/copyright/lgpl.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ A 3D sandbox game.
77
Math codes are from [JOML](https://github.com/JOML-CI/JOML).
88

99
Block textures are from [Squareful](https://www.curseforge.com/minecraft/texture-packs/xekr-square-pattern) by XeKr redistributed under [CC BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/deed.zh) License.
10+
11+
Font hexadecimal data uses [Unifont 15.1.05](https://www.unifoundry.com/unifont/index.html).

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,6 @@ if (hasPublication.toBoolean() && publicationRepo != null) {
326326

327327
dependencies {
328328
constraints {
329-
gameModules.forEach { api("io.github.xenfork:${it.artifactId}:${it.version}") }
329+
gameModules.forEach { api("$projGroupId:${it.artifactId}:${it.version}") }
330330
}
331331
}

doc/legal/LICENSE_Unifont.txt

Lines changed: 476 additions & 0 deletions
Large diffs are not rendered by default.

modules/freeworld.client/build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ plugins {
1212
application
1313
}
1414

15+
val clientVersion: String by rootProject
1516
val jdkEnablePreview: String by rootProject
1617
val overrunglVersion: String by rootProject
1718

@@ -72,3 +73,13 @@ application {
7273
)
7374
}
7475
}
76+
77+
tasks.processResources {
78+
val map = mapOf(
79+
"client_version" to clientVersion
80+
)
81+
inputs.properties(map)
82+
filesMatching("client_version.json") {
83+
expand(map)
84+
}
85+
}

modules/freeworld.client/src/main/java/freeworld/client/Freeworld.java renamed to modules/freeworld.client/src/main/java/freeworld/client/FreeworldClient.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public
7-
* License as published by the Free Software Foundation;
8-
* only version 2.1 of the License.
7+
* License as published by the Free Software Foundation; either
8+
* version 2.1 of the License, or (at your option) any later version.
99
*/
1010

1111
package freeworld.client;
@@ -15,7 +15,6 @@
1515
import freeworld.client.render.GameRenderer;
1616
import freeworld.client.render.RenderSystem;
1717
import freeworld.client.render.gl.GLStateMgr;
18-
import freeworld.client.render.model.block.BlockModelManager;
1918
import freeworld.client.render.screen.Screen;
2019
import freeworld.client.render.screen.ingame.CreativeTabScreen;
2120
import freeworld.client.render.screen.ingame.PauseScreen;
@@ -55,8 +54,8 @@
5554
* @author squid233
5655
* @since 0.1.0
5756
*/
58-
public final class Freeworld implements AutoCloseable {
59-
private static final Freeworld INSTANCE = new Freeworld();
57+
public final class FreeworldClient implements AutoCloseable {
58+
private static final FreeworldClient INSTANCE = new FreeworldClient();
6059
private static final Logger logger = Logging.caller();
6160
private static final int INIT_WINDOW_WIDTH = 854;
6261
private static final int INIT_WINDOW_HEIGHT = 480;
@@ -71,7 +70,6 @@ public final class Freeworld implements AutoCloseable {
7170
private final Camera camera = new Camera();
7271
private MouseInput mouseInput;
7372
private GameRenderer gameRenderer;
74-
private BlockModelManager blockModelManager;
7573
private World world;
7674
private PlayerEntity player;
7775
@Nullable
@@ -81,8 +79,9 @@ public final class Freeworld implements AutoCloseable {
8179
private int blockPlaceTimer = 0;
8280
private int gameTick = 0;
8381
private int spaceTick = 0;
82+
private boolean debugHudEnabled = false;
8483

85-
private Freeworld() {
84+
private FreeworldClient() {
8685
this.glfw = GLFW.INSTANCE;
8786
}
8887

@@ -109,7 +108,7 @@ public void start() {
109108
throw new IllegalStateException("Failed to create GLFW window");
110109
}
111110

112-
mouseInput = new MouseInput(window);
111+
mouseInput = new MouseInput(this, window);
113112
CursorPosEvent.DISABLED.subscribe(this::onCursorPosDisabled);
114113
glfw.setKeyCallback(window, (_, key, scancode, action, mods) -> onKey(key, scancode, action, mods));
115114
glfw.setFramebufferSizeCallback(window, (_, width, height) -> onResize(width, height));
@@ -168,6 +167,7 @@ private void onKey(int key, int scancode, int action, int mods) {
168167
}
169168
spaceTick = gameTick;
170169
}
170+
case GLFW.KEY_F3 -> debugHudEnabled = !debugHudEnabled;
171171
}
172172
}
173173
} else {
@@ -313,9 +313,6 @@ private void initGL() {
313313

314314
RenderSystem.initialize(gl);
315315

316-
blockModelManager = new BlockModelManager();
317-
blockModelManager.bootstrap();
318-
319316
EntityRenderers.bootstrap();
320317

321318
gameRenderer = new GameRenderer(this);
@@ -407,10 +404,6 @@ public GameRenderer gameRenderer() {
407404
return gameRenderer;
408405
}
409406

410-
public BlockModelManager blockModelManager() {
411-
return blockModelManager;
412-
}
413-
414407
public World world() {
415408
return world;
416409
}
@@ -423,7 +416,11 @@ public float guiScale() {
423416
return guiScale;
424417
}
425418

426-
public static Freeworld getInstance() {
419+
public boolean debugHudEnabled() {
420+
return debugHudEnabled;
421+
}
422+
423+
public static FreeworldClient getInstance() {
427424
return INSTANCE;
428425
}
429426
}

modules/freeworld.client/src/main/java/freeworld/client/MouseInput.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public
7-
* License as published by the Free Software Foundation;
8-
* only version 2.1 of the License.
7+
* License as published by the Free Software Foundation; either
8+
* version 2.1 of the License, or (at your option) any later version.
99
*/
1010

1111
package freeworld.client;
@@ -20,15 +20,16 @@
2020
* @since 0.1.0
2121
*/
2222
public final class MouseInput {
23-
private final GLFW glfw = GLFW.INSTANCE;
23+
private final GLFW glfw;
2424
private final MemorySegment window;
2525
private double cursorX;
2626
private double cursorY;
2727
private double cursorDeltaX;
2828
private double cursorDeltaY;
2929
private boolean disabled = false;
3030

31-
public MouseInput(MemorySegment window) {
31+
public MouseInput(FreeworldClient client, MemorySegment window) {
32+
this.glfw = client.glfw();
3233
this.window = window;
3334
glfw.setCursorPosCallback(window, (_, x, y) -> {
3435
cursorDeltaX = x - cursorX;

modules/freeworld.client/src/main/java/freeworld/client/main/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
package freeworld.client.main;
1212

13-
import freeworld.client.Freeworld;
13+
import freeworld.client.FreeworldClient;
1414

1515
/**
1616
* The main class
@@ -28,7 +28,7 @@ private Main() {
2828
* @param args arguments
2929
*/
3030
public static void main(String[] args) {
31-
try (Freeworld game = Freeworld.getInstance()) {
31+
try (FreeworldClient game = FreeworldClient.getInstance()) {
3232
game.start();
3333
}
3434
}

0 commit comments

Comments
 (0)