11package imgui ;
22
33import glm_ .vec2 .Vec2 ;
4+ import glm_ .vec2 .Vec2i ;
45import glm_ .vec4 .Vec4 ;
56import imgui .impl .LwjglGL3 ;
7+ import kotlin .Unit ;
68import org .lwjgl .opengl .GL ;
79import uno .glfw .GlfwWindow ;
8- import static imgui .impl .CommonKt .setGlslVersion ;
910
1011import static org .lwjgl .opengl .GL11 .GL_COLOR_BUFFER_BIT ;
1112import static org .lwjgl .opengl .GL11 .glClear ;
13+ import static org .lwjgl .system .MemoryUtil .NULL ;
1214
1315public class Test_lwjgl {
1416
@@ -24,6 +26,14 @@ public static void main(String[] args) {
2426 private ImGui imgui = ImGui .INSTANCE ;
2527 private IO io ;
2628
29+
30+ private float [] f = {0f };
31+ private Vec4 clearColor = new Vec4 (0.45f , 0.55f , 0.6f , 1f );
32+ private boolean [] showAnotherWindow = {false };
33+ private boolean [] showDemo = {true };
34+ private int [] counter = {0 };
35+
36+
2737 public void run () {
2838
2939 init ();
@@ -59,7 +69,10 @@ public void run() {
5969// Font font = io.getFonts().addFontFromFileTTF("misc/fonts/ArialUni.ttf", 18f, new FontConfig(), io.getFonts().getGlyphRangesJapanese());
6070// assert (font != null);
6171
62- while (window .isOpen ()) loop ();
72+ window .loop (() -> {
73+ loop ();
74+ return Unit .INSTANCE ;
75+ });
6376
6477 lwjglGL3 .shutdown ();
6578 ContextKt .destroy (ctx );
@@ -73,11 +86,11 @@ private void init() {
7386 windowHint .getContext ().setVersion ("3.2" );
7487 windowHint .setProfile ("core" );
7588
76- window = new GlfwWindow (1280 , 720 , "ImGui Lwjgl OpenGL3 example" );
89+ window = new GlfwWindow (1280 , 720 , "ImGui Lwjgl OpenGL3 example" , NULL , new Vec2i ( Integer . MIN_VALUE ), true );
7790
7891 window .makeContextCurrent ();
7992 glfw .setSwapInterval (1 ); // Enable vsync
80- window .show ();
93+ window .show (true );
8194
8295 /* This line is critical for LWJGL's interoperation with GLFW's OpenGL context, or any context that is
8396 managed externally.
@@ -86,11 +99,6 @@ private void init() {
8699 GL .createCapabilities ();
87100 }
88101
89- private float [] f = {0f };
90- private Vec4 clearColor = new Vec4 (0.45f , 0.55f , 0.6f , 1f );
91- private boolean [] showAnotherWindow = {false };
92- private boolean [] showDemo = {true };
93- private int [] counter = {0 };
94102
95103 private void loop () {
96104
@@ -100,7 +108,6 @@ private void loop() {
100108 - when Io.wantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
101109 Generally you may always pass all inputs to dear imgui, and hide them from your application based on those
102110 two flags. */
103- glfw .pollEvents ();
104111 lwjglGL3 .newFrame ();
105112
106113
@@ -144,7 +151,6 @@ private void loop() {
144151
145152 imgui .render ();
146153 lwjglGL3 .renderDrawData (imgui .getDrawData ());
147- window .swapBuffers ();
148154
149155 gln .GlnKt .checkError ("loop" , true ); // TODO remove
150156 }
0 commit comments