|
@@ -11,7 +11,14 @@ import static org.lwjgl.opengl.GL30.*;
|
|
|
|
|
|
public class FontRenderer
|
|
public class FontRenderer
|
|
{
|
|
{
|
|
- private final static Texture FONT_TEXTURE = new Texture("font.png", true);
|
|
|
|
|
|
+ private final static float ERROR = 0.0f;
|
|
|
|
+
|
|
|
|
+ private final static Texture[] FONT_TEXTURE = new Texture[]
|
|
|
|
+ {
|
|
|
|
+ new Texture("font8x8.png", true),
|
|
|
|
+ new Texture("font16x16.png", true),
|
|
|
|
+ new Texture("font24x24.png", true)
|
|
|
|
+ };
|
|
|
|
|
|
public static final char COLOR_CHAR = '&';
|
|
public static final char COLOR_CHAR = '&';
|
|
|
|
|
|
@@ -95,6 +102,10 @@ public class FontRenderer
|
|
|
|
|
|
private void addRectangle(float minX, float minY, char c)
|
|
private void addRectangle(float minX, float minY, char c)
|
|
{
|
|
{
|
|
|
|
+ float scale = Shader.getViewScale();
|
|
|
|
+ minY = Math.round(minY * scale) / scale;
|
|
|
|
+ minX = Math.round(minX * scale) / scale;
|
|
|
|
+
|
|
float tMinX = (c & 0xF) / 16.0f;
|
|
float tMinX = (c & 0xF) / 16.0f;
|
|
float tMinY = (c >> 4) / 16.0f;
|
|
float tMinY = (c >> 4) / 16.0f;
|
|
float tMaxX = tMinX + 0.0625f;
|
|
float tMaxX = tMinX + 0.0625f;
|
|
@@ -165,7 +176,7 @@ public class FontRenderer
|
|
glUnmapBuffer(GL_ARRAY_BUFFER);
|
|
glUnmapBuffer(GL_ARRAY_BUFFER);
|
|
|
|
|
|
GLHelper.glBindVertexArray(vao);
|
|
GLHelper.glBindVertexArray(vao);
|
|
- FONT_TEXTURE.bind();
|
|
|
|
|
|
+ FONT_TEXTURE[Math.min(Shader.getViewScale() - 1, FONT_TEXTURE.length - 1)].bind();
|
|
|
|
|
|
glDrawArrays(GL_TRIANGLES, offset / 20, buffer.limit() / 20);
|
|
glDrawArrays(GL_TRIANGLES, offset / 20, buffer.limit() / 20);
|
|
|
|
|
|
@@ -244,4 +255,9 @@ public class FontRenderer
|
|
{
|
|
{
|
|
return FONT_SIZE + LINE_STEP;
|
|
return FONT_SIZE + LINE_STEP;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public float getWidth()
|
|
|
|
+ {
|
|
|
|
+ return FONT_SIZE;
|
|
|
|
+ }
|
|
}
|
|
}
|