Fixes #5
All checks were successful
Linux arm64 / Build (push) Successful in 41s

This commit is contained in:
2025-02-02 11:33:21 +01:00
parent d806420d21
commit 990c830590
10 changed files with 50 additions and 10 deletions

View File

@@ -5,16 +5,21 @@ import java.nio.ByteBuffer;
import org.lwjgl.opengl.GL11;
import org.lwjgl.stb.STBImage;
import gui.AssetManager;
public class Images {
public static int BACKGROUND;
private static int loadTexture(String fileName) {
private static int loadTexture(byte[] imageData) {
int[] width = new int[1];
int[] height = new int[1];
int[] channelCount = new int[1];
ByteBuffer pixels = STBImage.stbi_load(fileName, width, height, channelCount, 4);
ByteBuffer img = ByteBuffer.allocateDirect(imageData.length);
img.put(imageData);
img.flip();
ByteBuffer pixels = STBImage.stbi_load_from_memory(img, width, height, channelCount, 4);
int textureID = GL11.glGenTextures();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
@@ -33,7 +38,7 @@ public class Images {
}
public static void reloadImages() {
BACKGROUND = loadTexture(Options.BackgroundPath);
BACKGROUND = loadTexture(AssetManager.getResource(Options.BackgroundPath));
}
}