mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-23 04:24:16 -04:00
Merge branch 'master' of github.com:MightyPirates/OpenComputers into master-MC1.7.10
This commit is contained in:
commit
d37ccc9e28
@ -18,28 +18,13 @@ class DynamicFontRenderer extends TextureFontRenderer {
|
||||
|
||||
private val charMap = mutable.Map.empty[Char, DynamicFontRenderer.CharIcon]
|
||||
|
||||
private val fbo = GL30.glGenFramebuffers()
|
||||
|
||||
private val rbo = GL30.glGenRenderbuffers()
|
||||
|
||||
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbo)
|
||||
GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, rbo)
|
||||
|
||||
GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL11.GL_RGBA8, charWidth * 2, charHeight)
|
||||
GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL30.GL_RENDERBUFFER, rbo)
|
||||
|
||||
GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, 0)
|
||||
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0)
|
||||
|
||||
var activeTexture: CharTexture = textures(0)
|
||||
|
||||
generateChars(basicChars.toCharArray)
|
||||
|
||||
RenderState.checkError(getClass.getName + ".<init>: glGenFramebuffers")
|
||||
override protected def charWidth = glyphProvider.getGlyphWidth
|
||||
|
||||
override protected def charWidth = glyphProvider.getGlyphWidth.toInt
|
||||
|
||||
override protected def charHeight = glyphProvider.getGlyphHeight.toInt
|
||||
override protected def charHeight = glyphProvider.getGlyphHeight
|
||||
|
||||
override protected def textureCount = textures.length
|
||||
|
||||
@ -66,7 +51,7 @@ class DynamicFontRenderer extends TextureFontRenderer {
|
||||
else charMap.getOrElseUpdate('?', createCharIcon('?'))
|
||||
}
|
||||
else {
|
||||
if (textures.last.isFull) {
|
||||
if (textures.last.isFull(char)) {
|
||||
textures += new DynamicFontRenderer.CharTexture(this)
|
||||
textures.last.bind()
|
||||
}
|
||||
@ -103,7 +88,7 @@ object DynamicFontRenderer {
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, id)
|
||||
}
|
||||
|
||||
def isFull = chars >= capacity
|
||||
def isFull(char: Char) = chars + FontUtil.wcwidth(char) > capacity
|
||||
|
||||
def add(char: Char) = {
|
||||
val glyphWidth = FontUtil.wcwidth(char)
|
||||
@ -115,37 +100,9 @@ object DynamicFontRenderer {
|
||||
val x = chars % cols
|
||||
val y = chars / cols
|
||||
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST)
|
||||
GL11.glDepthMask(false)
|
||||
|
||||
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, owner.fbo)
|
||||
GL11.glClearColor(0, 0, 0, 0)
|
||||
GL20.glDrawBuffers(GL30.GL_COLOR_ATTACHMENT0)
|
||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT)
|
||||
|
||||
GL11.glViewport(0, 0, w, h)
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION)
|
||||
GL11.glPushMatrix()
|
||||
GL11.glLoadIdentity()
|
||||
|
||||
GL11.glOrtho(0, w, h, 0, 0, 1)
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW)
|
||||
GL11.glPushMatrix()
|
||||
GL11.glLoadIdentity()
|
||||
GL11.glTranslatef(0, 0, -0.5f)
|
||||
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, id)
|
||||
GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 1 + x * cellWidth, 1 + y * cellHeight, w, h, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, owner.glyphProvider.getGlyph(char))
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION)
|
||||
GL11.glPopMatrix()
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW)
|
||||
GL11.glPopMatrix()
|
||||
|
||||
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0)
|
||||
|
||||
chars += glyphWidth
|
||||
|
||||
new CharIcon(this, w, h, pad + x * uStep, pad + y * vStep, (x + glyphWidth) * uStep - pad, (y + 1) * vStep - pad)
|
||||
|
Loading…
x
Reference in New Issue
Block a user