Skip to content

Commit 677d038

Browse files
committed
fixed
1 parent 3562ec6 commit 677d038

File tree

5 files changed

+27
-25
lines changed

5 files changed

+27
-25
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies {
3333

3434
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
3535

36-
implementation 'com.github.kotlin-graphics:uno-sdk:1cef9449254e9e3b49dad569cd5f9161b573d83c'
36+
implementation 'com.github.kotlin-graphics:uno-sdk:4f00f5f4a69720be1906f88305d190280da04fb1'
3737

3838
testImplementation 'io.kotlintest:kotlintest-runner-junit5:3.0.6'
3939

imgui.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
[Window][ImGui Demo]
2-
Pos=650,20
3-
Size=550,680
4-
Collapsed=0
5-
61
[Window][Debug##Default]
72
Pos=60,60
83
Size=400,400
94
Collapsed=0
105

6+
[Window][ImGui Demo]
7+
Pos=650,20
8+
Size=550,680
9+
Collapsed=0
10+

src/main/kotlin/imgui/impl/LwjglGL3.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import org.lwjgl.opengl.GL20.*
2929
import org.lwjgl.opengl.GL30.*
3030
import org.lwjgl.opengl.GL33.GL_SAMPLER_BINDING
3131
import org.lwjgl.opengl.GL33.glBindSampler
32-
import uno.buffer.intBufferBig
3332
import uno.glfw.GlfwWindow
3433
import uno.glfw.glfw
3534

@@ -151,7 +150,7 @@ object LwjglGL3 {
151150
// Update gamepad inputs
152151
val buttons = window.getJoystickButtons(GLFW_JOYSTICK_1)!!
153152
val buttonsCount = buttons.capacity()
154-
val axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1)!!
153+
val axes = window.getJoystickAxes(GLFW_JOYSTICK_1)!!
155154
val axesCount = axes.capacity()
156155
fun mapButton(nav: NavInput, button: Int) {
157156
if (buttonsCount > button && buttons[button] == GLFW_PRESS.b)

src/test/java/imgui/Test_lwjgl.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package imgui;
22

33
import glm_.vec2.Vec2;
4+
import glm_.vec2.Vec2i;
45
import glm_.vec4.Vec4;
56
import imgui.impl.LwjglGL3;
7+
import kotlin.Unit;
68
import org.lwjgl.opengl.GL;
79
import uno.glfw.GlfwWindow;
8-
import static imgui.impl.CommonKt.setGlslVersion;
910

1011
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
1112
import static org.lwjgl.opengl.GL11.glClear;
13+
import static org.lwjgl.system.MemoryUtil.NULL;
1214

1315
public 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
}

src/test/kotlin/imgui/test lwjgl.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import glm_.vec4.Vec4
66
import gln.checkError
77
import gln.glClearColor
88
import gln.glViewport
9-
import imgui.functionalProgramming.button
109
import imgui.impl.LwjglGL3
11-
import imgui.impl.glslVersion
10+
import org.lwjgl.glfw.GLFW.glfwSwapBuffers
1211
import org.lwjgl.opengl.GL
1312
import org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT
1413
import org.lwjgl.opengl.GL11.glClear
@@ -77,7 +76,7 @@ class HelloWorld_lwjgl {
7776
// val a = IO.fonts.addFontFromFileTTF("misc/fonts/ArialUni.ttf", 18f)!!
7877
// val b = IO.fonts.addFontFromFileTTF("misc/fonts/ArialUni.ttf", 30f)!!
7978

80-
while (window.isOpen) loop()
79+
window.loop(this::loop)
8180

8281
LwjglGL3.shutdown()
8382
ctx.destroy()
@@ -100,7 +99,6 @@ class HelloWorld_lwjgl {
10099
- when Io.wantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
101100
Generally you may always pass all inputs to dear imgui, and hide them from your application based on those
102101
two flags. */
103-
glfw.pollEvents()
104102
LwjglGL3.newFrame()
105103

106104
with(ImGui) {
@@ -151,8 +149,7 @@ class HelloWorld_lwjgl {
151149

152150
ImGui.render()
153151
LwjglGL3.renderDrawData(ImGui.drawData!!)
154-
window.swapBuffers()
155152

156-
checkError("loop") // TODO remove
153+
checkError("loop") // TODO remove in production
157154
}
158155
}

0 commit comments

Comments
 (0)