fix font render with Angelica 2.1.x#184
Open
PinkYuDeer wants to merge 6 commits intoGTNewHorizons:masterfrom
Open
fix font render with Angelica 2.1.x#184PinkYuDeer wants to merge 6 commits intoGTNewHorizons:masterfrom
PinkYuDeer wants to merge 6 commits intoGTNewHorizons:masterfrom
Conversation
Author
Yes. Fixed. I create a release here
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Fixes garbled text on OpenComputers screens (and in Drone/Robot GUIs, manual code segments) when Angelica 2.x is installed. Replaces the legacy immediate-mode + display-list text rendering path with
Tessellator, which is compatible with Angelica's modernized pipeline.Solve GTNewHorizons/Angelica#1661
Problem
After installing Angelica 2.0+, any text drawn on the OC screen that contains Chinese or other characters but is not displayed in CP437 encoding may appear as garbled characters. The "wrong" characters visibly come from the CP437 / basic ASCII set (the same set stored in
assets/opencomputers/textures/font/chars.txt), so the symptom looks like UVs are being rebound to random cells of the font atlas. Uninstalling Angelica, or rolling back to Angelica < 2.0, makes the problem disappear.Root cause
The screen text renderer relied on three legacy GL paths that Angelica 2.x no longer supports correctly:
Immediate mode —
TextureFontRenderer.drawBuffer/drawStringand their backends (StaticFontRenderer.drawChar,DynamicFontRenderer.CharIcon.draw) usedglBegin(GL_QUADS)with per-vertexglTexCoord2d/glColor3ub/glVertex3d. Under Angelica's shader-based pipeline these per-vertex attributes are no longer forwarded throughgl_TexCoord/gl_Color, so UVs end up undefined or stuck on a single atlas cell.Display lists —
TextBufferRenderCachewrapped each per-screen draw inglNewList(list, GL_COMPILE_AND_EXECUTE)/glCallList(list)and reused the compiled list on subsequent frames. Angelica does not capture/replay legacy vertex attribute state through display lists, so non-dirty frames replay a partially-correct state machine.Raw
glBindTexturefor dynamically-generated atlases —DynamicFontRenderer.CharTexturebypasses Minecraft'sTextureManagerand binds atlas textures directly viaglGenTextures/glBindTexture. On its own this is fine, but combined with (1) and (2) it amplifies the failure: the texture is bound but nothing correctly samples it.Because
DynamicFontRenderer.initialize()pre-populates the first atlas withbasicChars(the CP437 set, identical tochars.txt), the corrupted UVs sample glyphs from that atlas — which is why the garbled output visibly looks likechars.txtcharacters.Fix
Port the entire screen-text rendering path from immediate mode + display lists to
Tessellator, which is the same vertex-buffer path used by vanilla TESRs and block rendering, and which Angelica must (and does) support.Changes
client/renderer/font/TextureFontRenderer.scaladrawBuffer,drawString, anddrawQuadrewritten to useTessellator.startDrawingQuads()/addVertex(WithUV)/setColorOpaque_I/draw(). Added adrawString(s, x, y, color)overload so callers can pass a color through the vertex stream instead of relying on externalglColor4fstate.client/renderer/font/StaticFontRenderer.scaladrawCharnow emits viaTessellator.addVertexWithUV.client/renderer/font/DynamicFontRenderer.scalaCharIcon.drawnow emits viaTessellator.addVertexWithUV.client/renderer/TextBufferRenderCache.scalaCallable/RemovalListener/ Guava cache /@SubscribeEvent onTickare all gone). Eachrender()call now: (a) generates missing glyphs if the buffer isdirty, then (b) callsrenderer.drawBufferdirectly every frame. The dirty flag still guards glyph generation (the only actually expensive step — GPU texture uploads).client/Proxy.scalaFMLCommonHandler.instance.bus.register(TextBufferRenderCache).client/renderer/markdown/segment/CodeSegment.scalaglColor4f(0.75f, 0.8f, 1, 1)with a color argument passed through the newdrawStringoverload, so the tint survives Angelica's pipeline.DynamicFontRenderer.CharTexture's rawglGenTextures/glBindTexturecalls are kept as-is: once drawing goes throughTessellator, the texture that is currently bound toGL_TEXTURE_2Datdraw()time is sampled correctly, the same way every other TESR in the game works.Performance notes
The previous code cached a compiled display list per
TextBufferRenderDataand replayed it on non-dirty frames. That cache is gone because it was the display list — the exact construct Angelica breaks — so it could not be kept.What remains behind the
dirtyflag is the expensive part: glyph generation (generateChars), which uploads new glyphs to the GPU atlas viaglTexSubImage2D. On clean frames we now re-walk the buffer and re-feedTessellatorinstead of replaying a compiled list. For a worst-case T3 screen (160x50 = 8000 cells) this is ~32k vertices per frame — well within normal TESR budgets, and negligible compared to a single vanilla chunk batch.If this later shows up in profiles, two Angelica-safe caching strategies are available as follow-ups (not included here to keep the fix minimal and data-driven):
Tessellator's raw vertexByteBufferon dirty frames and re-upload it on clean frames (saves the Scala loop + per-vertex method calls).glDrawArraysevery frame (requires reintroducing resource-lifetime management similar to the oldRemovalListener).Scope / Non-goals
client/renderer/gui/BufferRenderer.scalastill uses a display list + immediate mode to draw the GUI border frame around screens. It's a separate code path that does not exhibit the reported garbling (no per-char UV mapping, no per-quad color changes, and it's static), so it is intentionally left alone for this PR. It can be migrated in a follow-up if needed.Testing
./gradlew compileScala— BUILD SUCCESSFUL.CodeSegment) render in the expected light-blue tint.