26
26
27
27
@ SuppressWarnings ("MagicNumber" )
28
28
public final class ImGuiGlfwExample {
29
- private static final int DEFAULT_WIDTH = 1024 ;
29
+ private static final int DEFAULT_WIDTH = 1280 ;
30
30
private static final int DEFAULT_HEIGHT = 768 ;
31
31
32
32
private long window ; // current GLFW window pointer
@@ -80,7 +80,6 @@ private void initGlfw() {
80
80
glfwWindowHint (GLFW_VISIBLE , GLFW_FALSE ); // the window will stay hidden after creation
81
81
glfwWindowHint (GLFW_RESIZABLE , GLFW_TRUE ); // the window will be resizable
82
82
glfwWindowHint (GLFW_MAXIMIZED , GLFW_TRUE ); // the window will be maximized
83
- glfwWindowHint (GLFW_DECORATED , GLFW_TRUE ); // the window will be decorated
84
83
85
84
// Create the window
86
85
window = glfwCreateWindow (DEFAULT_WIDTH , DEFAULT_HEIGHT , "ImGui+GLFW+LWJGL Example" , NULL , NULL );
@@ -249,22 +248,18 @@ private void loop() {
249
248
glfwSetCursor (window , mouseCursors [imguiCursor ]);
250
249
glfwSetInputMode (window , GLFW_CURSOR , GLFW_CURSOR_NORMAL );
251
250
252
- // Render itself starts here
253
- glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // clear the framebuffer
251
+ // Clear the framebuffer
252
+ glClear (GL_COLOR_BUFFER_BIT );
254
253
255
254
// IMPORTANT!!
256
255
// Any ImGui code SHOULD go between NewFrame()/Render() methods
257
256
ImGui .newFrame ();
258
- showUi ();
259
- ImGui .end ();
260
-
261
- if (showDemoWindow .get ()) {
262
- ImGui .showDemoWindow (showDemoWindow );
263
- }
264
-
257
+ showUi (); // ImGui calls goes here
265
258
ImGui .render ();
266
259
267
- imGuiGl3 .render (ImGui .getDrawData ()); // render DrawData from ImGui into our OpenGL context
260
+ // After ImGui#render call we provide draw data into LWJGL3 render.
261
+ // At that moment ImGui will be rendered to the current OpenGL context.
262
+ imGuiGl3 .render (ImGui .getDrawData ());
268
263
269
264
glfwSwapBuffers (window ); // swap the color buffers
270
265
@@ -277,7 +272,7 @@ private void showUi() {
277
272
ImGui .setNextWindowSize (600 , 300 , ImGuiCond .Once );
278
273
ImGui .setNextWindowPos (10 , 10 , ImGuiCond .Once );
279
274
280
- ImGui .begin ("Custom window" );
275
+ ImGui .begin ("Custom window" ); // Start Custom window
281
276
ImGui .text ("Hello from Java!" );
282
277
283
278
ImGui .button ("Drag me" );
@@ -324,6 +319,12 @@ private void showUi() {
324
319
if (ImGui .button ("Copy" )) {
325
320
ImGui .setClipboardText (imguiDemoLink );
326
321
}
322
+
323
+ ImGui .end (); // End Custom window
324
+
325
+ if (showDemoWindow .get ()) {
326
+ ImGui .showDemoWindow (showDemoWindow );
327
+ }
327
328
}
328
329
329
330
// If you want to clean a room after yourself - do it by yourself
0 commit comments