This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user