>().configureEach { compilerOptions.freeCompilerArgs.addAll("-opt-in=kotlin.RequiresOptIn", "-Xallow-kotlin-package") }
33 | test { useJUnitPlatform() }
34 | }
35 |
36 | publishing {
37 | publications {
38 | createGithubPublication {
39 | from(components["java"])
40 | artifactId = "${rootProject.name}-${project.name}"
41 | suppressAllPomMetadataWarnings()
42 | }
43 | }
44 | repositories.github { domain = "kotlin-graphics/mary" }
45 | }
46 |
47 | java.withSourcesJar()
--------------------------------------------------------------------------------
/glfw/src/main/java/module-info:
--------------------------------------------------------------------------------
1 | module kotlin.graphics.imgui.glfw {
2 |
3 | requires kotlin.stdlib;
4 |
5 | requires kotlin.graphics.imgui.core;
6 | requires kotlin.graphics.uno.core;
7 | requires kotlin.graphics.glm;
8 | requires kotlin.graphics.kool;
9 |
10 | requires org.lwjgl.glfw;
11 |
12 | exports imgui.impl.glfw;
13 | }
--------------------------------------------------------------------------------
/glfw/src/main/kotlin/imgui/impl/glfw/wndProc hook.kt:
--------------------------------------------------------------------------------
1 | package imgui.impl.glfw
2 |
3 | import imgui.ImGui
4 | import imgui.MouseSource
5 | import org.lwjgl.system.*
6 | import org.lwjgl.system.libffi.FFICIF
7 | import org.lwjgl.system.libffi.LibFFI
8 | import org.lwjgl.system.windows.User32
9 |
10 | typealias WNDPROC = Long
11 | typealias LPARAM = Long
12 |
13 | // GLFW doesn't allow to distinguish Mouse vs TouchScreen vs Pen.
14 | // Add support for Win32 (based on imgui_impl_win32), because we rely on _TouchScreen info to trickle inputs differently.
15 | val mouseSourceFromMessageExtraInfo: MouseSource
16 | get() {
17 | val extraInfo: LPARAM = User32.GetMessageExtraInfo()
18 | return when {
19 | (extraInfo and 0xFFFFFF80) == 0xFF515700 -> MouseSource.Pen
20 | (extraInfo and 0xFFFFFF80) == 0xFF515780 -> MouseSource.TouchScreen
21 | else -> MouseSource.Mouse
22 | }
23 | }
24 |
25 | //static LRESULT CALLBACK ImGui_ImplGlfw_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
26 | //{
27 | // ImGui_ImplGlfw_Data * bd = ImGui_ImplGlfw_GetBackendData()
28 | // switch(msg)
29 | // {
30 | // case WM_MOUSEMOVE : case WM_NCMOUSEMOVE:
31 | // case WM_LBUTTONDOWN : case WM_LBUTTONDBLCLK: case WM_LBUTTONUP:
32 | // case WM_RBUTTONDOWN : case WM_RBUTTONDBLCLK: case WM_RBUTTONUP:
33 | // case WM_MBUTTONDOWN : case WM_MBUTTONDBLCLK: case WM_MBUTTONUP:
34 | // case WM_XBUTTONDOWN : case WM_XBUTTONDBLCLK: case WM_XBUTTONUP:
35 | // ImGui::GetIO().AddMouseSourceEvent(GetMouseSourceFromMessageExtraInfo())
36 | // break
37 | // }
38 | // return ::CallWindowProc(bd->GlfwWndProc, hWnd, msg, wParam, lParam)
39 | //}
40 |
41 | /**
42 | * Instances of this interface may be passed to the [SetWindowFocusCallback][GLFW.glfwSetWindowFocusCallback] method.
43 | *
44 | * Type
45 | *
46 | * `
47 | * void (*[.invoke]) (
48 | * GLFWwindow *window,
49 | * int focused
50 | * )`
51 | *
52 | * @since version 3.0
53 | */
54 | @FunctionalInterface
55 | @NativeType("ImplGlfw_WndProc")
56 | interface ImplGlfw_WndProcI : CallbackI {
57 | override fun getCallInterface(): FFICIF = CIF
58 |
59 | override fun callback(ret: Long, args: Long) {
60 | invoke(MemoryUtil.memGetAddress(MemoryUtil.memGetAddress(args)),
61 | MemoryUtil.memGetInt(MemoryUtil.memGetAddress(args + Pointer.POINTER_SIZE)) != 0)
62 | }
63 |
64 | /**
65 | * Will be called when the specified window gains or loses focus.
66 | *
67 | * @param window the window that was focused or defocused
68 | * @param focused [TRUE][GLFW.GLFW_TRUE] if the window was focused, or [FALSE][GLFW.GLFW_FALSE] if it was defocused
69 | */
70 | operator fun invoke(@NativeType("GLFWwindow *") window: Long, @NativeType("int") focused: Boolean)
71 |
72 | companion object {
73 | val CIF = APIUtil.apiCreateCIF(
74 | LibFFI.FFI_DEFAULT_ABI,
75 | LibFFI.ffi_type_void,
76 | LibFFI.ffi_type_uint32, LibFFI.ffi_type_uint32, LibFFI.ffi_type_uint32, LibFFI.ffi_type_uint32
77 | )
78 | }
79 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-XX:MaxMetaspaceSize=1g
2 | org.gradle.daemon=false
3 | systemProp.alignVerbose=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlin-graphics/imgui/665b1032094c4f342a4306c0d3adcc944d87d0e7/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | zipStoreBase=GRADLE_USER_HOME
3 | zipStorePath=wrapper/dists
4 | distributionPath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
6 | distributionSha256Sum=ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7
7 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/imgui.ini:
--------------------------------------------------------------------------------
1 | [Window][Debug##Default]
2 | Pos=60,60
3 | Size=400,400
4 | Collapsed=0
5 |
6 | [Window][Hello, world!]
7 | Pos=60,60
8 | Size=339,197
9 | Collapsed=0
10 |
11 | [Window][Dear ImGui Demo]
12 | Pos=650,20
13 | Size=550,680
14 | Collapsed=0
15 |
16 | [Window][Example: Custom rendering]
17 | Pos=60,60
18 | Size=485,414
19 | Collapsed=0
20 |
21 |
--------------------------------------------------------------------------------
/imgui_perflog.csv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlin-graphics/imgui/665b1032094c4f342a4306c0d3adcc944d87d0e7/imgui_perflog.csv
--------------------------------------------------------------------------------
/jogl/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java'
3 | id "org.jetbrains.kotlin.jvm"
4 | id "com.github.johnrengelman.shadow"
5 | }
6 |
7 | ext.moduleName = "$group.jogl"
8 |
9 | dependencies {
10 | // implementation "$kot-stdlib-jdk8"
11 | // implementation project(':core')
12 | // implementation "${kx}.glm:glm:$glm_version"
13 | // implementation "$kx:uno-sdk:$uno_version"
14 | // implementation "$kx:gln:$gln_version"
15 | // implementation "$kx:kool:$kool_version"
16 |
17 | def joglVersion = '2.3.2'
18 | implementation "org.jogamp.gluegen:gluegen-rt-main:$joglVersion"
19 | implementation "org.jogamp.jogl:jogl-all-main:$joglVersion"
20 |
21 | [""].each {
22 | // String base = "org.lwjgl:lwjgl$it:$lwjgl_version"
23 | // implementation base
24 | // String natives = "$base:natives-$lwjgl_natives"
25 | // testRuntimeOnly natives
26 | // shadow natives
27 | }
28 |
29 | testImplementation group: 'junit', name: 'junit', version: '4.12'
30 | }
31 |
32 | task lightJar(type: Jar) {
33 | archiveClassifier = 'light'
34 | from sourceSets.main.output
35 | exclude 'extraFonts'
36 | inputs.property("moduleName", moduleName)
37 | // manifest.attributes('Automatic-Module-Name': moduleName)
38 | duplicatesStrategy = DuplicatesStrategy.EXCLUDE
39 | }
40 |
41 | task sourcesJar(type: Jar, dependsOn: classes) {
42 | archiveClassifier = 'sources'
43 | from sourceSets.main.allSource
44 | }
45 |
46 | task javadocJar(type: Jar, dependsOn: javadoc) {
47 | archiveClassifier = 'javadoc'
48 | from javadoc.destinationDir
49 | }
50 |
51 | artifacts {
52 | archives lightJar
53 | archives sourcesJar
54 | // archives javadocJar
55 | }
56 |
57 | shadowJar {
58 | exclude 'module-info.class'
59 | inputs.property("moduleName", moduleName)
60 | // manifest.attributes('Automatic-Module-Name': moduleName)
61 | }
62 |
63 | jar {
64 | inputs.property("moduleName", moduleName)
65 | // manifest.attributes('Automatic-Module-Name': moduleName)
66 | }
67 |
68 | shadowJar.archiveClassifier = 'all'
69 |
70 | compileKotlin {
71 | kotlinOptions.jvmTarget = "11"
72 | destinationDir = compileJava.destinationDir
73 | }
74 | compileTestKotlin {
75 | kotlinOptions.jvmTarget = "11"
76 | destinationDir = compileTestJava.destinationDir
77 | }
78 |
79 | compileJava {
80 | dependsOn(':compileKotlin')
81 | inputs.property("moduleName", moduleName)
82 | doFirst {
83 | options.compilerArgs = [
84 | '--module-path', classpath.asPath,
85 | '--patch-module', "$moduleName=${sourceSets["main"].output.asPath}"]
86 | classpath = files()
87 | }
88 | }
89 |
90 | jar { duplicatesStrategy = DuplicatesStrategy.EXCLUDE }
--------------------------------------------------------------------------------
/jogl/src/main/java/module-info.java:
--------------------------------------------------------------------------------
1 | module com.github.kotlin_graphics.imgui_jogl {
2 |
3 | requires kotlin.stdlib;
4 |
5 | requires jogl.all;
6 | requires org.lwjgl;
7 |
8 | requires com.github.kotlin_graphics.glm;
9 | requires com.github.kotlin_graphics.gln;
10 | requires com.github.kotlin_graphics.kool;
11 | }
--------------------------------------------------------------------------------
/openjfx/src/main/java/module-info.java:
--------------------------------------------------------------------------------
1 | module kotlin.graphics.imgui.openjfx {
2 |
3 | requires javafx.graphics;
4 |
5 | requires kotlin.stdlib;
6 |
7 | requires kotlin.graphics.imgui.core;
8 | requires kotlin.graphics.glm;
9 | }
--------------------------------------------------------------------------------
/openjfx/src/main/kotlin/imgui/impl/OpenJFXDummyMain.kt:
--------------------------------------------------------------------------------
1 | package imgui.impl
2 |
3 | import javafx.application.Application
4 | import javafx.stage.Stage
5 | import kotlin.system.exitProcess
6 |
7 | class OpenJFXDummyMain: Application() {
8 | override fun start(primaryStage: Stage?) { exitProcess(0) }
9 | }
--------------------------------------------------------------------------------
/platform/platform.gradle.kts:
--------------------------------------------------------------------------------
1 |
2 | plugins {
3 | `java-platform`
4 | }
5 |
6 | dependencies {
7 | // The platform declares constraints on all components that require alignment
8 | constraints {
9 | api(projects.core)
10 | api(projects.gl)
11 | api(projects.glfw)
12 | }
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 |
2 | pluginManagement {
3 | repositories {
4 | gradlePluginPortal()
5 | // maven("https://raw.githubusercontent.com/kotlin-graphics/mary/master")
6 | // maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/")
7 | }
8 | // includeBuild("../build-logic")
9 | }
10 |
11 | rootProject.name = "imgui"
12 |
13 | for(module in listOf("core", "glfw", "gl"/*,"vk", "jogl",*//* "openjfx"*//*, "bgfx"*/, "platform")) {
14 | include(module)
15 | project(":$module").buildFileName = "$module.gradle.kts"
16 | }
17 |
18 | //enableFeaturePreview("VERSION_CATALOGS")
19 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
20 |
21 | gradle.rootProject {
22 | group = "kotlin.graphics"
23 | version = "1.89.7-1"
24 | }
25 |
26 | dependencyResolutionManagement {
27 | repositories {
28 | mavenCentral()
29 | maven("https://raw.githubusercontent.com/kotlin-graphics/mary/master")
30 | maven(url = "https://jitpack.io") // still needed for sealed-enums
31 | }
32 | }
--------------------------------------------------------------------------------
/vk/src/main/java/module-info.java:
--------------------------------------------------------------------------------
1 | module kotlin.graphics.imgui.vk {
2 |
3 | requires kotlin.stdlib;
4 |
5 | requires org.lwjgl;
6 | requires org.lwjgl.glfw;
7 | requires org.lwjgl.vulkan;
8 |
9 | requires kotlin.graphics.imgui.core;
10 | requires kotlin.graphics.imgui.glfw;
11 |
12 | requires kotlin.graphics.glm;
13 | requires kotlin.graphics.kool;
14 | requires kotlin.graphics.vkk;
15 | requires kotlin.graphics.gli;
16 | requires kotlin.graphics.uno.core;
17 | requires kotlin.graphics.uno.vk;
18 | }
--------------------------------------------------------------------------------
/vk/src/main/kotlin/imgui/impl/vk/tmp.kt:
--------------------------------------------------------------------------------
1 | package imgui.impl.vk
2 |
3 | import kool.Ptr
4 | import org.lwjgl.system.MemoryStack
5 | import org.lwjgl.system.MemoryUtil
6 | import vkk.*
7 | import vkk.entities.*
8 | import vkk.extensions.VkColorSpaceKHR
9 | import vkk.identifiers.CommandBuffer
10 | import vkk.identifiers.Device
11 | import vkk.vk10.structs.*
12 |
13 | // glfw -> T : MemoryStack (for VkStack)
14 | // inline fun loop(block: (MemoryStack) -> Unit) = loop({ isOpen }, block)
15 |
16 | // enum for all reports flags
--------------------------------------------------------------------------------