Added window icons
- Added window icons for various sizes - Broken on Wayland - Due to a bug in texture loading, textures a flipped - Included non-flipped versions - Added TextureSettings.allocateExactBuffer - When true, texture size is not rounded to a power of 2
@ -22,6 +22,9 @@ import static org.lwjgl.opengl.GL11.*;
|
|||||||
import static org.lwjgl.glfw.GLFW.*;
|
import static org.lwjgl.glfw.GLFW.*;
|
||||||
import static org.lwjgl.system.MemoryUtil.*;
|
import static org.lwjgl.system.MemoryUtil.*;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.lwjgl.glfw.GLFWImage;
|
||||||
import org.lwjgl.opengl.GL;
|
import org.lwjgl.opengl.GL;
|
||||||
|
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
@ -30,6 +33,12 @@ import ru.windcorp.progressia.Progressia;
|
|||||||
import ru.windcorp.progressia.client.graphics.GUI;
|
import ru.windcorp.progressia.client.graphics.GUI;
|
||||||
import ru.windcorp.progressia.client.graphics.input.FrameResizeEvent;
|
import ru.windcorp.progressia.client.graphics.input.FrameResizeEvent;
|
||||||
import ru.windcorp.progressia.client.graphics.input.InputEvent;
|
import ru.windcorp.progressia.client.graphics.input.InputEvent;
|
||||||
|
import ru.windcorp.progressia.client.graphics.texture.TextureDataEditor;
|
||||||
|
import ru.windcorp.progressia.client.graphics.texture.TextureLoader;
|
||||||
|
import ru.windcorp.progressia.client.graphics.texture.TextureSettings;
|
||||||
|
import ru.windcorp.progressia.common.resource.Resource;
|
||||||
|
import ru.windcorp.progressia.common.resource.ResourceManager;
|
||||||
|
import ru.windcorp.progressia.common.util.crash.CrashReports;
|
||||||
|
|
||||||
class LWJGLInitializer {
|
class LWJGLInitializer {
|
||||||
|
|
||||||
@ -64,14 +73,20 @@ class LWJGLInitializer {
|
|||||||
glfwWindowHint(GLFW_FOCUSED, GLFW_TRUE);
|
glfwWindowHint(GLFW_FOCUSED, GLFW_TRUE);
|
||||||
glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);
|
glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);
|
||||||
|
|
||||||
long handle = glfwCreateWindow(800, 600, Progressia.getName() + " " + Progressia.getFullerVersion(), NULL, NULL);
|
long handle = glfwCreateWindow(
|
||||||
|
800,
|
||||||
|
600,
|
||||||
|
Progressia.getName() + " " + Progressia.getFullerVersion(),
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
// TODO Check that handle != NULL
|
// TODO Check that handle != NULL
|
||||||
|
|
||||||
GraphicsBackend.setWindowHandle(handle);
|
GraphicsBackend.setWindowHandle(handle);
|
||||||
|
|
||||||
glfwMakeContextCurrent(handle);
|
glfwMakeContextCurrent(handle);
|
||||||
glfwSwapInterval(0); // TODO: remove after config system is added
|
glfwSwapInterval(0); // TODO: remove after config system is added
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void positionWindow() {
|
private static void positionWindow() {
|
||||||
@ -80,8 +95,25 @@ class LWJGLInitializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void createWindowIcons() {
|
private static void createWindowIcons() {
|
||||||
// TODO Auto-generated method stub
|
final String prefix = "assets/icons/";
|
||||||
|
|
||||||
|
String[] sizes = ResourceManager.getResource(prefix + "logoSizes.txt").readAsString().split(" ");
|
||||||
|
|
||||||
|
try (GLFWImage.Buffer buffer = GLFWImage.malloc(sizes.length)) {
|
||||||
|
for (int i = 0; i < sizes.length; ++i) {
|
||||||
|
Resource resource = ResourceManager.getResource(prefix + "logo" + sizes[i].trim() + ".png");
|
||||||
|
TextureDataEditor icon = TextureLoader.loadPixels(resource, new TextureSettings(false, true));
|
||||||
|
|
||||||
|
buffer.position(i)
|
||||||
|
.width(icon.getContentWidth())
|
||||||
|
.height(icon.getContentHeight())
|
||||||
|
.pixels(icon.getData().getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwSetWindowIcon(GraphicsBackend.getWindowHandle(), buffer);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw CrashReports.report(e, "Could not load window icons");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeOpenGL() {
|
private static void initializeOpenGL() {
|
||||||
|
@ -45,7 +45,7 @@ public class GNUUnifontLoader {
|
|||||||
|
|
||||||
private static final AtlasGroup ATLAS_GROUP_GNU_UNIFONT = new AtlasGroup("GNUUnifont", 1 << 12);
|
private static final AtlasGroup ATLAS_GROUP_GNU_UNIFONT = new AtlasGroup("GNUUnifont", 1 << 12);
|
||||||
|
|
||||||
private static final TextureSettings TEXTURE_SETTINGS = new TextureSettings(false);
|
private static final TextureSettings TEXTURE_SETTINGS = new TextureSettings(false, false);
|
||||||
|
|
||||||
private static final int BITS_PER_HEX_DIGIT = 4;
|
private static final int BITS_PER_HEX_DIGIT = 4;
|
||||||
private static final int PREFIX_LENGTH = "0000:".length();
|
private static final int PREFIX_LENGTH = "0000:".length();
|
||||||
|
@ -163,7 +163,7 @@ public class Atlases {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final TextureSettings SETTINGS = new TextureSettings(false);
|
private static final TextureSettings SETTINGS = new TextureSettings(false, false);
|
||||||
|
|
||||||
private static final Map<Resource, Sprite> LOADED = new HashMap<>();
|
private static final Map<Resource, Sprite> LOADED = new HashMap<>();
|
||||||
private static final Multimap<AtlasGroup, Atlas> ATLASES = MultimapBuilder.hashKeys().arrayListValues().build();
|
private static final Multimap<AtlasGroup, Atlas> ATLASES = MultimapBuilder.hashKeys().arrayListValues().build();
|
||||||
|
@ -28,7 +28,7 @@ import ru.windcorp.progressia.common.util.crash.CrashReports;
|
|||||||
|
|
||||||
public class SimpleTextures {
|
public class SimpleTextures {
|
||||||
|
|
||||||
private static final TextureSettings SETTINGS = new TextureSettings(false);
|
private static final TextureSettings SETTINGS = new TextureSettings(false, false);
|
||||||
|
|
||||||
private static final Map<Resource, Texture> TEXTURES = new HashMap<>();
|
private static final Map<Resource, Texture> TEXTURES = new HashMap<>();
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import static org.lwjgl.opengl.GL12.*;
|
|||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
class TextureData {
|
public class TextureData {
|
||||||
|
|
||||||
private final ByteBuffer data;
|
private final ByteBuffer data;
|
||||||
|
|
||||||
|
@ -42,8 +42,16 @@ public class TextureLoader {
|
|||||||
int width = readResult.getWidth();
|
int width = readResult.getWidth();
|
||||||
int height = readResult.getHeight();
|
int height = readResult.getHeight();
|
||||||
|
|
||||||
int bufferWidth = BinUtil.roundToGreaterPowerOf2(width);
|
int bufferWidth;
|
||||||
int bufferHeight = BinUtil.roundToGreaterPowerOf2(height);
|
int bufferHeight;
|
||||||
|
|
||||||
|
if (settings.allocateExactBuffer()) {
|
||||||
|
bufferWidth = width;
|
||||||
|
bufferHeight = height;
|
||||||
|
} else {
|
||||||
|
bufferWidth = BinUtil.roundToGreaterPowerOf2(width);
|
||||||
|
bufferHeight = BinUtil.roundToGreaterPowerOf2(height);
|
||||||
|
}
|
||||||
|
|
||||||
WritableRaster raster = TextureUtil.createRaster(
|
WritableRaster raster = TextureUtil.createRaster(
|
||||||
bufferWidth,
|
bufferWidth,
|
||||||
|
@ -21,13 +21,19 @@ package ru.windcorp.progressia.client.graphics.texture;
|
|||||||
public class TextureSettings {
|
public class TextureSettings {
|
||||||
|
|
||||||
private final boolean isFiltered;
|
private final boolean isFiltered;
|
||||||
|
private final boolean allocateExactBuffer;
|
||||||
|
|
||||||
public TextureSettings(boolean isFiltered) {
|
public TextureSettings(boolean isFiltered, boolean allocateExactBuffer) {
|
||||||
this.isFiltered = isFiltered;
|
this.isFiltered = isFiltered;
|
||||||
|
this.allocateExactBuffer = allocateExactBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFiltered() {
|
public boolean isFiltered() {
|
||||||
return isFiltered;
|
return isFiltered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean allocateExactBuffer() {
|
||||||
|
return allocateExactBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class EntityRenderRegistry extends NamespacedInstanceRegistry<EntityRende
|
|||||||
ResourceManager.getTextureResource(
|
ResourceManager.getTextureResource(
|
||||||
"entities/" + name
|
"entities/" + name
|
||||||
),
|
),
|
||||||
new TextureSettings(false)
|
new TextureSettings(false, false)
|
||||||
).getData()
|
).getData()
|
||||||
);
|
);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
BIN
src/main/resources/assets/icons/logo128.original.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
src/main/resources/assets/icons/logo128.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
src/main/resources/assets/icons/logo16.original.png
Executable file
After Width: | Height: | Size: 342 B |
BIN
src/main/resources/assets/icons/logo16.png
Normal file
After Width: | Height: | Size: 424 B |
BIN
src/main/resources/assets/icons/logo20.original.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
src/main/resources/assets/icons/logo20.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
src/main/resources/assets/icons/logo22.original.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
src/main/resources/assets/icons/logo22.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
src/main/resources/assets/icons/logo24.original.png
Executable file
After Width: | Height: | Size: 8.5 KiB |
BIN
src/main/resources/assets/icons/logo24.png
Normal file
After Width: | Height: | Size: 485 B |
BIN
src/main/resources/assets/icons/logo256.original.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
src/main/resources/assets/icons/logo256.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
src/main/resources/assets/icons/logo32.original.png
Executable file
After Width: | Height: | Size: 407 B |
BIN
src/main/resources/assets/icons/logo32.png
Normal file
After Width: | Height: | Size: 476 B |
BIN
src/main/resources/assets/icons/logo40.original.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
src/main/resources/assets/icons/logo40.png
Normal file
After Width: | Height: | Size: 8.5 KiB |
BIN
src/main/resources/assets/icons/logo48.original.png
Executable file
After Width: | Height: | Size: 529 B |
BIN
src/main/resources/assets/icons/logo48.png
Normal file
After Width: | Height: | Size: 541 B |
BIN
src/main/resources/assets/icons/logo64.original.png
Executable file
After Width: | Height: | Size: 6.6 KiB |
BIN
src/main/resources/assets/icons/logo64.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
src/main/resources/assets/icons/logo96.original.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
src/main/resources/assets/icons/logo96.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
1
src/main/resources/assets/icons/logoSizes.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
16 20 22 24 32 40 48 64 96 128 256
|