diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Font.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Font.kt index 9c98a301..12f234ce 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Font.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/Font.kt @@ -212,19 +212,23 @@ class Font( model.translate(x = -lineWidth - movedX, y = lineHeight) } - client.programs.font.use() - client.programs.font.colorMultiplier = color - client.programs.font.worldMatrix = client.stack.last() + builder.end() - builder.upload(vbo, ebo, GL_STREAM_DRAW) + if (builder.elementCount != 0) { + client.programs.font.use() + client.programs.font.colorMultiplier = color + client.programs.font.worldMatrix = client.stack.last() - client.activeTexture = 0 - atlas.bind() + builder.upload(vbo, ebo, GL_STREAM_DRAW) - client.vao = vao - glDrawElements(GL_TRIANGLES, builder.indexCount, builder.indexType, 0L) - checkForGLError() - client.vao = null + client.activeTexture = 0 + atlas.bind() + + client.vao = vao + glDrawElements(GL_TRIANGLES, builder.indexCount, builder.indexType, 0L) + checkForGLError() + client.vao = null + } return TextSize(totalX * scale, totalY * scale) } @@ -261,10 +265,8 @@ class Font( if (chr == '\t') { if (lineGlyphs % 4 == 0) { lineWidth += space.advanceX * 4 - client.stack.last().translate(x = space.advanceX * 4) } else { lineWidth += space.advanceX * (lineGlyphs % 4) - client.stack.last().translate(x = space.advanceX * (lineGlyphs % 4)) } lineGlyphs += lineGlyphs % 4