Skip to content

Commit

Permalink
Upgrade to imgui-java 1.87.1
Browse files Browse the repository at this point in the history
This version includes support for M1 macs and my contribution for
TableSortSpecs so we don't need to build these libraries any more!
🥳
  • Loading branch information
ultraq committed Aug 20, 2024
1 parent 354678f commit 5078a32
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 30 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ subprojects {

ext {
groovyVersion = '4.0.21'
imguiVersion = '1.86.11'
imguiVersion = '1.87.1'
jomlVersion = '1.10.6'
jomlPrimitivesVersion = '1.10.0'
logbackVersion = '1.5.6'
lwjglVersion = '3.3.3'
lwjglVersion = '3.3.4'
slf4jVersion = '2.0.13'
}
ext.targetPlatform = targetPlatform
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 4 additions & 6 deletions redhorizon-engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,17 @@ dependencies {
implementation project(':redhorizon-filetypes')
implementation platform("org.lwjgl:lwjgl-bom:${lwjglVersion}")
implementation "ch.qos.logback:logback-core:${logbackVersion}"
implementation("io.github.spair:imgui-java-lwjgl3:${imguiVersion}") {
exclude group: 'io.github.spair', module: 'imgui-java-binding'
}
implementation files("../libraries/imgui-java-binding-with-tablesortspecs-${imguiVersion}.jar")
implementation "io.github.spair:imgui-java-binding:${imguiVersion}"
implementation "io.github.spair:imgui-java-lwjgl3:${imguiVersion}"
implementation "org.joml:joml:${jomlVersion}"
implementation "org.joml:joml-primitives:${jomlPrimitivesVersion}"
implementation 'org.lwjgl:lwjgl'
implementation 'org.lwjgl:lwjgl-glfw'
implementation 'org.lwjgl:lwjgl-openal'
implementation 'org.lwjgl:lwjgl-opengl'

runtimeOnly files("../libraries/imgui-java-natives-with-tablesortspecs-macos-arm64-${imguiVersion}.jar")
runtimeOnly files("../libraries/imgui-java-natives-with-tablesortspecs-windows-${imguiVersion}.jar")
runtimeOnly "io.github.spair:imgui-java-natives-macos:${imguiVersion}"
runtimeOnly "io.github.spair:imgui-java-natives-windows:${imguiVersion}"
['natives-macos-arm64', 'natives-windows'].each { natives ->
runtimeOnly "org.lwjgl:lwjgl::${natives}"
runtimeOnly "org.lwjgl:lwjgl-glfw::${natives}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ import static imgui.flag.ImGuiWindowFlags.*
import static org.lwjgl.glfw.GLFW.*

import groovy.transform.TupleConstructor
import java.nio.file.Files
import java.nio.file.StandardCopyOption

/**
* Wrapper around all of the `imgui-java` binding classes, hiding all of the
Expand All @@ -64,20 +62,6 @@ class ImGuiLayer implements AutoCloseable, InputSource {
static ImFont robotoFont
static ImFont robotoMonoFont

static {

// Extract and use the locally built natives for macOS running M processors
if (System.isMacOs() && System.isArm64()) {
ImGuiLayer.classLoader.getResourceAsStream('io/imgui/java/native-bin/libimgui-javaarm64.dylib').withStream { inputStream ->
var tmpDir = File.createTempDir('imgui-java-natives-macos-arm64')
tmpDir.deleteOnExit()
var libFile = new File(tmpDir, 'libimgui-javaarm64.dylib')
Files.copy(inputStream, libFile.toPath(), StandardCopyOption.REPLACE_EXISTING)
System.load(libFile.absolutePath)
}
}
}

final MainMenu mainMenu
final GameWindow gameWindow

Expand Down Expand Up @@ -165,8 +149,8 @@ class ImGuiLayer implements AutoCloseable, InputSource {
@Override
void close() {

imGuiGl3.dispose()
imGuiGlfw.dispose()
imGuiGl3.shutdown()
imGuiGlfw.shutdown()
ImGui.destroyContext()
}

Expand All @@ -176,6 +160,7 @@ class ImGuiLayer implements AutoCloseable, InputSource {
*/
void frame(Closure<Framebuffer> closure) {

imGuiGl3.newFrame()
imGuiGlfw.newFrame()
ImGui.newFrame()

Expand Down
2 changes: 1 addition & 1 deletion redhorizon-explorer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies {
implementation project(':redhorizon-filetypes')
implementation platform("org.lwjgl:lwjgl-bom:${lwjglVersion}")
implementation "ch.qos.logback:logback-classic:${logbackVersion}"
implementation files("../libraries/imgui-java-binding-with-tablesortspecs-${imguiVersion}.jar")
implementation "io.github.spair:imgui-java-binding:${imguiVersion}"
implementation 'nz.net.ultraq.preferences:preferences:3.1.0'
implementation "org.apache.groovy:groovy-json:${groovyVersion}"
implementation "org.joml:joml:${jomlVersion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ class EntryList implements EventTarget, ImGuiElement {
specialEntry = entries.remove(specialEntryIndex)
}

var sortingColumn = tableSortSpecs.specs.columnIndex
switch (sortingColumn) {
var sortingColumnSpecs = tableSortSpecs.specs[0]
switch (sortingColumnSpecs.columnIndex) {
case 1 -> entries.sort { it.type }
case 2 -> entries.sort { it.size }
case 3 && entries[0] instanceof MixEntry -> entries.sort { it.description }
default -> entries.sort { it.name }
}
if (tableSortSpecs.specs.sortDirection == ImGuiSortDirection.Descending) {
if (sortingColumnSpecs.sortDirection == ImGuiSortDirection.Descending) {
entries.reverse(true)
}

Expand Down

0 comments on commit 5078a32

Please sign in to comment.