diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97a0088..4a57177 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,92 +4,169 @@ jobs: build-java: strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ ubuntu-latest, macos-latest ] name: Build Java runs-on: ${{ matrix.os }} steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 + with: + fetch-depth: 0 - - name: Setup Java 8 - uses: actions/setup-java@v1 + - name: Setup Java + uses: actions/setup-java@v3 with: java-version: 8 + distribution: liberica - name: Build - uses: eskatos/gradle-command-action@v1 + run: ./gradlew buildAll + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 with: - arguments: buildAll + name: java-libraries + path: | + imgui-app/build/libs/*.jar + imgui-binding/build/libs/*.jar + imgui-lwjgl3/build/libs/*.jar build-natives: - env: - FREETYPE_URL: https://download.savannah.gnu.org/releases/freetype/freetype-2.12.1.tar.gz strategy: matrix: - os: [ubuntu-latest, macos-latest] - type: [win, linux, mac] - freetype: [true, false] + os: [ ubuntu-latest, macos-latest ] + type: [ windows, linux, macos ] + freetype: [ true, false ] include: - - type: win + - type: windows expected: /tmp/imgui/libsNative/windows64/imgui-java64.dll - type: linux expected: /tmp/imgui/libsNative/linux64/libimgui-java64.so - - type: mac + - type: macos expected: /tmp/imgui/libsNative/macosx64/libimgui-java64.dylib exclude: - os: ubuntu-latest - type: mac + type: macos - os: macos-latest - type: win + type: windows - os: macos-latest type: linux - name: Build Native (type=${{ matrix.type }}, freetype=${{ matrix.freetype }}) + name: Build Native (${{ matrix.type }}${{ matrix.freetype && ', freetype' || '' }}) runs-on: ${{ matrix.os }} steps: - name: Checkout Repository and Submodules - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: + fetch-depth: 0 submodules: recursive - - name: Setup Java 8 - uses: actions/setup-java@v1 + - name: Setup Java + uses: actions/setup-java@v3 with: java-version: 8 + distribution: liberica - name: Ant Version run: ant -version - if: matrix.os == 'ubuntu-latest' - name: Install MinGW-w64/GCC/G++ + name: Install MinGW-w64/GCC/G++ (Linux & Windows) run: sudo apt install mingw-w64 - if: matrix.os == 'ubuntu-latest' && matrix.type == 'linux' && matrix.freetype == true - name: FreeType - Install + name: FreeType - Install (Linux) run: sudo apt install libfreetype6-dev - - if: matrix.os == 'ubuntu-latest' && matrix.type == 'win' && matrix.freetype == true - name: FreeType - Download + - if: matrix.os == 'ubuntu-latest' && matrix.type == 'windows' && matrix.freetype == true + name: FreeType - Install (Windows) run: | - sudo wget -O /freetype.tar.gz ${{ env.FREETYPE_URL }} sudo mkdir /freetype - sudo tar -xzf /freetype.tar.gz -C /freetype --strip-components=1 - - - if: matrix.os == 'ubuntu-latest' && matrix.type == 'win' && matrix.freetype == true - name: FreeType - Compile & Install - working-directory: /freetype - run: | + sudo tar -xzf ./vendor/freetype-2.12.1.tar.gz -C /freetype --strip-components=1 + cd /freetype sudo ./configure --with-zlib=no --with-bzip2=no --with-png=no --with-harfbuzz=no --with-brotli=no --host=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32 sudo make sudo make install - name: Build - uses: eskatos/gradle-command-action@v1 - with: - arguments: :imgui-binding:generateLibs -Denvs=${{ matrix.type }} -Dfreetype=${{ matrix.freetype }} + run: ./gradlew imgui-binding:generateLibs -Denvs=${{ matrix.type }} -Dfreetype=${{ matrix.freetype }} - - name: Upload Native - uses: actions/upload-artifact@v2 + - name: Upload Artifacts + uses: actions/upload-artifact@v3 with: - name: ${{ matrix.freetype && 'freetype' || 'common' }} - path: ${{ matrix.expected }} + name: ${{ matrix.freetype && 'native-libraries-with-freetype' || 'native-libraries' }} if-no-files-found: error + path: ${{ matrix.expected }} + + update-bin: + if: github.ref == 'refs/heads/main' # runs only on the main branch + name: Update Binaries + runs-on: ubuntu-latest + needs: build-natives + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Download Artifacts + uses: actions/download-artifact@v3 + with: + path: /tmp/artifacts + + - name: Update + run: | + mv /tmp/artifacts/native-libraries/* bin/ + mv /tmp/artifacts/native-libraries-with-freetype/* bin/freetype/ + + - name: Commit + uses: EndBug/add-and-commit@v9 + with: + default_author: github_actions + message: '[ci skip] update native binaries' + + release: + if: startsWith(github.ref, 'refs/tags/v') # if tag starts with "v" + name: Release + runs-on: ubuntu-latest + needs: [ build-java, build-natives ] + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Java + uses: actions/setup-java@v3 + with: + java-version: 8 + distribution: liberica + + - name: Download Artifacts + uses: actions/download-artifact@v3 + with: + path: out/artifacts + + - name: Zip Artifacts + run: | + mkdir out/archives + zip -rj out/archives/native-libraries out/artifacts/native-libraries + zip -rj out/archives/native-libraries-with-freetype out/artifacts/native-libraries-with-freetype + zip -rj out/archives/java-libraries out/artifacts/java-libraries + + - name: Publish + env: + NEXUS_UPD_ID: ${{ secrets.RELEASE_NEXUS_UPD_ID }} + NEXUS_UPD_PASS: ${{ secrets.RELEASE_NEXUS_UPD_PASS }} + SIGNING_KEY_ID: ${{ secrets.RELEASE_SIGNING_KEY_ID }} + SIGNING_KEY: ${{ secrets.RELEASE_SIGNING_KEY }} + run: | + chmod +x ./buildSrc/scripts/publish.sh + buildSrc/scripts/publish.sh + + - name: Release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + draft: true + prerelease: false + files: | + out/archives/** diff --git a/.github/workflows/publish_to_maven.yml b/.github/workflows/publish_to_maven.yml deleted file mode 100644 index 870c46c..0000000 --- a/.github/workflows/publish_to_maven.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Publish to Maven -on: workflow_dispatch -jobs: - publish-to-maven: - name: Publish to Maven - runs-on: ubuntu-latest - env: - NEXUS_UPD_ID: ${{ secrets.RELEASE_NEXUS_UPD_ID }} - NEXUS_UPD_PASS: ${{ secrets.RELEASE_NEXUS_UPD_PASS }} - SIGNING_KEY_ID: ${{ secrets.RELEASE_SIGNING_KEY_ID }} - SIGNING_KEY: ${{ secrets.RELEASE_SIGNING_KEY }} - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Setup Repository - run: | - chmod +x ./buildSrc/scripts/release.sh - chmod +x ./gradlew - - - name: Setup Java 8 - uses: actions/setup-java@v1 - with: - java-version: 8 - - - name: Release - run: ./buildSrc/scripts/release.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index fe48b46..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Release -on: - workflow_dispatch: - inputs: - version: - description: 'Version' - required: true -jobs: - release: - name: Release - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Up Version - uses: eskatos/gradle-command-action@v1 - with: - arguments: ${{ format('upVersion -Pnext={0}', github.event.inputs.version) }} - - - name: Commit Version - uses: EndBug/add-and-commit@v7 - with: - default_author: github_actions - message: ${{ format('v{0}', github.event.inputs.version) }} - - - name: Push Tag - uses: mathieudutour/github-tag-action@v5.5 - id: tag_version - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - custom_tag: ${{ github.event.inputs.version }} - - - name: Build All - uses: eskatos/gradle-command-action@v1 - with: - arguments: buildAll - - - name: Generate Changelog - id: changelog - uses: metcalfc/changelog-generator@v1.0.0 - with: - myToken: ${{ secrets.GITHUB_TOKEN }} - - - name: Release - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - body: ${{ steps.changelog.outputs.changelog }} - tag_name: ${{ steps.tag_version.outputs.new_tag }} - draft: true - prerelease: false - files: | - imgui-app/build/libs/*.jar - imgui-binding/build/libs/*.jar - imgui-lwjgl3/build/libs/*.jar - bin/imgui-java64.dll - bin/libimgui-java64.dylib - bin/libimgui-java64.so diff --git a/.github/workflows/update_natives.yml b/.github/workflows/update_natives.yml deleted file mode 100644 index c42e6aa..0000000 --- a/.github/workflows/update_natives.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Update Natives -on: workflow_dispatch -jobs: - update-natives: - name: Update Natives - runs-on: ubuntu-latest - steps: - - name: Download Natives - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ci.yml - branch: main - event: push - path: /tmp/artifacts - - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Update Natives - run: | - mv /tmp/artifacts/common/* bin/ - mv /tmp/artifacts/freetype/* bin/freetype/ - - - name: Commit Natives - uses: EndBug/add-and-commit@v7 - with: - default_author: github_actions - message: '[ci skip] Update native binaries' diff --git a/.gitignore b/.gitignore index e5d6d4f..f333580 100644 --- a/.gitignore +++ b/.gitignore @@ -25,10 +25,11 @@ logs/ *.tar.gz *.rar *.gpg +!vendor/freetype-2.12.1.tar.gz # Gradle .gradletasknamecache .gradle/ -!gradle/wrapper/*.jar build/ out/ +!gradle/wrapper/*.jar diff --git a/README.md b/README.md index 62330e2..0ca30a8 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,50 @@ -# imgui-java +
+ +# ImGui Java +#### JNI based binding for [Dear ImGui](https://github.com/ocornut/imgui) [![Github All Releases](https://img.shields.io/github/downloads/SpaiR/imgui-java/total.svg?logo=github)](https://github.com/SpaiR/imgui-java/releases) -[![CI](https://github.com/SpaiR/imgui-java/actions/workflows/ci.yml/badge.svg)](https://github.com/SpaiR/imgui-java/actions/workflows/ci.yml) [![Maven Central](https://img.shields.io/maven-central/v/io.github.spair/imgui-java-binding?logo=apache-maven)](https://search.maven.org/search?q=g:io.github.spair%20AND%20a:imgui-java-*) +[![CI](https://github.com/SpaiR/imgui-java/actions/workflows/ci.yml/badge.svg)](https://github.com/SpaiR/imgui-java/actions/workflows/ci.yml) [![binding javadoc](https://javadoc.io/badge2/io.github.spair/imgui-java-binding/javadoc_binding.svg?logo=java)](https://javadoc.io/doc/io.github.spair/imgui-java-binding) [![app javadoc](https://javadoc.io/badge2/io.github.spair/imgui-java-app/javadoc_app.svg?logo=java)](https://javadoc.io/doc/io.github.spair/imgui-java-app) +
+ --- -JNI based binding for [Dear ImGui](https://github.com/ocornut/imgui) with no dependencies.
-Read official [documentation](https://github.com/ocornut/imgui#usage) and [wiki](https://github.com/ocornut/imgui/wiki) to see how to work with Dear ImGui. -Almost everything from C++ could be done in Java in the same way. - -Binding has an OpenGL renderer and a GLFW backend implementation, using a [LWJGL3](https://www.lwjgl.org/) library. Could be found in [imgui-lwjgl3](https://github.com/SpaiR/imgui-java/blob/v1.86.4/imgui-lwjgl3) module.
-They are recommended, yet optional to use. The advantage of Dear ImGui is a portability, so feel free to copy-paste classes or write your own implementations.
- -Additionally, there is an [imgui-app](https://github.com/SpaiR/imgui-java/blob/v1.86.4/imgui-app) module, which provides **a high abstraction layer**.
-It hides all low-level stuff under one class to extend, so you can build your GUI application instantly. - ### Features + +- **JNI based**
+ Native communication layer made with generated JNI code. No dependencies, no problems. - **Small and Efficient**
- Binding has a very small memory footprint and uses direct native calls to work.
+ Binding has a small memory footprint and uses direct native calls to work.
- **Fully Featured**
All public API was carefully implemented with Java usage in mind.
-- **Multi-Viewports/Docking Branch**
+- **Multi-Viewports / Docking Branch**
Binding has a full support of [Multi-Viewports](https://github.com/ocornut/imgui/wiki/Multi-Viewports) and [Docking](https://github.com/ocornut/imgui/wiki/Docking).
- **FreeType Font Renderer**
FreeType font renderer provides a much better fonts quality. [See how to use](#freetype).
- **Extensions**
Binding includes several useful [extensions](https://github.com/ocornut/imgui/wiki/Useful-Extensions) for Dear ImGui. [See full list](#extensions). +To understand how to use ImGui Java - read official [documentation](https://github.com/ocornut/imgui#usage) and [wiki](https://github.com/ocornut/imgui/wiki). +Binding adopts C++ API for Java, but almost everything can be used in the same manner. + +ImGui Java has a ready to use implementation for GLFW and OpenGL API using [LWJGL3](https://www.lwjgl.org/) library. See `imgui-lwjgl3` module.
+Implementation is optional, yet optional to use. Advantage of Dear ImGui is total portability, so feel free to copy-paste classes or write your own implementations. + +Additionally, there is an `imgui-app` module, which provides **a high abstraction layer**.
+It hides all low-level code under one class to extend. With it, you can build your GUI application instantly. + +# Support +[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/P5P5BF17Q) + +You can support the project to motivate its further development. + # How to Try -_Make sure you have installed Java 8 or higher._ + +_**Make sure you have installed JDK 8 or higher.**_

@@ -40,27 +53,36 @@ _Make sure you have installed Java 8 or higher._ You can try binding by yourself in three simple steps: ``` -git clone --branch v1.86.4 https://github.com/SpaiR/imgui-java.git +git clone git@github.com:SpaiR/imgui-java.git cd imgui-java ./gradlew :example:run ``` -See [example](https://github.com/SpaiR/imgui-java/blob/v1.86.4/example) module to try other widgets in action. +See `example` module to try other widgets in action. # How to Use -**[ImGui in LWJGL YouTube video](https://youtu.be/Xq-eVcNtUbw)** by [GamesWithGabe](https://www.youtube.com/channel/UCQP4qSCj1eHMHisDDR4iPzw).
-You can use this video as a basic step-by-step tutorial. It shows how to integrate binding with the usage of jar files. Gradle and Maven dependecies could be used for this purpose as well. -Take a note, that integration itself is a very flexible process. It could be done in one way or another. If you just need a framework for your GUI - use **Application** module. Otherwise, if you need more control, the best way is not just to repeat steps, but to understand what each step does. +**[ImGui in LWJGL YouTube video](https://youtu.be/Xq-eVcNtUbw)** by [GamesWithGabe](https://www.youtube.com/channel/UCQP4qSCj1eHMHisDDR4iPzw).
+You can use this video as a basic step-by-step tutorial. It shows how to integrate binding with the usage of jar files.
+Gradle and Maven dependencies could be used for this purpose as well. + +Take a note, that integration itself is a very flexible process. It could be done in one way or another. If you just need a framework for your GUI - use [Application](#application) module. +Otherwise, if you need more control, the best way is not just to repeat steps, but to understand what each step does. ## Application -If you don't care about OpenGL or other low-level stuff, then you can use application layer from [imgui-app](https://github.com/SpaiR/imgui-java/blob/v1.86.4/imgui-app) module. -It is a **one jar solution** which includes: GLFW, OpenGL and Dear ImGui itself. So you only need **one dependency** line or **one jar in classpath** to make everything to work. You don't need to add separate dependencies to LWJGL or native libraries, since they are already included.
-Application module is the best choice if everything you care is the GUI for your app. -At the same time, Application gives an option to override any life-cycle method it has. That means that if you're seeking for a bit more low-level control - you can gain it too. +If you don't care about OpenGL and other low-level stuff, then you can use application layer from `imgui-app` module. +It is a **one jar solution** which includes: GLFW, OpenGL and Dear ImGui itself. +So you only need **one dependency** line or **one jar in classpath** to make everything to work. +You don't need to add separate dependencies to LWJGL or native libraries, since they are already included. + +**Application module is the best choice if everything you care is the GUI itself.** + +At the same time, Application gives options to override any life-cycle method it has. +That means that if you are seeking for a bit more low-level control - you can gain it as well. + +### Example -#### Example A very simple application may look like this: ``` import imgui.ImGui; @@ -82,9 +104,12 @@ public class Main extends Application { } } ``` + Read `imgui.app.Application` [javadoc](https://javadoc.io/doc/io.github.spair/imgui-java-app) to understand how it works under the hood. -#### Dependencies +### Dependencies + +![Maven Central](https://img.shields.io/maven-central/v/io.github.spair/imgui-java-binding?color=green&label=Version%20to%20use&style=flat-square)
Gradle @@ -95,7 +120,7 @@ repositories { } dependencies { - implementation "io.github.spair:imgui-java-app:1.86.4" + implementation "io.github.spair:imgui-java-app:${version}" } ```
@@ -108,7 +133,7 @@ dependencies { io.github.spair imgui-java-app - 1.86.4 + ${version} ``` @@ -123,16 +148,19 @@ dependencies { #### Java Module System + If using Java 9 modules, you will need to require the `imgui.app` module. - ## Binding -Using binding without the wrapper requires to "attach" it to your application manually. -You can refer to [imgui-app](https://github.com/SpaiR/imgui-java/blob/v1.86.4/imgui-app) module and see how things are done there. + +Using binding without `imgui-app` module requires to "attach" it to the application manually. +You can refer to `imgui-app` module to see how things are done there. ### Dependencies -For simplicity, example of dependencies for Gradle/Maven only shows how to add natives for Windows. -Feel free to add other platforms. + +![Maven Central](https://img.shields.io/maven-central/v/io.github.spair/imgui-java-binding?color=green&label=Version%20to%20use&style=flat-square) + +For simplicity, example of dependencies for Gradle / Maven only shows how to add natives for Windows. Feel free to add other platforms. | Native Binaries | System | |----------------------------|---------| @@ -140,7 +168,7 @@ Feel free to add other platforms. | imgui-java-natives-linux | Linux | | imgui-java-natives-macos | macOS | -Take a note, that you also need to add dependencies to [LWJGL](https://www.lwjgl.org/). Examples below shows how to do it as well. +Take a note, that you also need to add dependencies to [LWJGL](https://www.lwjgl.org/) library. Examples below shows how to do it as well.
Gradle @@ -152,7 +180,7 @@ repositories { ext { lwjglVersion = '3.3.1' - imguiVersion = '1.86.4' + imguiVersion = "${version}" } dependencies { @@ -177,7 +205,7 @@ dependencies { ``` 3.3.1 - 1.86.4 + ${version} @@ -253,7 +281,8 @@ dependencies {
#### Java Module System -If using Java 9 modules, imgui-java has Automatic Module Names: + +If using Java 9 modules, ImGui Java has Automatic Module Names: | Package | Module | |----------------------------|-----------------------| @@ -265,29 +294,36 @@ If using Java 9 modules, imgui-java has Automatic Module Names: | imgui-java-natives-macos | imgui.natives.macos | ## Extensions -- [ImNodes](https://github.com/Nelarius/imnodes/tree/857cc860af05ac0f6a4039c2af33d982377b6cf4) | [Example](https://github.com/SpaiR/imgui-java/blob/v1.86.4/example/src/main/java/ExampleImNodes.java)
- A small, dependency-free node editor for dear imgui. (A good choice for simple start.) -- [imgui-node-editor](https://github.com/thedmd/imgui-node-editor/tree/687a72f940c76cf5064e13fe55fa0408c18fcbe4) | [Example](https://github.com/SpaiR/imgui-java/blob/v1.86.4/example/src/main/java/ExampleImGuiNodeEditor.java)
+ +All extensions are already included in the binding and can be used as it is. +See examples in the `example` module for more information about how to use them. + +- [ImNodes](https://github.com/Nelarius/imnodes/tree/857cc860af05ac0f6a4039c2af33d982377b6cf4) | [Example](https://github.com/SpaiR/imgui-java/blob/main/example/src/main/java/ExampleImNodes.java)
+ A small, dependency-free node editor for Dear ImGui. (A good choice for simple start.) +- [imgui-node-editor](https://github.com/thedmd/imgui-node-editor/tree/687a72f940c76cf5064e13fe55fa0408c18fcbe4) | [Example](https://github.com/SpaiR/imgui-java/blob/main/example/src/main/java/ExampleImGuiNodeEditor.java)
Node Editor using ImGui. (A bit more complex than ImNodes, but has more features.) -- [ImGuizmo](https://github.com/CedricGuillemet/ImGuizmo/tree/f7bbbe39971d9d45816417a70e9b53a0f698c56e) | [Example](https://github.com/SpaiR/imgui-java/blob/v1.86.4/example/src/main/java/ExampleImGuizmo.java)
- Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui. -- [implot](https://github.com/epezent/implot/tree/555ff688a8134bc0c602123149abe9c17d577475) | [Example](https://github.com/SpaiR/imgui-java/blob/v1.86.4/example/src/main/java/ExampleImPlot.java)
+- [ImGuizmo](https://github.com/CedricGuillemet/ImGuizmo/tree/f7bbbe39971d9d45816417a70e9b53a0f698c56e) | [Example](https://github.com/SpaiR/imgui-java/blob/main/example/src/main/java/ExampleImGuizmo.java)
+ Immediate mode 3D gizmo for scene editing and other controls based on Dear ImGui. +- [implot](https://github.com/epezent/implot/tree/555ff688a8134bc0c602123149abe9c17d577475) | [Example](https://github.com/SpaiR/imgui-java/blob/main/example/src/main/java/ExampleImPlot.java)
Advanced 2D Plotting for Dear ImGui. -- [ImGuiColorTextEdit](https://github.com/BalazsJako/ImGuiColorTextEdit/tree/0a88824f7de8d0bd11d8419066caa7d3469395c4) | [Example](https://github.com/SpaiR/imgui-java/blob/v1.86.4/example/src/main/java/ExampleImGuiColorTextEdit.java)
+- [ImGuiColorTextEdit](https://github.com/BalazsJako/ImGuiColorTextEdit/tree/0a88824f7de8d0bd11d8419066caa7d3469395c4) | [Example](https://github.com/SpaiR/imgui-java/blob/main/example/src/main/java/ExampleImGuiColorTextEdit.java)
Syntax highlighting text editor for ImGui. -- [ImGuiFileDialog](https://github.com/aiekick/ImGuiFileDialog/tree/4d42dfba125cbd4780a90fbc5f75e7dfbae64060) | [Example](https://github.com/SpaiR/imgui-java/blob/v1.86.4/example/src/main/java/ExampleImGuiFileDialog.java)
+- [ImGuiFileDialog](https://github.com/aiekick/ImGuiFileDialog/tree/4d42dfba125cbd4780a90fbc5f75e7dfbae64060) | [Example](https://github.com/SpaiR/imgui-java/blob/main/example/src/main/java/ExampleImGuiFileDialog.java)
A file selection dialog built for ImGui. -- [ImGui Club MemoryEditor](https://github.com/ocornut/imgui_club/tree/d4cd9896e15a03e92702a578586c3f91bbde01e8) | [Example](https://github.com/SpaiR/imgui-java/blob/v1.86.4/example/src/main/java/ExampleImGuiMemoryEditor.java)
+- [ImGui Club MemoryEditor](https://github.com/ocornut/imgui_club/tree/d4cd9896e15a03e92702a578586c3f91bbde01e8) | [Example](https://github.com/SpaiR/imgui-java/blob/main/example/src/main/java/ExampleImGuiMemoryEditor.java)
Memory editor and viewer for ImGui. ## Freetype -By default, Dear ImGui uses stb-truetype to render fonts. Yet there is an option to use FreeType font renderer. Go to the [imgui_freetype](https://github.com/ocornut/imgui/tree/256594575d95d56dda616c544c509740e74906b4/misc/freetype) to read about the difference. -Binding has this option too. Freetype especially useful when you use custom font with small (~<16px) size. If you use the default font or a large font, stb will be fine for you. + +By default, Dear ImGui uses stb-truetype to render fonts. Yet there is an option to use FreeType font renderer. +Go to the [imgui_freetype](https://github.com/ocornut/imgui/tree/256594575d95d56dda616c544c509740e74906b4/misc/freetype) to read about the difference. +Binding has this option too. Freetype especially useful when you use custom font with small (~<16px) size. +If you use the default font or a large font, stb will be fine for you. There are two types of precompiled binaries: 1. with stb (the default one) 2. with freetype. You can decide by yourself, which kind of libraries for any system you want to use. -Take a note, that for Linux and Mac users using of freetype will add an additional dependency to the `libfreetype` itself. +Take a note, that for Linux and macOS users using of freetype will add a dependency to the `libfreetype` itself. This is not the case for Windows users, since `dll` binaries are compiled fully statically and already include freetype in themselves. **For fully portable application** use default binaries.
@@ -296,11 +332,14 @@ You can still use freetype binaries for Windows builds without worry though. **For better fonts** use freetype binaries.
Don't forget to make clear for your Linux/Mac users, that they will need to install freetype on their systems as well. -### How To Use FreeType -- Maven/Gradle:
- Use the same native libraries as you would, but with `-ft` suffix in the end. -
- Modified Gradle Example +### Dependencies + +![Maven Central](https://img.shields.io/maven-central/v/io.github.spair/imgui-java-binding?color=green&label=Version%20to%20use&style=flat-square) + +Use the same native libraries as you would, but with `-ft` suffix in the end. + +
+ Modified Gradle Example ``` repositories { @@ -309,7 +348,7 @@ Don't forget to make clear for your Linux/Mac users, that they will need to inst ext { lwjglVersion = '3.3.1' - imguiVersion = '1.86.4' + imguiVersion = "${version}" } dependencies { @@ -327,8 +366,7 @@ Don't forget to make clear for your Linux/Mac users, that they will need to inst implementation "io.github.spair:imgui-java-natives-windows-ft:$imguiVersion" } ``` -
-- If you're using raw dll/so files, go to the `bin/freetype` folder and take them from there. +
| Native Binaries With FreeType | System | |-------------------------------|---------| @@ -336,8 +374,11 @@ Don't forget to make clear for your Linux/Mac users, that they will need to inst | imgui-java-natives-linux-ft | Linux | | imgui-java-natives-macos-ft | macOS | +If you're using raw dll/so files, go to the `bin/freetype` folder and take them from there. + # Binding Notice -Binding was made with java usage in mind. Some places of the original library were adapted for that.
+ +Binding was made with Java usage in mind. Some places of the original library were adapted for that.
For example, in places where in C++ you need to pass a reference value, in Java you pass primitive wrappers: `ImInt`, `ImFloat` etc.
One important thing is how natives structs work. All of them have a public field with a pointer to the natively allocated memory.
@@ -347,36 +388,36 @@ Most of the time you can ignore this fact and just work with objects in a common Read [javadoc](https://javadoc.io/doc/io.github.spair/imgui-java-binding) and source comments to get more info about how to do specific stuff. # How to Build Native Libraries + Ensure you've downloaded git submodules. That could be achieved: - When cloning the repository: `git clone --recurse-submodules https://github.com/SpaiR/imgui-java.git` - When the repository cloned: `git submodule init` + `git submodule update` ### Windows + - Make sure you have installed and **available in PATH**: - * Java 8 or higher + * JDK 8 or higher * Ant * Mingw-w64 (recommended way: use [MSYS2](https://www.msys2.org/) and install [mingw-w64-x86_64-toolchain](https://packages.msys2.org/group/mingw-w64-x86_64-toolchain) group) - - Build with: `./gradlew :imgui-binding:generateLibs -Denvs=win -Dlocal` - - Run with: `./gradlew :example:run -PlibPath="../imgui-binding/build/libsNative/windows64"` + - Build with: `./gradlew imgui-binding:generateLibs -Denvs=windows -Dlocal` + - Run with: `./gradlew example:run -PlibPath="../imgui-binding/build/libsNative/windows64"` ### Linux + - Install dependencies: `openjdk8`, `mingw-w64-gcc`, `ant`. (Package names could vary from system to system.) - - Build with: `./gradlew :imgui-binding:generateLibs -Denvs=linux -Dlocal` - - Run with: `./gradlew :example:run -PlibPath=../imgui-binding/build/libsNative/linux64` + - Build with: `./gradlew imgui-binding:generateLibs -Denvs=linux -Dlocal` + - Run with: `./gradlew example:run -PlibPath=../imgui-binding/build/libsNative/linux64` ### macOS - - Check dependencies from "Linux" section and make sure you have them installed. - - Build with: `./gradlew :imgui-binding:generateLibs -Denvs=mac -Dlocal` - - Run with: `./gradlew :example:run -PlibPath=../imgui-binding/build/libsNative/macosx64` -In `envs` parameter next values could be used `win`, `linux` or `mac`.
+ - Check dependencies from "Linux" section and make sure you have them installed. + - Build with: `./gradlew imgui-binding:generateLibs -Denvs=macos -Dlocal` + - Run with: `./gradlew example:run -PlibPath=../imgui-binding/build/libsNative/macosx64` + +In `envs` parameter next values could be used `windows`, `linux` or `macos`.
`-Dlocal` is optional and means that natives will be built under the `./imgui-binding/build/` folder. Otherwise `/tmp/imgui` folder will be used. On Windows always use local build. -# Support -[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/P5P5BF17Q) - -You can support the project to motivate its further development. - # License + See the LICENSE file for license rights and limitations (Apache-2.0). diff --git a/build.gradle b/build.gradle index 7aa0cb3..64064a6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -import tool.UpVersion +import java.text.SimpleDateFormat ext { lwjglVersion = '3.3.1' @@ -6,19 +6,39 @@ ext { allprojects { group 'imgui-java' - version property('version') + version 'git describe --tags --always'.execute().text.trim().substring(1) repositories { mavenCentral() } - tasks.withType(JavaCompile) { - sourceCompatibility = JavaVersion.VERSION_1_8 + tasks.withType(JavaCompile).tap { + configureEach { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + } + + tasks.withType(Jar).tap { + configureEach { + from(project.rootDir) { + include 'LICENSE' + } + + manifest { + attributes ( + 'Implementation-Title': project.name, + 'Implementation-Version': project.version, + 'Build-Timestamp': new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(System.currentTimeMillis()), + 'Build-Revision': 'git rev-parse HEAD'.execute().text.trim(), + 'Build-Jdk': "${System.getProperty('java.version')} (${System.getProperty('java.vendor')})", + 'Created-By': "Gradle ${gradle.gradleVersion}" + ) + } + } } } -tasks.register('upVersion', UpVersion) - tasks.register('buildAll') { t -> t.group = 'build' t.description = 'Build all project sources.' diff --git a/buildSrc/scripts/build-ft-local.sh b/buildSrc/scripts/build-ft-local.sh deleted file mode 100644 index 7acbe0e..0000000 --- a/buildSrc/scripts/build-ft-local.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -BASEDIR=$(dirname "$0") -cd $BASEDIR/../../imgui-binding || exit - -../gradlew clean generateLibs -Denvs=$* -Dlocal -Dfreetype=true -rm -frd libsNative diff --git a/buildSrc/scripts/build-ft.sh b/buildSrc/scripts/build-ft.sh deleted file mode 100644 index 906f9c7..0000000 --- a/buildSrc/scripts/build-ft.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -BASEDIR=$(dirname "$0") -cd $BASEDIR/../../imgui-binding || exit - -rm -frd /tmp/imgui -../gradlew clean generateLibs -Denvs=$* -Dfreetype=true diff --git a/buildSrc/scripts/build-local.sh b/buildSrc/scripts/build-local.sh deleted file mode 100644 index e3753bb..0000000 --- a/buildSrc/scripts/build-local.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -BASEDIR=$(dirname "$0") -cd $BASEDIR/../../imgui-binding || exit - -../gradlew clean generateLibs -Denvs=$* -Dlocal -rm -frd libsNative diff --git a/buildSrc/scripts/build.sh b/buildSrc/scripts/build.sh deleted file mode 100644 index c6f6d51..0000000 --- a/buildSrc/scripts/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -BASEDIR=$(dirname "$0") -cd $BASEDIR/../../imgui-binding || exit - -rm -frd /tmp/imgui -../gradlew clean generateLibs -Denvs=$* diff --git a/buildSrc/scripts/copy-ft.sh b/buildSrc/scripts/copy-ft.sh deleted file mode 100644 index 2aac9bb..0000000 --- a/buildSrc/scripts/copy-ft.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -BASEDIR=$(dirname "$0") -cd $BASEDIR/../.. || exit - -mkdir ./bin/freetype - -[ -e "/tmp/imgui/libsNative/windows32/imgui-java.dll" ] && cp /tmp/imgui/libsNative/windows32/imgui-java.dll ./bin/freetype -[ -e "/tmp/imgui/libsNative/windows64/imgui-java64.dll" ] && cp /tmp/imgui/libsNative/windows64/imgui-java64.dll ./bin/freetype -[ -e "/tmp/imgui/libsNative/linux32/libimgui-java.so" ] && cp /tmp/imgui/libsNative/linux32/libimgui-java.so ./bin/freetype -[ -e "/tmp/imgui/libsNative/linux64/libimgui-java64.so" ] && cp /tmp/imgui/libsNative/linux64/libimgui-java64.so ./bin/freetype -[ -e "/tmp/imgui/libsNative/macosx64/libimgui-java64.dylib" ] && cp /tmp/imgui/libsNative/macosx64/libimgui-java64.dylib ./bin/freetype diff --git a/buildSrc/scripts/copy.sh b/buildSrc/scripts/copy.sh deleted file mode 100644 index 37aa427..0000000 --- a/buildSrc/scripts/copy.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -BASEDIR=$(dirname "$0") -cd $BASEDIR/../.. || exit - -[ -e "/tmp/imgui/libsNative/windows32/imgui-java.dll" ] && cp /tmp/imgui/libsNative/windows32/imgui-java.dll ./bin -[ -e "/tmp/imgui/libsNative/windows64/imgui-java64.dll" ] && cp /tmp/imgui/libsNative/windows64/imgui-java64.dll ./bin -[ -e "/tmp/imgui/libsNative/linux32/libimgui-java.so" ] && cp /tmp/imgui/libsNative/linux32/libimgui-java.so ./bin -[ -e "/tmp/imgui/libsNative/linux64/libimgui-java64.so" ] && cp /tmp/imgui/libsNative/linux64/libimgui-java64.so ./bin -[ -e "/tmp/imgui/libsNative/macosx64/libimgui-java64.dylib" ] && cp /tmp/imgui/libsNative/macosx64/libimgui-java64.dylib ./bin diff --git a/buildSrc/scripts/publish.sh b/buildSrc/scripts/publish.sh new file mode 100644 index 0000000..d40dcbf --- /dev/null +++ b/buildSrc/scripts/publish.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +BASEDIR=$(dirname "$0") +cd $BASEDIR/../.. || exit + +echo '> Publishing Modules...' +echo '>> Module [imgui-app]' +./gradlew imgui-app:publishImguiPublicationToMavenCentralRepository +echo '>> Module [imgui-lwjgl3]' +./gradlew imgui-lwjgl3:publishImguiPublicationToMavenCentralRepository +echo '>> Module [imgui-binding]' +./gradlew imgui-binding:publishImguiPublicationToMavenCentralRepository + +echo '> Publishing Natives...' +echo '>> Natives: [windows, freetype]' +./gradlew imgui-binding-natives:publishImguiPublicationToMavenCentralRepository -PdeployType=windows -Pfreetype=true +echo '>> Natives: [windows]' +./gradlew imgui-binding-natives:publishImguiPublicationToMavenCentralRepository -PdeployType=windows -Pfreetype=false +echo '>> Natives: [linux, freetype]' +./gradlew imgui-binding-natives:publishImguiPublicationToMavenCentralRepository -PdeployType=linux -Pfreetype=true +echo '>> Natives: [linux]' +./gradlew imgui-binding-natives:publishImguiPublicationToMavenCentralRepository -PdeployType=linux -Pfreetype=false +echo '>> Natives: [macOS, freetype]' +./gradlew imgui-binding-natives:publishImguiPublicationToMavenCentralRepository -PdeployType=macos -Pfreetype=true +echo '>> Natives: [macOS]' +./gradlew imgui-binding-natives:publishImguiPublicationToMavenCentralRepository -PdeployType=macos -Pfreetype=false diff --git a/buildSrc/scripts/release.sh b/buildSrc/scripts/release.sh deleted file mode 100644 index 172858f..0000000 --- a/buildSrc/scripts/release.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -BASEDIR=$(dirname "$0") -cd $BASEDIR/../.. || exit - -echo '> Publishing Modules...' -echo '>> Module [imgui-app]' -./gradlew :imgui-app:publishMavenJavaPublicationToMavenCentralRepository -echo '>> Module [imgui-lwjgl3]' -./gradlew :imgui-lwjgl3:publishMavenJavaPublicationToMavenCentralRepository -echo '>> Module [imgui-binding]' -./gradlew :imgui-binding:publishMavenJavaPublicationToMavenCentralRepository - -echo '> Publishing Natives...' -echo '>> Natives: [win & freetype]' -./gradlew :imgui-binding-natives:publishMavenJavaPublicationToMavenCentralRepository -PdeployType=win -Pfreetype=true -echo '>> Natives: [win & no freetype]' -./gradlew :imgui-binding-natives:publishMavenJavaPublicationToMavenCentralRepository -PdeployType=win -Pfreetype=false -echo '>> Natives: [linux & freetype]' -./gradlew :imgui-binding-natives:publishMavenJavaPublicationToMavenCentralRepository -PdeployType=linux -Pfreetype=true -echo '>> Natives: [linux & no freetype]' -./gradlew :imgui-binding-natives:publishMavenJavaPublicationToMavenCentralRepository -PdeployType=linux -Pfreetype=false -echo '>> Natives: [mac & freetype]' -./gradlew :imgui-binding-natives:publishMavenJavaPublicationToMavenCentralRepository -PdeployType=mac -Pfreetype=true -echo '>> Natives: [mac & no freetype]' -./gradlew :imgui-binding-natives:publishMavenJavaPublicationToMavenCentralRepository -PdeployType=mac -Pfreetype=false diff --git a/buildSrc/src/main/groovy/tool/UpVersion.groovy b/buildSrc/src/main/groovy/tool/UpVersion.groovy deleted file mode 100644 index e0f7cf4..0000000 --- a/buildSrc/src/main/groovy/tool/UpVersion.groovy +++ /dev/null @@ -1,35 +0,0 @@ -package tool - -import org.gradle.api.DefaultTask -import org.gradle.api.tasks.Internal -import org.gradle.api.tasks.TaskAction - -class UpVersion extends DefaultTask { - @Internal - String group = 'build' - @Internal - String description = 'Up project version to the next one.' - - @TaskAction - void up() { - String currentVersion = project.findProperty('version') - String nextVersion = project.findProperty('next') - - if (!currentVersion) { - throw new IllegalStateException('No property was found: "version"') - } - if (!nextVersion) { - throw new IllegalStateException('No property was found: "next"') - } - - println "Up project version: $nextVersion..." - - println 'Updating gradle.properties...' - def propsFile = project.file('gradle.properties') - propsFile.text = propsFile.text.replace("version=$currentVersion", "version=$nextVersion") - - println 'Updating README.md...' - def readmeFile = project.file('README.md') - readmeFile.text = readmeFile.text.replace(currentVersion, nextVersion) - } -} diff --git a/buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy b/buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy index 7a7f6f2..52e70d0 100644 --- a/buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy +++ b/buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy @@ -16,9 +16,9 @@ class GenerateLibs extends DefaultTask { String description = 'Generate imgui-java native binaries.' private final String[] buildEnvs = System.getProperty('envs')?.split(',') - private final boolean forWindows = buildEnvs?.contains('win') + private final boolean forWindows = buildEnvs?.contains('windows') private final boolean forLinux = buildEnvs?.contains('linux') - private final boolean forMac = buildEnvs?.contains('mac') + private final boolean forMac = buildEnvs?.contains('macos') private final boolean isLocal = System.properties.containsKey('local') private final boolean withFreeType = Boolean.valueOf(System.properties.getProperty('freetype', 'false')) diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 8b6bf49..0000000 --- a/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -version=1.86.4 diff --git a/imgui-app/build.gradle b/imgui-app/build.gradle index 9e70faf..ee0eaf4 100644 --- a/imgui-app/build.gradle +++ b/imgui-app/build.gradle @@ -48,4 +48,4 @@ shadowJar { } apply from: "$rootDir/publish.gradle" -configurePublishing('imgui-java-app', 'Application wrapper for Dear ImGui') +configurePublishing('imgui-java-app', 'Application wrapper for Dear ImGui', project.version) diff --git a/imgui-binding-natives/build.gradle b/imgui-binding-natives/build.gradle index 6b37d2c..4d3eb55 100644 --- a/imgui-binding-natives/build.gradle +++ b/imgui-binding-natives/build.gradle @@ -48,4 +48,4 @@ jar { } apply from: "$rootDir/publish.gradle" -configurePublishing(packageName, packageDesc) +configurePublishing(packageName, packageDesc, project.version) diff --git a/imgui-binding/build.gradle b/imgui-binding/build.gradle index 3deefdf..b28535c 100644 --- a/imgui-binding/build.gradle +++ b/imgui-binding/build.gradle @@ -21,7 +21,7 @@ tasks.register('generateLibs', GenerateLibs) { } apply from: "$rootDir/publish.gradle" -configurePublishing('imgui-java-binding', 'JNI based binding for Dear ImGui') +configurePublishing('imgui-java-binding', 'JNI based binding for Dear ImGui', project.version) jar { manifest { diff --git a/imgui-lwjgl3/build.gradle b/imgui-lwjgl3/build.gradle index 5ea842a..d39a696 100644 --- a/imgui-lwjgl3/build.gradle +++ b/imgui-lwjgl3/build.gradle @@ -16,7 +16,7 @@ dependencies { } apply from: "$rootDir/publish.gradle" -configurePublishing('imgui-java-lwjgl3', 'Backend LWJGL3 implementation for imgui-java') +configurePublishing('imgui-java-lwjgl3', 'Backend LWJGL3 implementation for imgui-java', project.version) jar { manifest { diff --git a/publish.gradle b/publish.gradle index f503a2c..e29d81b 100644 --- a/publish.gradle +++ b/publish.gradle @@ -1,4 +1,4 @@ -ext.configurePublishing = { packageName, packageDesc -> +ext.configurePublishing = { packageName, packageDesc, packageVersion -> tasks.register('sourcesJar', Jar) { it.dependsOn classes it.archiveClassifier.set('sources') @@ -23,10 +23,10 @@ ext.configurePublishing = { packageName, packageDesc -> } } publications { - mavenJava(MavenPublication) { + imgui(MavenPublication) { groupId = 'io.github.spair' artifactId = packageName - version = property('version') + version = packageVersion from components.java artifact sourcesJar diff --git a/vendor/freetype-2.12.1.tar.gz b/vendor/freetype-2.12.1.tar.gz new file mode 100644 index 0000000..0d1b56d Binary files /dev/null and b/vendor/freetype-2.12.1.tar.gz differ