@@ -29,10 +29,14 @@ public final class ImGui {
29
29
private static final ImDrawList BACKGROUND_DRAW_LIST ;
30
30
private static final ImDrawList FOREGROUND_DRAW_LIST ;
31
31
private static final ImGuiStorage IMGUI_STORAGE ;
32
+ private static final ImGuiViewport WINDOW_VIEWPORT ;
33
+ private static final ImGuiViewport FIND_VIEWPORT ;
32
34
33
35
private static ImDrawData drawData ;
34
36
private static ImFont font ;
35
37
private static ImGuiStyle style ;
38
+ private static ImGuiViewport mainViewport ;
39
+ private static ImGuiPlatformIO platformIO ;
36
40
37
41
static {
38
42
final String libPath = System .getProperty (LIB_PATH_PROP );
@@ -54,9 +58,12 @@ public final class ImGui {
54
58
BACKGROUND_DRAW_LIST = new ImDrawList (0 );
55
59
FOREGROUND_DRAW_LIST = new ImDrawList (0 );
56
60
IMGUI_STORAGE = new ImGuiStorage (0 );
61
+ WINDOW_VIEWPORT = new ImGuiViewport (0 );
62
+ FIND_VIEWPORT = new ImGuiViewport (0 );
57
63
58
64
nInitJni ();
59
65
ImFontAtlas .nInit ();
66
+ ImGuiPlatformIO .init ();
60
67
nInitInputTextData ();
61
68
}
62
69
@@ -494,6 +501,18 @@ public static ImDrawList getWindowDrawList() {
494
501
return ImGui::GetWindowDpiScale();
495
502
*/
496
503
504
+ /**
505
+ * Get viewport currently associated to the current window.
506
+ */
507
+ public static ImGuiViewport getWindowViewport () {
508
+ WINDOW_VIEWPORT .ptr = nGetWindowViewport ();
509
+ return WINDOW_VIEWPORT ;
510
+ }
511
+
512
+ private static native long nGetWindowViewport (); /*
513
+ return (intptr_t)ImGui::GetWindowViewport();
514
+ */
515
+
497
516
/**
498
517
* Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
499
518
*/
@@ -4918,6 +4937,32 @@ public static ImDrawList getForegroundDrawList() {
4918
4937
return (intptr_t)ImGui::GetForegroundDrawList();
4919
4938
*/
4920
4939
4940
+ /**
4941
+ * Get background draw list for the given viewport.
4942
+ * This draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
4943
+ */
4944
+ public static ImDrawList getBackgroundDrawList (ImGuiViewport viewport ) {
4945
+ BACKGROUND_DRAW_LIST .ptr = nGetBackgroundDrawList (viewport .ptr );
4946
+ return BACKGROUND_DRAW_LIST ;
4947
+ }
4948
+
4949
+ private static native long nGetBackgroundDrawList (long viewportPtr ); /*
4950
+ return (intptr_t)ImGui::GetBackgroundDrawList((ImGuiViewport*)viewportPtr);
4951
+ */
4952
+
4953
+ /**
4954
+ * Get foreground draw list for the given viewport.
4955
+ * This draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents.
4956
+ */
4957
+ public static ImDrawList getForegroundDrawList (ImGuiViewport viewport ) {
4958
+ BACKGROUND_DRAW_LIST .ptr = nGetForegroundDrawList (viewport .ptr );
4959
+ return BACKGROUND_DRAW_LIST ;
4960
+ }
4961
+
4962
+ private static native long nGetForegroundDrawList (long viewportPtr ); /*
4963
+ return (intptr_t)ImGui::GetBackgroundDrawList((ImGuiViewport*)viewportPtr);
4964
+ */
4965
+
4921
4966
// TODO GetDrawListSharedData
4922
4967
4923
4968
/**
@@ -5378,4 +5423,72 @@ public static ImGuiStorage getStateStorage() {
5378
5423
public static native String saveIniSettingsToMemory (long outIniSize ); /*
5379
5424
return env->NewStringUTF(ImGui::SaveIniSettingsToMemory((size_t*)&outIniSize));
5380
5425
*/
5426
+
5427
+ // (Optional) Platform/OS interface for multi-viewport support
5428
+ // Read comments around the ImGuiPlatformIO structure for more details.
5429
+ // Note: You may use GetWindowViewport() to get the current viewport of the current window.
5430
+
5431
+ /**
5432
+ * Platform/renderer functions, for back-end to setup + viewports list.
5433
+ */
5434
+ public static ImGuiPlatformIO getPlatformIO () {
5435
+ if (platformIO == null ) {
5436
+ platformIO = new ImGuiPlatformIO (nGetPlatformIO ());
5437
+ }
5438
+ return platformIO ;
5439
+ }
5440
+
5441
+ private static native long nGetPlatformIO (); /*
5442
+ return (intptr_t)ImGui::GetMainViewport();
5443
+ */
5444
+
5445
+ /**
5446
+ * Main viewport. Same as GetPlatformIO().MainViewport == GetPlatformIO().Viewports[0].
5447
+ */
5448
+ public static ImGuiViewport getMainViewport () {
5449
+ if (mainViewport == null ) {
5450
+ mainViewport = new ImGuiViewport (nGetMainViewport ());
5451
+ }
5452
+ return mainViewport ;
5453
+ }
5454
+
5455
+ private static native long nGetMainViewport (); /*
5456
+ return (intptr_t)ImGui::GetMainViewport();
5457
+ */
5458
+
5459
+ /**
5460
+ * Call in main loop. Will call CreateWindow/ResizeWindow/etc. Platform functions for each secondary viewport, and DestroyWindow for each inactive viewport.
5461
+ */
5462
+ public static native void updatePlatformWindows (); /*
5463
+ ImGui::UpdatePlatformWindows();
5464
+ */
5465
+
5466
+ /**
5467
+ * Call in main loop. will call RenderWindow/SwapBuffers platform functions for each secondary viewport which doesn't have the ImGuiViewportFlags_Minimized flag set.
5468
+ * May be reimplemented by user for custom rendering needs.
5469
+ */
5470
+ public static native void renderPlatformWindowsDefault (); /*
5471
+ ImGui::RenderPlatformWindowsDefault();
5472
+ */
5473
+
5474
+ /**
5475
+ * Call DestroyWindow platform functions for all viewports.
5476
+ * Call from back-end Shutdown() if you need to close platform windows before imgui shutdown.
5477
+ * Otherwise will be called by DestroyContext().
5478
+ */
5479
+ public static native void destroyPlatformWindows (); /*
5480
+ ImGui::DestroyPlatformWindows();
5481
+ */
5482
+
5483
+ /**
5484
+ * This is a helper for back-ends.
5485
+ */
5486
+ public static ImGuiViewport findViewportByID (int imGuiID ) {
5487
+ FIND_VIEWPORT .ptr = nFindViewportByID (imGuiID );
5488
+ return FIND_VIEWPORT ;
5489
+ }
5490
+
5491
+ private static native long nFindViewportByID (int imGuiID ); /*
5492
+ return (intptr_t)ImGui::FindViewportByID(imGuiID);
5493
+ */
5381
5494
}
0 commit comments