centering text when setting lower resolution in robot; clearing screen when changing resolution to avoid dirty buffer space and cursor going out of scope

This commit is contained in:
Florian Nücke 2013-12-17 14:01:56 +01:00
parent 9a0ebf1bae
commit 7cd405361b
2 changed files with 12 additions and 0 deletions

View File

@ -20,3 +20,4 @@ local result, reason = component.gpu.setResolution(w, h)
if not result then
print(reason)
end
term.clear()

View File

@ -76,6 +76,17 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten
GL11.glTranslatef(8, 8, 0)
RenderState.disableLighting()
RenderState.makeItBlend()
val (w, h) = buffer.resolution
val scaleX = 48f / w
val scaleY = 14f / h
val scale = math.min(scaleX, scaleY)
if (scaleX > scale) {
GL11.glTranslated(MonospaceFontRenderer.fontWidth * w * (scaleX - scale) / 2, 0, 0)
}
else if (scaleY > scale) {
GL11.glTranslated(0, MonospaceFontRenderer.fontHeight * h * (scaleY - scale) / 2, 0)
}
GL11.glScalef(scale, scale, scale)
BufferRenderer.drawText()
}