-
Notifications
You must be signed in to change notification settings - Fork 36
Install
As of the time writing, the best way to retrieve artifacts of ImGui is by using Jitpack as a repository. The artifact ids follow the format com.github.User:Repo:Tag
.
%IMGUI_VERSION%
is used as a placeholder in all samples. To retrieve the latest snapshot build use -SNAPSHOT
.
Using Gradle with a workaround is recommended to keep the required maintenance cost as low as possible. The following example is a fully working Gradle script:
import org.gradle.internal.os.OperatingSystem
repositories {
mavenCentral()
maven { url "https://dl.bintray.com/kotlin/kotlin-dev" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'com.github.kotlin-graphics:imgui:%IMGUI_VERSION%'
switch (OperatingSystem.current()) {
case OperatingSystem.WINDOWS:
ext.lwjglNatives = "natives-windows"
break
case OperatingSystem.LINUX:
ext.lwjglNatives = "natives-linux"
break
case OperatingSystem.MAC_OS:
ext.lwjglNatives = "natives-macos"
break
}
// Look up which modules and versions of LWJGL are required and add setup the approriate natives.
configurations.compile.resolvedConfiguration.getResolvedArtifacts().forEach {
if (it.moduleVersion.id.group == "org.lwjgl") {
runtime "org.lwjgl:${it.moduleVersion.id.name}:${it.moduleVersion.id.version}:${lwjglNatives}"
}
}
}
Gradle Kotlin may also be used to receive all the benefits of Gradle with Kotlin's type-safety instead.
import org.gradle.internal.os.OperatingSystem
repositories {
mavenCentral()
maven("https://dl.bintray.com/kotlin/kotlin-dev")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://jitpack.io")
}
dependencies {
compile("com.github.kotlin-graphics:imgui:%IMGUI_VERSION%")
val lwjglNatives = when (OperatingSystem.current()) {
OperatingSystem.WINDOWS -> "natives-windows"
OperatingSystem.LINUX -> "natives-linux"
OperatingSystem.MAC_OS -> "natives-macos"
else -> ""
}
// Look up which modules and versions of LWJGL are required and add setup the approriate natives.
configurations["compile"].resolvedConfiguration.resolvedArtifacts.forEach {
if (it.moduleVersion.id.group == "org.lwjgl") {
"runtime"("org.lwjgl:${it.moduleVersion.id.name}:${it.moduleVersion.id.version}:$lwjglNatives")
}
}
}
If you want to have imgui as a git submodule to your main project and automatically chain build the dependency from your main projects gradle file this section is for you.
In your project root add imgui as a submodule:
git submodule add https://github.com/kotlin-graphics/imgui
Edit your main projects settings.gradle and add the following. This will allow you to use the local imgui build if the submodule is checked out and if not use imgui from the repository.
if (file('imgui/build.gradle.kts').exists()) includeBuild("imgui") {
dependencySubstitution { // Substitute the imgui projects you will be using, this example is for glfw
substitute module('com.github.kotlin-graphics.imgui:core') with project(':core')
substitute module('com.github.kotlin-graphics.imgui:gl') with project(':gl')
substitute module('com.github.kotlin-graphics.imgui:glwf') with project(':glfw')
}
}
You will also want a well defined version for the local imgui so modify build.gradle.kts and add a version line below the group.
In the same file comment out the archives(dokkaJar)
artifact at the bottom to avoid spending time building html documentation.
group = "com.github.kotlin_graphics"
version = "-SNAPSHOT"
...
artifacts {
archives(sourceJar)
// archives(dokkaJar)
}
If you also want to avoid unnecessary plugins you can comment out maven and dokka from both plugins and allprojects but then you will also have to comment out the dokka tasks.
To speed up gradle refresh modify imguis settings.gradle.kts and comment out the parts you don't use.
rootProject.name = "imgui"
include("core", "glfw", "gl")
//include("core", "glfw", "gl", "vk", /*"jogl",*/ "openjfx", "bgfx")
This should allow you to use the normal dependencies in your main project and gradle will automatically build imgui for you with your local imgui changes.
When cloning your project remember to cd into the imgui submodule dir and run git submodule init
and git submodule update
, or it will be empty and no local build will happen.
Configuring ImGui to work with other dependency resolution systems is, unfortunately, not quite as simple.
A dependency on ImGui may be specified as usual for the respective system but its dependencies require special treatment.
- Make sure to also add (runtime) dependencies on LWJGL native modules for all LWJGL modules in the dependency graph. At the time of writing those are:
lwjgl
,lwjgl-glfw
,lwjgl-jemalloc
,lwjgl-openal
,lwjgl-opengl
, andlwjgl-stb
. - Always use matching versions of LWJGL to avoid incompatibilities.