Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Frames and text become black blocks in minecraft #235

Open
tumuidle opened this issue Jul 3, 2024 · 0 comments
Open

Bug: Frames and text become black blocks in minecraft #235

tumuidle opened this issue Jul 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@tumuidle
Copy link

tumuidle commented Jul 3, 2024

Version

1.86.11

What happened?

Frames and text become black blocks in Minecraft MCP 1.21 when using custom fonts
image

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)
@tumuidle tumuidle added the bug Something isn't working label Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant