|
3 | 3 | package org.polyfrost.oneconfig.api.ui.v1.internal |
4 | 4 |
|
5 | 5 | import dev.deftu.omnicore.api.client.render.GlCapabilities |
| 6 | +import dev.deftu.omnicore.api.client.render.OmniResolution |
6 | 7 | import dev.deftu.omnicore.api.client.render.OmniTextRenderer |
7 | 8 | import dev.deftu.omnicore.api.client.render.stack.OmniPoseStack |
8 | 9 | import dev.deftu.omnicore.api.color.OmniColor |
9 | | -import dev.deftu.omnicore.api.math.OmniMatrix3f |
| 10 | +import dev.deftu.omnicore.api.math.OmniMatrix4f |
10 | 11 | import dev.deftu.omnicore.internal.client.render.shader.ShaderInternals |
11 | 12 | import org.apache.logging.log4j.LogManager |
12 | 13 | import org.lwjgl.BufferUtils |
@@ -641,11 +642,21 @@ class GLRendererImpl(private val nsvg: NanoSvgApi, private val stb: StbApi) : Re |
641 | 642 | count += 1 |
642 | 643 | } |
643 | 644 |
|
| 645 | + private fun FloatArray.getScaledMat4(): OmniMatrix4f { |
| 646 | + // asm: scale to MC instance coordinates and mutate to a 4x4 matrix |
| 647 | + val sf = pixelRatio / OmniResolution.scaleFactor.toFloat() |
| 648 | + return OmniMatrix4f.from(floatArrayOf( |
| 649 | + this[0] * sf, this[1] * sf, 0f, 0f, |
| 650 | + this[3] * sf, this[4] * sf, 0f, 0f, |
| 651 | + 0f, 0f, 1f, 0f, |
| 652 | + this[6] * sf, this[7] * sf, 0f, 1f |
| 653 | + )) |
| 654 | + } |
| 655 | + |
644 | 656 | override fun text(font: Font, x: Float, y: Float, text: String, color: Color, fontSize: Float) { |
645 | 657 | if (font === UIManager.INSTANCE.mcFont) { |
646 | 658 | val ctx = UIManager.INSTANCE.renderingContext |
647 | | - // todo hi deftu https://github.com/Deftu/OmniCore/issues/57 |
648 | | - ctx.pose.push(OmniPoseStack.Entry(ctx.pose.current.positionMatrix, OmniMatrix3f.from(transform))) |
| 659 | + ctx.pose.push(OmniPoseStack.Entry(transform.getScaledMat4(), ctx.pose.current.normalMatrix)) |
649 | 660 | // asm: can be optimized by https://github.com/Deftu/OmniCore/issues/58 |
650 | 661 | OmniTextRenderer.render(ctx.pose, text, x, y, OmniColor.argb(color.argb), false) |
651 | 662 | ctx.pose.pop() |
|
0 commit comments