mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 02:39:48 -04:00
redid font texture to include all ascii chars, even special chars for control characters since there was padding anyway and in particular umlaut chars and such; simplified initialization of renderer a tad, too
This commit is contained in:
parent
cca693da31
commit
887a21941d
Binary file not shown.
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 8.2 KiB |
@ -30,40 +30,31 @@ object MonospaceFontRenderer {
|
|||||||
|
|
||||||
// Set up the display lists.
|
// Set up the display lists.
|
||||||
{
|
{
|
||||||
// The font texture is 16x12, but chars are really only 10x12.
|
|
||||||
val charsPerRow = 16
|
|
||||||
val (charWidth, charHeight) = (MonospaceFontRenderer.fontWidth * 2, MonospaceFontRenderer.fontHeight * 2)
|
val (charWidth, charHeight) = (MonospaceFontRenderer.fontWidth * 2, MonospaceFontRenderer.fontHeight * 2)
|
||||||
val uStep = 1.0 / charsPerRow
|
val cols = 256 / charWidth
|
||||||
val vStep = 1.0 / 12 * 240 / 256 // Correct for padding at bottom.
|
val uStep = charWidth / 256.0
|
||||||
val uOffset = uStep * 3 / 16
|
val vStep = charHeight / 256.0
|
||||||
val uSize = uStep * 10 / 16
|
|
||||||
val vOffset = vStep * 1 / 20
|
|
||||||
val vSize = vStep * 18 / 20
|
|
||||||
val t = Tessellator.instance
|
val t = Tessellator.instance
|
||||||
// Special case for whitespace: just translate, don't render.
|
|
||||||
GL11.glNewList(charLists + 32, GL11.GL_COMPILE)
|
|
||||||
GL11.glTranslatef(charWidth, 0, 0)
|
|
||||||
GL11.glEndList()
|
|
||||||
// Now create lists for all printable chars.
|
// Now create lists for all printable chars.
|
||||||
for (index <- (33 until 0x7F).union(0x9F until 0xFF)) {
|
for (index <- 1 until 0xFF) {
|
||||||
// The font texture does not contain the 0-1F range, nor the 0x7F to
|
val x = (index - 1) % cols
|
||||||
// 0x9F range (control chars as per Character.isISOControl).
|
val y = (index - 1) / cols
|
||||||
val textureIndex =
|
val u = x * uStep
|
||||||
(if (index - 32 >= 0x7F) index - (0x9F - 0x7F) else index) - 32
|
val v = y * vStep
|
||||||
val x = textureIndex % charsPerRow
|
|
||||||
val y = textureIndex / charsPerRow
|
|
||||||
val u = x * uStep + uOffset
|
|
||||||
val v = y * vStep + vOffset
|
|
||||||
GL11.glNewList(charLists + index, GL11.GL_COMPILE)
|
GL11.glNewList(charLists + index, GL11.GL_COMPILE)
|
||||||
t.startDrawingQuads()
|
t.startDrawingQuads()
|
||||||
t.addVertexWithUV(0, charHeight, 0, u, v + vSize)
|
t.addVertexWithUV(0, charHeight, 0, u, v + vStep)
|
||||||
t.addVertexWithUV(charWidth, charHeight, 0, u + uSize, v + vSize)
|
t.addVertexWithUV(charWidth, charHeight, 0, u + uStep, v + vStep)
|
||||||
t.addVertexWithUV(charWidth, 0, 0, u + uSize, v)
|
t.addVertexWithUV(charWidth, 0, 0, u + uStep, v)
|
||||||
t.addVertexWithUV(0, 0, 0, u, v)
|
t.addVertexWithUV(0, 0, 0, u, v)
|
||||||
t.draw()
|
t.draw()
|
||||||
GL11.glTranslatef(charWidth, 0, 0)
|
GL11.glTranslatef(charWidth, 0, 0)
|
||||||
GL11.glEndList()
|
GL11.glEndList()
|
||||||
}
|
}
|
||||||
|
// Special case for whitespace: just translate, don't render.
|
||||||
|
GL11.glNewList(charLists + ' ', GL11.GL_COMPILE)
|
||||||
|
GL11.glTranslatef(charWidth, 0, 0)
|
||||||
|
GL11.glEndList()
|
||||||
}
|
}
|
||||||
|
|
||||||
def drawString(value: Array[Char], x: Int, y: Int) = {
|
def drawString(value: Array[Char], x: Int, y: Int) = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user