pvik / jimgui

:sparkling_heart: Pure Java binding for dear-imgui

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jimgui

Download

Linux Build Windows Build
CCI AV

Cross-platform efficient pure Java binding for dear-imgui, Kotlin is used as code generation tool.
Attention: this project is actually using a modified version of dear-imugi.

This project is created for a code editor and a game engine, both not open-sourced currently.

For mac, you should add -XstartOnFirstThread JVM argument.

Demo

Progress

  • ImGui namespace getter/setter/function/javadoc generation
  • ImGuiIO properties getter/setter/function/javadoc generation
  • ImGuiFont properties getter/setter/function/javadoc generation
  • ImGuiStyle properties getter/setter/function/javadoc generation
  • ImGuiFontAtlas 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
  • Native value pointer (bool *, int *, float *) wrappers, providing accessValue and modifyValue
  • 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
  • MacOS native library with Cocoa, glut as additions to Linux implementation
    • hosted on @zxj5470 's Mac laptop

Usage

Remember to add jcenter to your repositories.

Code example

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();
			}
		}
	}
}

Gradle

// ...
repositories {
    // ... 
    jcenter()
}
// ...
dependencies {
  String jimgui_version = 'v0.7'
  compile "org.ice1000.jimgui:core:$jimgui_version" // basic functionality
  compile "org.ice1000.jimgui:kotlin-dsl:$jimgui_version" // kotlin dsl wrapper
}

Gradle Kotlin DSL

dependencies {
  val jimguiVersion = "v0.7"
  compile("org.ice1000.jimgui:core:$jimguiVersion") // basic functionality
  compile("org.ice1000.jimgui:kotlin-dsl:$jimguiVersion") // kotlin dsl wrapper
}

Maven

<dependency>
  <groupId>org.ice1000.jimgui</groupId>
  <!-- basic functionality -->
  <artifactId>core</artifactId>
  <version>v0.7</version>
  <type>pom</type>
</dependency>

Build

First you need to make sure you have cmake newer than 3.5 and the following software installed:

  • For Linux
    • make
    • pkg-config
    • libglfw3-dev
  • For Windows (>= XP)
    • Visual Studio 2017 with msbuild
    • DirectX 9 Libraries (should be pre-installed on Windows or with Visual Studio)
    • DirectX SDK
  • For Mac OS X
    • Everything needed on Linux
    • Cocoa
    • GLUT
    • OpenGL
    • Run with JVM Argument: -XstartOnFirstThread
      • You can use export _JAVA_OPTIONS='-XstartOnFirstThread'.

To compile a jar library, run:

$ ./gradlew assemble

To run tests, run:

$ ./gradlew test

About

:sparkling_heart: Pure Java binding for dear-imgui

License:Apache License 2.0


Languages

Language:Java 35.5%Language:Kotlin 27.7%Language:C++ 20.9%Language:CMake 10.2%Language:C 5.5%Language:Batchfile 0.2%