Linux Build | Windows Build |
---|---|
Cross-platform efficient pure Java binding for dear-imgui, Kotlin is used as code generation tool.
This project is created for a code editor and a game engine, both not open-sourced currently.
For macOS users, add -XstartOnFirstThread
JVM argument when running programs built with jimgui.
-
ImGui
namespace getter/setter/function/javadoc generation -
ImGuiFontAtlas
/ImGuiStyle
/ImGuiFont
/ImGuiIO
/ImGuiDrawList
properties getter/setter/function/javadoc generation -
ImGui*Flags
copy-pasted constant/javadoc -
ImStyleVar
keys using generic parameter as type constraint (type safe!) - Functions to access and modify platform window size/pos
- Use
MagicConstant
annotation to specify where the constant parameters are from (IntelliJ IDEA understands this!)- Generate functions with
MagicConstant
annotation
- Generate functions with
- Native value pointer (
bool *
,int *
,float *
) wrappers, providingaccessValue
andmodifyValue
-
ImVec4
wrapper with optional mutability - Critical Native function generations
-
ImTextureID
wrapper with platform-dependent implementations-
LPDIRECT3DTEXTURE9
on WindowsXP+ -
GLuint
on MacOS/Linux
-
- Linux native library with glfw3 + opengl3 implementation
- 32-bit hosted on ?
- 64-bit hosted on CircleCI
- WindowsXP+ native library
- with glfw + opengl3 implementation
- 32-bit hosted on ?
- 64-bit hosted on my laptop
- with directX9 implementation
- 32-bit hosted on AppVeyor
- 64-bit hosted on AppVeyor
- with glfw + opengl3 implementation
- MacOS native library with Cocoa, glut as additions to Linux implementation
- hosted on @zxj5470 's Mac laptop
Remember to add jcenter to your repositories.
import org.ice1000.jimgui.JImGui;
import org.ice1000.jimgui.util.JniLoader;
public class Main {
public static void main(String... args){
JniLoader.load();
try (JImGui imGui = new JImGui()) {
// load fonts, global initializations, etc.
imGui.initBeforeMainLoop();
while (!imGui.windowShouldClose()) {
// some drawing-irrelated initializations
// mostly do nothing here
imGui.initNewFrame();
// draw your widgets here, like this
imGui.text("Hello, World!");
imGui.render();
}
}
}
}
Notice that jimgui uses a not-very-efficient way to convert java.lang.String
into byte arrays that C++ is happy with.
You can customize the string-to-bytes function yourself by using org.ice1000.jimgui.util.JImGuiUtil.setStringToBytes
,
or use the more efficient alternative to java.lang.String
-- org.ice1000.jimgui.JImStr
,
which is supposed to be created as global constants.
import org.gradle.internal.os.OperatingSystem
// ...
repositories {
// ...
jcenter()
}
// ...
dependencies {
String jimgui_version = 'v0.9'
compile "org.ice1000.jimgui:core:$jimgui_version" // basic functionality
compile "org.ice1000.jimgui:kotlin-dsl:$jimgui_version" // kotlin dsl wrapper
}
// ...
run {
if (OperatingSystem.current() == OperatingSystem.MAC_OS) {
jvmArgs "-XstartOnFirstThread"
}
}
dependencies {
val jimguiVersion = "v0.9"
compile("org.ice1000.jimgui:core:$jimguiVersion") // basic functionality
compile("org.ice1000.jimgui:kotlin-dsl:$jimguiVersion") // kotlin dsl wrapper
}
<dependency>
<groupId>org.ice1000.jimgui</groupId>
<!-- basic functionality -->
<artifactId>core</artifactId>
<version>v0.9</version>
<type>pom</type>
</dependency>
First you need to make sure you have cmake
newer than 3.14 and the following software installed:
- For Linux
make
pkg-config
libglfw3-dev
- For Windows (>= XP)
- Visual Studio 2019 with
msbuild
- DirectX 9 Libraries (should be pre-installed on Windows or with Visual Studio)
- DirectX SDK
- Visual Studio 2019 with
- For Mac OS X
- Everything needed on Linux
Cocoa
GLUT
OpenGL
- Run with JVM Argument:
-XstartOnFirstThread
- You can use
export _JAVA_OPTIONS='-XstartOnFirstThread'
.
- You can use
To compile a jar library, run:
$ ./gradlew assemble
To run tests, run:
$ ./gradlew test