Skip to content

Instantly share code, notes, and snippets.

@zeroeightysix
Last active December 19, 2019 15:26
Show Gist options
  • Save zeroeightysix/d8bd103b998893f1dd7e3c3f23641fba to your computer and use it in GitHub Desktop.
Save zeroeightysix/d8bd103b998893f1dd7e3c3f23641fba to your computer and use it in GitHub Desktop.
public class MinecraftScreen extends Screen {
private ImGui imgui = ImGui.INSTANCE;
private ImplGL3 implGl3;
private ImplGlfw implGlfw;
private boolean[] showDemoWindow = new boolean[] { false };
public KamiGuiScreen() {
super(new LiteralText("Imgui")); // The title of this screen
setup();
}
private void setup() {
ImguiKt.MINECRAFT_BEHAVIORS = true;
GlfwWindow window = GlfwWindow.from(MinecraftClient.getInstance().window.getHandle());
window.makeContextCurrent();
new Context();
implGlfw = new ImplGlfw(window, false, null);
implGl3 = new ImplGL3();
}
/*
* This method is called from another class when the player wishes to reload the GUI using an ingame command.
*/
public void reload() {
implGl3 = new ImplGL3();
}
@Override
public void render(int x, int y, float partialTicks) {
implGl3.newFrame();
implGlfw.newFrame();
imgui.newFrame();
imgui.text("Hello world!");
if (imgui.button("Open demo window", new Vec2())) {
showDemoWindow[0] = true;
}
if (showDemoWindow[0]) {
imgui.showDemoWindow(showDemoWindow);
}
imgui.render();
implGl3.renderDrawData(imgui.getDrawData());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment