Skip to content

Commit 951fde8

Browse files
committed
Font texture fix
1 parent 1dab763 commit 951fde8

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

common/src/main/kotlin/com/lambda/graphics/renderer/gui/font/FontRenderer.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@ class FontRenderer(
5656
val subText = emojis.asReversed().fold(text) { acc, (
5757
charInfo, start, end
5858
) ->
59-
val emojiWidth = charInfo.size.x * actualScale
60-
val emojiHeight = charInfo.size.y * actualScale
59+
val emojiSize = charInfo.size * actualScale
6160

6261
val startPos = Vec2d(posX, posY)
63-
val endPos = startPos + Vec2d(emojiWidth, emojiHeight)
62+
val endPos = startPos + emojiSize
6463

6564
putChar(position, startPos, endPos, color, charInfo)
6665

67-
posX += emojiWidth + scaledGap
66+
posX += emojiSize.x + scaledGap
6867

6968
acc.replaceRange(start, end, " ")
7069
}
@@ -142,8 +141,6 @@ class FontRenderer(
142141
shader.use()
143142

144143
font.glyphs.bind()
145-
shader["u_FontTexture"] = 0
146-
147144
emojis.glyphs.bind()
148145
shader["u_EmojiTexture"] = 1
149146

common/src/main/kotlin/com/lambda/graphics/texture/Texture.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ abstract class Texture {
1414

1515
protected abstract fun init()
1616

17-
open fun bind(slot: Int = 0) = bindTexture(id)
17+
open fun bind(slot: Int = 0) = bindTexture(id, slot)
1818

1919
override fun equals(other: Any?): Boolean {
2020
if (this === other) return true

common/src/main/resources/assets/lambda/shaders/fragment/renderer/font.frag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void main() {
1414
if (v_TexCoord.x > 0.0) {
1515
tex = texture(u_FontTexture, v_TexCoord);
1616
} else {
17-
tex = texture(u_EmojiTexture, v_TexCoord);
17+
tex = texture(u_EmojiTexture, -v_TexCoord);
1818
}
1919

2020
color = tex * v_Color;

0 commit comments

Comments
 (0)