From dc4e0a5b6d9b29a78c87848789f6ecbf53784413 Mon Sep 17 00:00:00 2001 From: Duncan Calvert Date: Wed, 6 Nov 2024 18:50:31 -0600 Subject: [PATCH 1/2] :arrow_up: lwjgl 3.3.4, libgdx 1.13.0, imgui 1.87.6 --- ihmc-graphics/build.gradle.kts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ihmc-graphics/build.gradle.kts b/ihmc-graphics/build.gradle.kts index 620b1e193c3..0be4755c92d 100644 --- a/ihmc-graphics/build.gradle.kts +++ b/ihmc-graphics/build.gradle.kts @@ -48,12 +48,12 @@ libgdxDependencies { api("us.ihmc:ihmc-java-toolkit:source") api("us.ihmc:ihmc-robotics-toolkit:source") - val gdxVersion = "1.12.1" + val gdxVersion = "1.13.0" api("com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion") api("com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop") api("com.github.mgsx-dev.gdx-gltf:core:2.2.1") - val lwjglVersion = "3.3.3" + val lwjglVersion = "3.3.4" api("org.lwjgl:lwjgl-openvr:$lwjglVersion") api("org.lwjgl:lwjgl-openvr:$lwjglVersion:natives-linux") api("org.lwjgl:lwjgl-openvr:$lwjglVersion:natives-windows") @@ -65,12 +65,12 @@ libgdxDependencies { api("org.lwjgl:lwjgl-assimp:$lwjglVersion:natives-windows-x86") api("org.lwjgl:lwjgl-assimp:$lwjglVersion:natives-macos") - val imguiVersion = "1.86.11" + val imguiVersion = "1.87.6" api("io.github.spair:imgui-java-binding:$imguiVersion") api("io.github.spair:imgui-java-lwjgl3:$imguiVersion") - api("io.github.spair:imgui-java-natives-linux-ft:$imguiVersion") - api("io.github.spair:imgui-java-natives-macos-ft:$imguiVersion") - api("io.github.spair:imgui-java-natives-windows-ft:$imguiVersion") + api("io.github.spair:imgui-java-natives-linux:$imguiVersion") + api("io.github.spair:imgui-java-natives-macos:$imguiVersion") + api("io.github.spair:imgui-java-natives-windows:$imguiVersion") val javaFXVersion = "17.0.9" api(ihmc.javaFXModule("graphics", javaFXVersion)) // JFX Color From 38e1ea291034662a62fad24bc0288086bb2a01f4 Mon Sep 17 00:00:00 2001 From: Duncan Calvert Date: Wed, 6 Nov 2024 18:50:56 -0600 Subject: [PATCH 2/2] WIP: Upgrade imgui --- .../java/us/ihmc/rdx/imgui/ImGuiTools.java | 14 +++++++------ .../ihmc/rdx/imgui/ImPlotDoublePlotLine.java | 3 ++- .../java/us/ihmc/rdx/imgui/ImPlotPlot.java | 20 +++++++++---------- .../java/us/ihmc/rdx/imgui/ImPlotTools.java | 11 ++++++---- .../imgui/RDXImGuiWindowAndDockSystem.java | 4 ++-- .../us/ihmc/rdx/ui/RDX3DPanelTooltip.java | 2 +- .../sequence/RDXActionProgressWidgets.java | 3 ++- .../rdx/ui/missionControl/ImGuiMachine.java | 11 +++++----- 8 files changed, 38 insertions(+), 30 deletions(-) diff --git a/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImGuiTools.java b/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImGuiTools.java index 302aa8d5703..5458610099c 100644 --- a/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImGuiTools.java +++ b/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImGuiTools.java @@ -252,32 +252,32 @@ public static boolean volatileInputDouble(String label, ImDouble imDouble, doubl public static boolean sliderDouble(String label, ImDouble imDouble, double minValue, double maxValue) { - return ImGui.sliderScalar(label, ImGuiDataType.Double, imDouble, minValue, maxValue); + return ImGui.sliderScalar(label, imDouble.getData(), minValue, maxValue); } public static boolean sliderDouble(String label, ImDouble imDouble, double minValue, double maxValue, String format) { - return ImGui.sliderScalar(label, ImGuiDataType.Double, imDouble, minValue, maxValue, format); + return ImGui.sliderScalar(label, imDouble.getData(), minValue, maxValue, format); } public static boolean sliderDouble(String label, ImDouble imDouble, double minValue, double maxValue, String format, int imGuiSliderFlags) { - return ImGui.sliderScalar(label, ImGuiDataType.Double, imDouble, minValue, maxValue, format, imGuiSliderFlags); + return ImGui.sliderScalar(label, imDouble.getData(), minValue, maxValue, format, imGuiSliderFlags); } public static boolean sliderInt(String label, ImInt imInt, int minValue, int maxValue) { - return ImGui.sliderScalar(label, ImGuiDataType.U32, imInt, minValue, maxValue); + return ImGui.sliderScalar(label, imInt.getData(), minValue, maxValue); } public static boolean sliderInt(String label, ImInt imInt, int minValue, int maxValue, String format) { - return ImGui.sliderScalar(label, ImGuiDataType.U32, imInt, minValue, maxValue, format); + return ImGui.sliderScalar(label, imInt.getData(), minValue, maxValue, format); } public static boolean sliderInt(String label, ImInt imInt, int minValue, int maxValue, String format, int imGuiSliderFlags) { - return ImGui.sliderScalar(label, ImGuiDataType.U32, imInt, minValue, maxValue, format, imGuiSliderFlags); + return ImGui.sliderScalar(label, imInt.getData(), minValue, maxValue, format, imGuiSliderFlags); } public static boolean smallCheckbox(String label, ImBoolean checked) @@ -510,6 +510,8 @@ public static String uniqueLabel(Object thisObject, String label) */ public static void setupFonts(ImGuiIO io) { + ImGui.getIO().getFonts().setFreeTypeRenderer(true); + if (SystemUtils.IS_OS_WINDOWS) FONT_DIRECTORY = System.getenv("WINDIR") + "/Fonts"; else diff --git a/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImPlotDoublePlotLine.java b/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImPlotDoublePlotLine.java index 47501fb9ffa..9166353b80d 100644 --- a/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImPlotDoublePlotLine.java +++ b/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImPlotDoublePlotLine.java @@ -1,6 +1,7 @@ package us.ihmc.rdx.imgui; import imgui.extension.implot.ImPlot; +import imgui.extension.implot.flag.ImPlotAxis; import imgui.flag.ImGuiCond; import java.text.DecimalFormat; @@ -50,6 +51,6 @@ public void setLimitYMin(double minLimitY) limitY = Math.max(doubleSwapBuffer.getValue(i), limitY); } } - ImPlot.setNextPlotLimitsY(0.0, limitY, ImGuiCond.Always); + ImPlot.setupAxisLimits(ImPlotAxis.Y1, 0.0, limitY, ImGuiCond.Always); } } diff --git a/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImPlotPlot.java b/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImPlotPlot.java index 00d5cb0efd7..9d8297e66c4 100644 --- a/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImPlotPlot.java +++ b/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImPlotPlot.java @@ -49,7 +49,7 @@ public ImPlotPlot(float plotHeight) flags += ImPlotFlags.NoMenus; flags += ImPlotFlags.NoBoxSelect; flags += ImPlotFlags.NoTitle; - flags += ImPlotFlags.NoMousePos; + flags += ImPlotFlags.NoMouseText; xFlags = ImPlotAxisFlags.None; xFlags += ImPlotAxisFlags.NoDecorations; @@ -78,13 +78,15 @@ public void render(float plotWidth, float plotHeight) outerBoundsDimensionsPixels.x = plotWidth; outerBoundsDimensionsPixels.y = plotHeight; - customBeforePlotLogic.run(); - if (ImPlot.beginPlot(labels.get("Plot"), xLabel, yLabel, outerBoundsDimensionsPixels, flags, xFlags, yFlags)) + if (ImPlot.beginPlot(labels.get("Plot"), outerBoundsDimensionsPixels, flags)) { - customDuringPlotLogic.run(); + ImPlot.setupAxis(ImPlotAxis.X1, xLabel, xFlags); + ImPlot.setupAxis(ImPlotAxis.Y1, yLabel, yFlags); + customBeforePlotLogic.run(); + ImPlot.setupLegend(ImPlotLocation.SouthWest, ImPlotLegendFlags.Horizontal | ImPlotLegendFlags.Outside); + ImPlot.setupFinish(); - boolean outside = true; - ImPlot.setLegendLocation(ImPlotLocation.SouthWest, ImPlotOrientation.Horizontal, outside); + customDuringPlotLogic.run(); boolean showingLegendPopup = false; for (ImPlotPlotLine plotLine : plotLines) @@ -95,7 +97,7 @@ public void render(float plotWidth, float plotHeight) if (!plotLines.isEmpty() && ImPlot.isPlotHovered()) { ImPlotPoint plotMousePosition = ImPlot.getPlotMousePos(ImPlotTools.IMPLOT_AUTO); - int bufferIndex = (int) Math.round(plotMousePosition.getX()); + int bufferIndex = (int) Math.round(plotMousePosition.x); StringBuilder tooltipText = new StringBuilder(); for (ImPlotPlotLine plotLine : plotLines) @@ -105,8 +107,6 @@ public void render(float plotWidth, float plotHeight) tooltipText.append(plotLine.getValueString(bufferIndex)).append("\n"); } ImGui.setTooltip(tooltipText.toString().trim()); - - plotMousePosition.destroy(); } if (popupContextWindowImGuiRenderer != null && !showingLegendPopup && ImGui.beginPopupContextWindow()) @@ -117,7 +117,7 @@ public void render(float plotWidth, float plotHeight) if (dragAndDropPayloadConsumer != null) { - if (ImPlot.beginDragDropTarget()) + if (ImPlot.beginDragDropTargetPlot()) { String payload = ImGui.acceptDragDropPayload(String.class); diff --git a/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImPlotTools.java b/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImPlotTools.java index b7ebef54c8a..cc7091a5eb9 100644 --- a/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImPlotTools.java +++ b/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/ImPlotTools.java @@ -4,6 +4,7 @@ import imgui.extension.implot.ImPlot; import imgui.extension.implot.ImPlotContext; import imgui.extension.implot.ImPlotStyle; +import imgui.extension.implot.flag.ImPlotAxis; import imgui.extension.implot.flag.ImPlotAxisFlags; import imgui.extension.implot.flag.ImPlotFlags; @@ -60,11 +61,13 @@ public static void setSCSStyle() public static void renderEmptyPlotArea(String label, float width, float height) { emptyPlotSize.set(width, height); - if (ImPlot.beginPlot(label, "", "", emptyPlotSize, - ImPlotFlags.NoMenus | ImPlotFlags.NoBoxSelect | ImPlotFlags.NoTitle | ImPlotFlags.NoMousePos, - ImPlotAxisFlags.NoDecorations | ImPlotAxisFlags.NoLabel, - ImPlotAxisFlags.NoDecorations | ImPlotAxisFlags.NoLabel)) + if (ImPlot.beginPlot(label, emptyPlotSize, + ImPlotFlags.NoMenus | ImPlotFlags.NoBoxSelect | ImPlotFlags.NoTitle | ImPlotFlags.NoMouseText)) { + ImPlot.setupAxis(ImPlotAxis.X1, "", ImPlotAxisFlags.NoDecorations | ImPlotAxisFlags.NoLabel); + ImPlot.setupAxis(ImPlotAxis.Y1, "", ImPlotAxisFlags.NoDecorations | ImPlotAxisFlags.NoLabel); + ImPlot.setupFinish(); + ImPlot.endPlot(); } } diff --git a/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/RDXImGuiWindowAndDockSystem.java b/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/RDXImGuiWindowAndDockSystem.java index e92cf7fba5f..95a620e3137 100644 --- a/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/RDXImGuiWindowAndDockSystem.java +++ b/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/imgui/RDXImGuiWindowAndDockSystem.java @@ -324,8 +324,8 @@ public void afterWindowManagement() public void dispose() { - imGuiGl3.dispose(); - imGuiGlfw.dispose(); + imGuiGl3.shutdown(); + imGuiGlfw.shutdown(); ImGui.destroyContext(); if (debugMessageCallback != null) diff --git a/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/ui/RDX3DPanelTooltip.java b/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/ui/RDX3DPanelTooltip.java index 89d3c787380..54ce44be836 100644 --- a/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/ui/RDX3DPanelTooltip.java +++ b/ihmc-graphics/src/libgdx/java/us/ihmc/rdx/ui/RDX3DPanelTooltip.java @@ -61,7 +61,7 @@ public void render(String text, int linesOfSpaceToGiveAbove) float textPositionX = drawStartX + 5.0f; float textPositionY = drawStartY + 2.0f; - ImGui.getWindowDrawList().addText(font, font.getFontSize(), textPositionX, textPositionY, Color.WHITE.toIntBits(), text); + ImGui.getWindowDrawList().addText(font, (int) font.getFontSize(), textPositionX, textPositionY, Color.WHITE.toIntBits(), text); } } } diff --git a/ihmc-high-level-behaviors/src/libgdx/java/us/ihmc/rdx/ui/behavior/sequence/RDXActionProgressWidgets.java b/ihmc-high-level-behaviors/src/libgdx/java/us/ihmc/rdx/ui/behavior/sequence/RDXActionProgressWidgets.java index 9282f9b27a6..928852f50c8 100644 --- a/ihmc-high-level-behaviors/src/libgdx/java/us/ihmc/rdx/ui/behavior/sequence/RDXActionProgressWidgets.java +++ b/ihmc-high-level-behaviors/src/libgdx/java/us/ihmc/rdx/ui/behavior/sequence/RDXActionProgressWidgets.java @@ -1,6 +1,7 @@ package us.ihmc.rdx.ui.behavior.sequence; import imgui.extension.implot.ImPlot; +import imgui.extension.implot.flag.ImPlotAxis; import imgui.extension.implot.flag.ImPlotFlags; import imgui.flag.ImGuiCond; import imgui.internal.ImGui; @@ -111,7 +112,7 @@ private void setupPlot(ImPlotPlot plot, double limitYMin, ImPlotBasicDoublePlotL double plotMaxY = plotLine.getMaxYValue(); max = Double.isNaN(max) ? plotMaxY : Math.max(plotMaxY, max); } - ImPlot.setNextPlotLimitsY(0.0, Double.isNaN(max) ? limitYMin : Double.max(limitYMin, max), ImGuiCond.Always); + ImPlot.setupAxisLimits(ImPlotAxis.Y1, 0.0, Double.isNaN(max) ? limitYMin : Double.max(limitYMin, max), ImGuiCond.Always); }); } diff --git a/ihmc-high-level-behaviors/src/libgdx/java/us/ihmc/rdx/ui/missionControl/ImGuiMachine.java b/ihmc-high-level-behaviors/src/libgdx/java/us/ihmc/rdx/ui/missionControl/ImGuiMachine.java index f2f5452e956..d967f6fad3b 100644 --- a/ihmc-high-level-behaviors/src/libgdx/java/us/ihmc/rdx/ui/missionControl/ImGuiMachine.java +++ b/ihmc-high-level-behaviors/src/libgdx/java/us/ihmc/rdx/ui/missionControl/ImGuiMachine.java @@ -3,6 +3,7 @@ import com.badlogic.gdx.graphics.Color; import imgui.ImGui; import imgui.extension.implot.ImPlot; +import imgui.extension.implot.flag.ImPlotAxis; import imgui.extension.implot.flag.ImPlotAxisFlags; import imgui.extension.implot.flag.ImPlotFlags; import imgui.flag.ImGuiCond; @@ -80,17 +81,17 @@ public ImGuiMachine(UUID instanceId, String hostname, ROS2Node ros2Node) cpuPlot.setFlags(plotFlags); cpuPlot.setXFlags(plotAxisXFlags); cpuPlot.setYFlags(plotAxisYFlags); - cpuPlot.setCustomBeforePlotLogic(() -> ImPlot.setNextPlotLimitsY(0.0, 103.0, ImGuiCond.Always)); + cpuPlot.setCustomBeforePlotLogic(() -> ImPlot.setupAxisLimits(ImPlotAxis.Y1, 0.0, 103.0, ImGuiCond.Always)); ramPlot.setFlags(plotFlags); ramPlot.setXFlags(plotAxisXFlags); ramPlot.setYFlags(plotAxisYFlags); - ramPlot.setCustomBeforePlotLogic(() -> ImPlot.setNextPlotLimitsY(0.0, lastResourceUsageMessage.getMemoryTotal(), ImGuiCond.Always)); + ramPlot.setCustomBeforePlotLogic(() -> ImPlot.setupAxisLimits(ImPlotAxis.Y1, 0.0, lastResourceUsageMessage.getMemoryTotal(), ImGuiCond.Always)); netPlot.setFlags(plotFlags); netPlot.setXFlags(plotAxisXFlags); netPlot.setYFlags(plotAxisYFlags); - netPlot.setCustomBeforePlotLogic(() -> ImPlot.setNextPlotLimitsY(-3000.0, 103000.0, ImGuiCond.Always)); + netPlot.setCustomBeforePlotLogic(() -> ImPlot.setupAxisLimits(ImPlotAxis.Y1, -3000.0, 103000.0, ImGuiCond.Always)); this.ros2Node = ros2Node; @@ -154,7 +155,7 @@ private void acceptSystemResourceUsageMessage(SystemResourceUsageMessage message plot.setXFlags(plotAxisXFlags); plot.setYFlags(plotAxisYFlags); String gpuModel = message.getNvidiaGpuModels().getString(0); - plot.setCustomBeforePlotLogic(() -> ImPlot.setNextPlotLimitsY(0.0, 103.0, ImGuiCond.Always)); + plot.setCustomBeforePlotLogic(() -> ImPlot.setupAxisLimits(ImPlotAxis.Y1, 0.0, 103.0, ImGuiCond.Always)); plot.getPlotLines() .add(new ImPlotDoublePlotLine("GPU (" + gpuIndex + ", " + gpuModel + ") utilization %", GRAPH_BUFFER_SIZE, @@ -174,7 +175,7 @@ private void acceptSystemResourceUsageMessage(SystemResourceUsageMessage message plot.setYFlags(plotAxisYFlags); String gpuModel = message.getNvidiaGpuModels().getString(0); float totalGpuMemory = message.getNvidiaGpuMemoryTotal().get(gpuIndex); - plot.setCustomBeforePlotLogic(() -> ImPlot.setNextPlotLimitsY(0.0, totalGpuMemory, ImGuiCond.Always)); + plot.setCustomBeforePlotLogic(() -> ImPlot.setupAxisLimits(ImPlotAxis.Y1, 0.0, totalGpuMemory, ImGuiCond.Always)); plot.getPlotLines() .add(new ImPlotDoublePlotLine("GPU (" + gpuIndex + ", " + gpuModel + ") memory usage (GiB)", GRAPH_BUFFER_SIZE,