Last active
December 19, 2019 15:26
-
-
Save zeroeightysix/d8bd103b998893f1dd7e3c3f23641fba to your computer and use it in GitHub Desktop.
This file contains 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
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