Skip to content

Install

Leon Linhart edited this page Dec 5, 2017 · 3 revisions

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.

Gradle

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

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")
        }
    }
}

Maven, Sbt, Leiningen, and others

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, and lwjgl-stb.
  • Always use matching versions of LWJGL to avoid incompatibilities.
Clone this wiki locally