dominaezzz / kotlin-imgui Goto Github PK
View Code? Open in Web Editor NEWKotlin bindings for Dear ImGui
License: MIT License
Kotlin bindings for Dear ImGui
License: MIT License
Because of bintray shutdown, kotlin-imgui is now unavailable as a dependency .
It would be great to publish in another repo, or on Github.
Some functions like fun ImGui.getWindowPos(): Vec2
could be val ImGui.windowPos: Vec2
.
I have created a new native project with intelli and added imgui dependencies:
// build.gradle.kts
plugins {
kotlin("multiplatform") version "1.5.0"
}
group = "me.me"
version = "1.0-SNAPSHOT"
val imguiVersion = "0.1.9"
val kglVersion = "0.3-RC1"
repositories {
mavenCentral()
maven("https://maven.pkg.github.com/Dominaezzz/kotlin-imgui") {
credentials {
username = System.getenv("GITHUB_USER") // Your GitHub username.
password = System.getenv("GITHUB_TOKEN") // A GitHub token with `read:packages`.
}
}
}
kotlin {
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
nativeTarget.apply {
binaries {
executable {
entryPoint = "main"
}
}
}
sourceSets {
val nativeMain by getting {
dependencies {
implementation("com.kotlin-imgui:imgui:$imguiVersion")
implementation("com.kotlin-imgui:imgui-glfw:$imguiVersion")
implementation("com.kotlin-imgui:imgui-opengl:$imguiVersion")
// For jvm binaries
implementation("com.kotlin-imgui:cimgui-jvmlinuxx64:$imguiVersion")
implementation("com.kotlin-imgui:cimgui-jvmmacosx64:$imguiVersion")
implementation("com.kotlin-imgui:cimgui-jvmmingwx64:$imguiVersion")
// Optional
implementation("com.kgl:kgl-glfw:$kglVersion")
implementation("com.kgl:kgl-glfw-static:$kglVersion")
implementation("com.kgl:kgl-opengl:$kglVersion")
}
}
val nativeTest by getting
}
}
But building the project on windows ends up with the following error message:
Execution failed for task ':compileKotlinNative'.
> Could not resolve all files for configuration ':nativeCompileKlibraries'.
> Could not resolve com.kotlin-imgui:cimgui-jvmlinuxx64:0.1.9.
Required by:
project :
> No matching variant of com.kotlin-imgui:cimgui-jvmlinuxx64:0.1.9 was found. The consumer was configured to find a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native', attribute 'org.jetbrains.kotlin.native.target' with value 'mingw_x64' but:
- Variant 'jvmLinuxX64-api' capability com.kotlin-imgui:cimgui-jvmlinuxx64:0.1.9 declares an API of a component:
- Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
- Other compatible attribute:
- Doesn't say anything about org.jetbrains.kotlin.native.target (required 'mingw_x64')
- Variant 'jvmLinuxX64-runtime' capability com.kotlin-imgui:cimgui-jvmlinuxx64:0.1.9 declares a runtime of a component:
- Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
- Other compatible attribute:
- Doesn't say anything about org.jetbrains.kotlin.native.target (required 'mingw_x64')
- Variant 'metadata-api' capability com.kotlin-imgui:cimgui-jvmlinuxx64:0.1.9 declares a usage of 'kotlin-api' of a component:
- Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
- Other compatible attribute:
- Doesn't say anything about org.jetbrains.kotlin.native.target (required 'mingw_x64')
> Could not resolve com.kotlin-imgui:cimgui-jvmmacosx64:0.1.9.
Required by:
project :
> No matching variant of com.kotlin-imgui:cimgui-jvmmacosx64:0.1.9 was found. The consumer was configured to find a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native', attribute 'org.jetbrains.kotlin.native.target' with value 'mingw_x64' but:
- Variant 'jvmMacosX64-api' capability com.kotlin-imgui:cimgui-jvmmacosx64:0.1.9 declares an API of a component:
- Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
- Other compatible attribute:
- Doesn't say anything about org.jetbrains.kotlin.native.target (required 'mingw_x64')
- Variant 'jvmMacosX64-runtime' capability com.kotlin-imgui:cimgui-jvmmacosx64:0.1.9 declares a runtime of a component:
- Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
- Other compatible attribute:
- Doesn't say anything about org.jetbrains.kotlin.native.target (required 'mingw_x64')
- Variant 'metadata-api' capability com.kotlin-imgui:cimgui-jvmmacosx64:0.1.9 declares a usage of 'kotlin-api' of a component:
- Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
- Other compatible attribute:
- Doesn't say anything about org.jetbrains.kotlin.native.target (required 'mingw_x64')
> Could not resolve com.kotlin-imgui:cimgui-jvmmingwx64:0.1.9.
Required by:
project :
> No matching variant of com.kotlin-imgui:cimgui-jvmmingwx64:0.1.9 was found. The consumer was configured to find a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native', attribute 'org.jetbrains.kotlin.native.target' with value 'mingw_x64' but:
- Variant 'jvmMingwX64-api' capability com.kotlin-imgui:cimgui-jvmmingwx64:0.1.9 declares an API of a component:
- Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
- Other compatible attribute:
- Doesn't say anything about org.jetbrains.kotlin.native.target (required 'mingw_x64')
- Variant 'jvmMingwX64-runtime' capability com.kotlin-imgui:cimgui-jvmmingwx64:0.1.9 declares a runtime of a component:
- Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
- Other compatible attribute:
- Doesn't say anything about org.jetbrains.kotlin.native.target (required 'mingw_x64')
- Variant 'metadata-api' capability com.kotlin-imgui:cimgui-jvmmingwx64:0.1.9 declares a usage of 'kotlin-api' of a component:
- Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
- Other compatible attribute:
- Doesn't say anything about org.jetbrains.kotlin.native.target (required 'mingw_x64')
> Could not find com.kgl:kgl-glfw:0.3-RC1.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/kgl/kgl-glfw/0.3-RC1/kgl-glfw-0.3-RC1.pom
- https://maven.pkg.github.com/Dominaezzz/kotlin-imgui/com/kgl/kgl-glfw/0.3-RC1/kgl-glfw-0.3-RC1.pom
Required by:
project :
> Could not find com.kgl:kgl-glfw-static:0.3-RC1.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/kgl/kgl-glfw-static/0.3-RC1/kgl-glfw-static-0.3-RC1.pom
- https://maven.pkg.github.com/Dominaezzz/kotlin-imgui/com/kgl/kgl-glfw-static/0.3-RC1/kgl-glfw-static-0.3-RC1.pom
Required by:
project :
> Could not find com.kgl:kgl-opengl:0.3-RC1.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/kgl/kgl-opengl/0.3-RC1/kgl-opengl-0.3-RC1.pom
- https://maven.pkg.github.com/Dominaezzz/kotlin-imgui/com/kgl/kgl-opengl/0.3-RC1/kgl-opengl-0.3-RC1.pom
Required by:
project :
> Could not find com.kgl:kgl-glfw:0.3-RC1.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/kgl/kgl-glfw/0.3-RC1/kgl-glfw-0.3-RC1.pom
- https://maven.pkg.github.com/Dominaezzz/kotlin-imgui/com/kgl/kgl-glfw/0.3-RC1/kgl-glfw-0.3-RC1.pom
Required by:
project : > com.kotlin-imgui:imgui-glfw:0.1.9 > com.kotlin-imgui:imgui-glfw-mingwx64:0.1.9
> Could not find com.kgl:kgl-opengl:0.3-RC1.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/kgl/kgl-opengl/0.3-RC1/kgl-opengl-0.3-RC1.pom
- https://maven.pkg.github.com/Dominaezzz/kotlin-imgui/com/kgl/kgl-opengl/0.3-RC1/kgl-opengl-0.3-RC1.pom
Required by:
project : > com.kotlin-imgui:imgui-opengl:0.1.9 > com.kotlin-imgui:imgui-opengl-mingwx64:0.1.9
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
What am I doing wrong? Would you consider creating a self contained hello-world template in its own github repo? Thx!
just tried the new version of kgl and got hung up on the same ABI problem with this lib.
Convenience DSLs like these should be generated.
inline fun ImGui.menuBar(block: () -> Unit) {
if (beginMenuBar()) {
try {
block()
} finally {
endMenuBar()
}
}
}
inline fun ImGui.withId(id: Int, block: () -> Unit) {
pushId(id)
try {
block()
} finally {
popId()
}
}
I could not find a way to compute the size of a text in advance, without rendering it on screen.
As far as I know, ImGui has a CalcTextSize
function that facilitates this functionality.
I have created a simple Hello-World app:
import com.imgui.*
fun main() {
with(ImGui) {
text("Hello, world!")
}
}
Yet, it doesn't show anything on screen and exits with the following message:
Execution failed for task ':runDebugExecutableNative'.
> Process 'command 'D:\hello-imgui\build\bin\native\debugExecutable\hello-imgui.exe'' finished with non-zero exit value -1073741819
At the moment Kotlin/Native doesn't support forwarding args to variadic C functions.
fun ImGui.text(fmt: String, varags args: Any?) {
igText(fmt, *args)
}
result in
e:(...path...): When calling variadic C functions spread operator is supported only for *arrayOf(...)
I encountered the following error when trying kotlin-imgui 0.1.7
on Ubuntu 18.04
with JDK 11.0.9
.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/libcimgui7590039100609315263.so: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /tmp/libcimgui7590039100609315263.so)
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
at java.base/java.lang.Runtime.load0(Runtime.java:768)
at java.base/java.lang.System.load(System.java:1837)
at com.imgui.UtilsKt.loadCImGuiNativeLibs(Utils.kt:58)
at com.imgui.ImGui.<clinit>(ImGui.kt:308)
at org.acejump.tracejump.HelloImGuiKt.main(HelloImGui.kt:15)
at org.acejump.tracejump.HelloImGuiKt.main(HelloImGui.kt)
Here is my build.gradle.kts
excerpt:
val imguiVersion = "0.1.7"
implementation("com.kotlin-imgui:imgui:$imguiVersion")
implementation("com.kotlin-imgui:imgui-glfw:$imguiVersion")
implementation("com.kotlin-imgui:imgui-opengl:$imguiVersion")
// For jvm binaries
implementation("com.kotlin-imgui:cimgui-jvmlinuxx64:$imguiVersion")
implementation("com.kotlin-imgui:cimgui-jvmmacosx64:$imguiVersion")
implementation("com.kotlin-imgui:cimgui-jvmmingwx64:$imguiVersion")
Ok, I've started using the sample from Dominaezzz's kotlin-imgui library for the K/N, but I get errors thrown when trying to compile it for linuxArmHfp
.
error, my build.gradle.kts and my folder layout
It compiles and runs fine on the host, but it doesn't get past the errors when compiling for the ARM32HFP.
I can also test new builds on this architecture. I have a Raspberry Pi 2b+ and an IMX6 to test it on.
Ran into this problem just now: function like ImGui.treeNodeEx
which optionally take a Flag<ImGuiTreeNodeFlags>
don't currently support sending nullable flags:
val flags = (if (selected == current) ImGuiTreeNodeFlags.Selected else null) or ImGuiTreeNodeFlags.OpenOnArrow
ImGui.treeNodeEx(current.uuid(), flags, "Some node") // compile error: required Flag<ImGuiTreeNodeFlags>, found Flag<ImGuiTreeNodeFlags>?
there are a few workarounds, but since 0
is a valid Flag value, null
should be accepted anywhere
imgui
, and by extension cimgui
, support viewports and window docking in a separate branch. Would it be possible to publish a separate imgui-docking
artifact based on that branch?
Currently a system exists in codegen to generate setters for a selected whitelist of properties in ImGui classes. One notable property missing is ImGuiIO.configFlags
, and modification of ImGuiStyle
's properties is probably another good use case, but the question comes to mind: At what point might it be better to tweak the generation to make properties mutable based on whether they're const
rather than explicitly following a whitelist?
I am habing trouble with the imgui version you set (1.77)
None
is a perfectly valid option to pass as a flag for ImGui, but the code generator doesn't translate it into an enum value
cf ImGuiDockNodeFlags_None
vs no equivalent in enum class ImGuiDockNodeFlags
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.