Skip to content
New issue

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

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

Already on GitHub? # to your account

Index 33619455 out of bounds for length 0 #181

Open
damp11113 opened this issue Oct 28, 2022 · 1 comment
Open

Index 33619455 out of bounds for length 0 #181

damp11113 opened this issue Oct 28, 2022 · 1 comment

Comments

@damp11113
Copy link

I use imgui for minecraft

java.lang.IndexOutOfBoundsException: Index 33619455 out of bounds for length 0
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
	at java.base/java.util.Objects.checkIndex(Objects.java:359)
	at java.base/java.nio.Buffer.checkIndex(Buffer.java:741)
	at java.base/java.nio.DirectByteBuffer.put(DirectByteBuffer.java:362)
	at kool.Buffers_operatorsKt.set(buffers operators.kt:25)
	at imgui.font.FontAtlas.buildRender1bppRectFromString(FontAtlas.kt:949)
	at imgui.font.FontAtlas.buildRenderDefaultTexData(FontAtlas.kt:968)
	at imgui.font.FontAtlas.buildFinish(FontAtlas.kt:906)
	at imgui.font.FontAtlas.buildWithStbTrueType(FontAtlas.kt:841)
	at imgui.font.FontAtlas.build(FontAtlas.kt:202)
	at imgui.font.FontAtlas.getTexDataAsAlpha8(FontAtlas.kt:212)
	at imgui.font.FontAtlas.getTexDataAsRGBA32(FontAtlas.kt:222)
	at imgui.impl.gl.ImplGL3.createFontsTexture(ImplGL3.kt:225)
	at imgui.impl.gl.ImplGL3.createDeviceObjects(ImplGL3.kt:275)
	at imgui.impl.gl.ImplGL3.newFrame(ImplGL3.kt:61)
	at com.damp11113.devtools.HudImgui.onHudRender(HudImgui.java:43)
	at net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback.lambda$static$0(HudRenderCallback.java:27)
	at net.minecraft.client.gui.hud.InGameHud.handler$zgi000$render(InGameHud.java:1496)
	at net.minecraft.client.gui.hud.InGameHud.render(InGameHud.java:393)
	at net.minecraft.client.render.GameRenderer.render(GameRenderer.java:862)
	at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:1177)
	at net.minecraft.client.MinecraftClient.run(Unknown Source)
	at net.minecraft.client.main.Main.main(Main.java:244)
	at net.minecraft.client.main.Main.main(Main.java:51)
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:461)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
	at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)

This is code

public class HudImgui implements HudRenderCallback {
    private static ImGui imgui = ImGui.INSTANCE;

    private static ImplGL3 implGl3;
    private static ImplGlfw implGlfw;

    private static IO ImGuiIO;
    private static HashSet<Integer> keyBuffer = new HashSet<Integer>();

    // Initialization for imgui.
    static {
        ImguiKt.MINECRAFT_BEHAVIORS = true;
        GlfwWindow window = GlfwWindow.from(MinecraftClient.getInstance().getWindow().getHandle());
        window.makeContextCurrent();

        new Context();
        implGlfw = new ImplGlfw(window, false, null);
        implGl3 = new ImplGL3();
    }

    @Override
    public void onHudRender(MatrixStack matrixStack, float tickDelta) {
        ImGuiIO = imgui.getIo();

        implGl3.newFrame();
        implGlfw.newFrame();
        imgui.newFrame();

        imgui.showDemoWindow(new boolean[]{true});

        imgui.render();
        implGl3.renderDrawData(Objects.requireNonNull(imgui.getDrawData()));
    }
}
@elect86
Copy link
Collaborator

elect86 commented Nov 3, 2022

Sorry for the delay, I just updated it, could you give it a try?

implementation("kotlin.graphics:imgui-core:1.79+05")
implementation("kotlin.graphics:imgui-gl:1.79+05")
implementation("kotlin.graphics:imgui-glfw:1.79+05")

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants