Skip to content

Commit c14d2a3

Browse files
committed
[Doc] Readme about multi-viewports
1 parent 13c3a28 commit c14d2a3

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ JNI based binding for [Dear ImGui](https://github.com/ocornut/imgui) with no dep
66
Please read **Binding Notice** to get more info about java-specific things of the API.<br>
77
See official [documentation](https://github.com/ocornut/imgui#usage) and [wiki](https://github.com/ocornut/imgui/wiki) to get more info about how to do things in Dear ImGui.
88

9-
Binding provides all the data you need to render Dear ImGui. If, for some reason, you want to use your own backend renderer, see how [ImGuiImplGl3](https://github.com/SpaiR/imgui-java/blob/v1.77-0.17.2/imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java) for reference.
9+
Binding provides all the data you need to render Dear ImGui. If, for some reason, you want to use your own backend renderer, see [ImGuiImplGl3](https://github.com/SpaiR/imgui-java/blob/v1.77-0.17.2/imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java) for reference.
1010

1111
Versioning semantic of the binding: `imguiVersion-bindingVersion`.<br>
1212
For example `1.74-0.1` means that imgui-java uses `1.74` version of Dear ImGui and binding itself has the version `0.1`.
1313

1414
Additional available features:
15-
- [Docking API](#using-docking)
15+
- [Multi-Viewports/Docking API](#using-multi-viewports-and-docking)
1616
- [FreeType font renderer](#using-freetype)
1717

1818
## How to Try
@@ -224,12 +224,14 @@ If you're using native libs directly, you'll need to provide a VM option: `imgui
224224

225225
**You are ready to use imgui-java binding!**
226226

227-
## Using Docking
227+
## Using Multi-Viewports and Docking
228228
Binding based on the Dear ImGui [docking](https://github.com/ocornut/imgui/tree/docking) branch, commit: [90ea7e2f2f3c4096a58b8bd14c274d80ae63e1ce](https://github.com/ocornut/imgui/tree/90ea7e2f2f3c4096a58b8bd14c274d80ae63e1ce).
229229
That branch contains two important features: [multi-viewports](https://github.com/ocornut/imgui/issues/1542) and [docking](https://github.com/ocornut/imgui/issues/2109).
230+
See an official documentation about how to work with them.
230231

231-
Even if the viewport feature is still in a very experimental state, yet the docking API seems pretty stable. Thus, imgui-java exposes it and hides everything about viewports.<br>
232-
See an official documentation about how to work with [docking](https://github.com/ocornut/imgui/issues/2109).
232+
##### Important!
233+
Take a note that multi-viewports api is **VERY** complex to implement. It's highly recommended to use `imgui.glfw.ImGuiImplGlfw` class as it's done in the example.
234+
Otherwise, if you're using your own backed implementation, there are no guarantees it will work.
233235

234236
## Using FreeType
235237
Dear ImGui by default uses a stb_strutype library to render a fonts atlas. It's possible to use FreeType instead to get better fonts quality. See an example in [ImGuiGlfwExample](https://github.com/spair/imgui-java/blob/v1.77-0.17.2/imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java). [Read more](https://github.com/ocornut/imgui/blob/v1.76/misc/freetype/README.md)

imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ private void setupImGui() {
146146
final ImGuiIO io = ImGui.getIO();
147147

148148
io.setIniFilename(null); // We don't want to save .ini file
149-
io.addConfigFlags(ImGuiConfigFlags.NavEnableKeyboard | ImGuiConfigFlags.DockingEnable | ImGuiConfigFlags.ViewportsEnable);
149+
io.addConfigFlags(ImGuiConfigFlags.NavEnableKeyboard); // Enable Keyboard Controls
150+
io.addConfigFlags(ImGuiConfigFlags.DockingEnable); // Enable Docking
151+
io.addConfigFlags(ImGuiConfigFlags.ViewportsEnable); // Enable Multi-Viewport / Platform Windows
150152
io.setConfigViewportsNoTaskBarIcon(true);
151153

152154
// ------------------------------------------------------------
@@ -189,7 +191,7 @@ private void setupImGui() {
189191
ImGuiFreeType.buildFontAtlas(fontAtlas, ImGuiFreeType.RasterizerFlags.LightHinting);
190192

191193
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
192-
if ((io.getConfigFlags() & ImGuiConfigFlags.ViewportsEnable) != 0) {
194+
if (io.hasConfigFlags(ImGuiConfigFlags.ViewportsEnable)) {
193195
final ImGuiStyle style = ImGui.getStyle();
194196
style.setWindowRounding(0.0f);
195197
style.setColor(ImGuiCol.WindowBg, ImGui.getColorU32(ImGuiCol.WindowBg, 1));
@@ -224,7 +226,7 @@ private void endFrame() {
224226
// At that moment ImGui will be rendered to the current OpenGL context.
225227
imGuiGl3.renderDrawData(ImGui.getDrawData());
226228

227-
if ((ImGui.getIO().getConfigFlags() & ImGuiConfigFlags.ViewportsEnable) != 0) {
229+
if (ImGui.getIO().hasConfigFlags(ImGuiConfigFlags.ViewportsEnable)) {
228230
final long backupWindowPtr = glfwGetCurrentContext();
229231
ImGui.updatePlatformWindows();
230232
ImGui.renderPlatformWindowsDefault();

0 commit comments

Comments
 (0)