imgui-java
imgui-java copied to clipboard
Bug: Frames and text become black blocks in minecraft
Version
1.86.11
What happened?
Frames and text become black blocks in Minecraft MCP 1.21 when using custom fonts
Reproduction
Initialize called after game window initialized
createContext()
ctx = getCurrentContext()
val io = getIO()
glfw.init(window, false)
gl3.init()
val fontAtlas = io.fonts
val fontConfig = ImFontConfig()
fontConfig.glyphRanges = fontAtlas.glyphRangesChineseFull
fontConfig.mergeMode = true
fontConfig.pixelSnapH = true
fontAtlas.addFontDefault(fontConfig)
fontAtlas.addFontFromMemoryTTF(loadResource("assets/h3x/NotoSansSC-Medium.otf")!!, 14f, fontConfig, fontAtlas.glyphRangesChineseFull)
fontAtlas.build()
fontConfig.destroy()
Render called after a GLFW.glfwPollEvents() call and before GLFW.glfwSwapBuffers
fun render(window: Long) {
glfw.newFrame()
newFrame()
if (begin("test", ImGuiWindowFlags.MenuBar)) {
text("test")
}
end()
render()
MemoryStack.stackPush().use {
val dw = it.mallocInt(1)
val dh = it.mallocInt(1)
GLFW.glfwGetFramebufferSize(window, dw, dh)
RenderSystem.viewport(0, 0, dw.get(), dh.get())
}
gl3.renderDrawData(getDrawData())
updatePlatformWindows()
renderPlatformWindowsDefault()
}
loadResource method
fun loadResource(path: String) = Main.javaClass.classLoader.getResourceAsStream(path)?.readBytes()
Relevant log output
No error in log except an asset (icons/icon_16x16.png) does not exists in MCP environment(its normal)