diff --git a/.gitignore b/.gitignore index c5ceab45..323c8483 100644 --- a/.gitignore +++ b/.gitignore @@ -1,42 +1,49 @@ -/.idea/workspace.xml -/.idea/usage.statistics.xml -/nbproject/private/ -/bin -/wiki -.DS_Store -*.bat -*.conf -*.dll -*.dylib -*.jar -*.jpg -*.mhr -*.obj -*.ogg -*.sh -*.so -*.ttf -*.wav -*.zip -touch.txt +.run/ +run/ .gradle build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ -# Ignore Gradle GUI config -gradle-app.setting +### IntelliJ IDEA ### +.idea/ +#.idea/modules.xml +#.idea/jarRepositories.xml +#.idea/compiler.xml +#.idea/libraries/ +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ -# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) -!gradle-wrapper.jar -!gradlew.bat +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ -# Cache of project -.gradletasknamecache +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ -# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 -# gradle/wrapper/gradle-wrapper.properties +### VS Code ### +.vscode/ -.idea/ -out/ +### Mac OS ### +.DS_Store -run/ +natives/ +.kotlin/ diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 3149b10f..e0a6190b 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,3 +1,5 @@ -plugins { `kotlin-dsl` } +plugins { + kotlin("jvm") version "2.0.0" +} repositories { mavenCentral() } diff --git a/buildSrc/src/main/kotlin/myproject.java-conventions.gradle.kt b/buildSrc/src/main/kotlin/myproject.java-conventions.gradle.kt index 741d2509..33bdd136 100644 --- a/buildSrc/src/main/kotlin/myproject.java-conventions.gradle.kt +++ b/buildSrc/src/main/kotlin/myproject.java-conventions.gradle.kt @@ -32,21 +32,17 @@ enum class NativePlatform( WIN_64("windows", "x64", classifier = "windows", nativeLibPrefix = "", nativeLibSuffix = ".dll"), WIN_ARM64("windows", "arm64", nativeLibPrefix = "", nativeLibSuffix = ".dll"); - companion object { - val ALL = values() - } - val classifier = "natives-$classifier" } enum class NativeBinding( val bindingName: String, val basename: String, - vararg val platforms: NativePlatform + val platforms: List ) { - GLFW("glfw", "glfw", *NativePlatform.ALL), - NFD("nfd", "nfd", *NativePlatform.ALL), - STB("stb", "stb", *NativePlatform.ALL) + GLFW("glfw", "glfw", NativePlatform.entries), + NFD("nfd", "nfd", NativePlatform.entries), + STB("stb", "stb", NativePlatform.entries) } enum class Artifact( diff --git a/generators/build.gradle.kts b/generators/build.gradle.kts index 8aa54cd7..47b94120 100644 --- a/generators/build.gradle.kts +++ b/generators/build.gradle.kts @@ -1,3 +1,4 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile /* @@ -16,7 +17,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile * copies or substantial portions of the Software. */ -plugins { embeddedKotlin("jvm") } +plugins { kotlin("jvm") version "2.0.0" } allprojects { apply(plugin = "org.jetbrains.kotlin.jvm") @@ -28,7 +29,7 @@ allprojects { repositories { mavenCentral() } tasks.withType { - kotlinOptions { jvmTarget = kotlinTargetJdkVersion } + compilerOptions { jvmTarget.set(JvmTarget.fromTarget(kotlinTargetJdkVersion)) } } tasks.withType { diff --git a/gradle.properties b/gradle.properties index 82a1615b..83a306fe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,5 +19,5 @@ jdkEnablePreview=true #jdkEarlyAccessDoc=jdk22 kotlinTargetJdkVersion=21 -overrunMarshalVersion=0.1.0-alpha.26-jdk22 +overrunMarshalVersion=0.1.0-alpha.28-jdk22 overrunPlatformVersion=1.0.0 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136..2c352119 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23a..09523c0e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a42..f5feea6d 100644 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 25da30db..9d21a218 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## diff --git a/modules/overrungl.glfw/src/main/java/overrungl/glfw/GLFW.java b/modules/overrungl.glfw/src/main/java/overrungl/glfw/GLFW.java index ac39a8ea..5144b303 100644 --- a/modules/overrungl.glfw/src/main/java/overrungl/glfw/GLFW.java +++ b/modules/overrungl.glfw/src/main/java/overrungl/glfw/GLFW.java @@ -1496,7 +1496,7 @@ default Tuple2.OfObjInt getError() { */ @Skip default MemorySegment setErrorCallback(@Nullable GLFWErrorFun callback) { - return nsetErrorCallback(callback != null ? callback.stub(Arena.ofAuto()) : MemorySegment.NULL); + return nsetErrorCallback(callback != null ? callback.stub(Arena.global()) : MemorySegment.NULL); } /** @@ -1907,7 +1907,7 @@ default Pair.OfFloat getMonitorContentScale(MemorySegment monitor) { */ @Skip default MemorySegment setMonitorCallback(@Nullable GLFWMonitorFun callback) { - return nsetMonitorCallback(callback != null ? callback.stub(Arena.ofAuto()) : MemorySegment.NULL); + return nsetMonitorCallback(callback != null ? callback.stub(Arena.global()) : MemorySegment.NULL); } /** @@ -4944,7 +4944,7 @@ default byte[] getJoystickHats(int jid) { */ @Skip default MemorySegment setJoystickCallback(@Nullable GLFWJoystickFun callback) { - return nsetJoystickCallback(callback != null ? callback.stub(Arena.ofAuto()) : MemorySegment.NULL); + return nsetJoystickCallback(callback != null ? callback.stub(Arena.global()) : MemorySegment.NULL); } /** diff --git a/modules/samples/src/main/java/overrungl/demo/glfw/GLFWJoystickTest.java b/modules/samples/src/main/java/overrungl/demo/glfw/GLFWJoystickTest.java index 711c9336..3d9d0e14 100644 --- a/modules/samples/src/main/java/overrungl/demo/glfw/GLFWJoystickTest.java +++ b/modules/samples/src/main/java/overrungl/demo/glfw/GLFWJoystickTest.java @@ -75,29 +75,31 @@ private void init() { } private void loop() { - var states = new GLFWGamepadState[GLFW.JOYSTICK_LAST + 1]; - for (int i = 0; i < states.length; i++) { - states[i] = GLFWGamepadState.OF.of(Arena.ofAuto()); - } - while (!glfw.windowShouldClose(window)) { - for (int i = 0; i <= GLFW.JOYSTICK_LAST; i++) { - if (glfw.joystickPresent(i)) { - if (glfw.joystickIsGamepad(i)) { - var state = states[i]; - if (glfw.getGamepadState(i, state)) { - System.out.println(STR.""" - Get gamepad state for [jid=\{i},name=\{glfw.getGamepadName(i)}] successful: - Buttons: [A(Cross)=\{state.button(GLFW.GAMEPAD_BUTTON_A)}, B(Circle)=\{state.button(GLFW.GAMEPAD_BUTTON_B)}, X(Square)=\{state.button(GLFW.GAMEPAD_BUTTON_X)}, Y(Triangle)=\{state.button(GLFW.GAMEPAD_BUTTON_Y)}, - Left bumper=\{state.button(GLFW.GAMEPAD_BUTTON_LEFT_BUMPER)}, Right bumper=\{state.button(GLFW.GAMEPAD_BUTTON_RIGHT_BUMPER)}, Back=\{state.button(GLFW.GAMEPAD_BUTTON_BACK)}, Start=\{state.button(GLFW.GAMEPAD_BUTTON_START)}, - Guide=\{state.button(GLFW.GAMEPAD_BUTTON_GUIDE)}, Left thumb=\{state.button(GLFW.GAMEPAD_BUTTON_LEFT_THUMB)}, Right thumb=\{state.button(GLFW.GAMEPAD_BUTTON_RIGHT_THUMB)}, - DPAD(up=\{state.button(GLFW.GAMEPAD_BUTTON_DPAD_UP)}, right=\{state.button(GLFW.GAMEPAD_BUTTON_DPAD_RIGHT)}, down=\{state.button(GLFW.GAMEPAD_BUTTON_DPAD_DOWN)}, left=\{state.button(GLFW.GAMEPAD_BUTTON_DPAD_LEFT)})], - Axis: [Left(x=\{state.axe(GLFW.GAMEPAD_AXIS_LEFT_X)}, y=\{state.axe(GLFW.GAMEPAD_AXIS_LEFT_Y)}), Right(x=\{state.axe(GLFW.GAMEPAD_AXIS_RIGHT_X)}, y=\{state.axe(GLFW.GAMEPAD_AXIS_RIGHT_Y)}), Trigger(left=\{state.axe(GLFW.GAMEPAD_AXIS_LEFT_TRIGGER)}, right\{state.axe(GLFW.GAMEPAD_AXIS_RIGHT_TRIGGER)})] - """); + try (Arena arena = Arena.ofConfined()) { + var states = new GLFWGamepadState[GLFW.JOYSTICK_LAST + 1]; + for (int i = 0; i < states.length; i++) { + states[i] = GLFWGamepadState.OF.of(arena); + } + while (!glfw.windowShouldClose(window)) { + for (int i = 0; i <= GLFW.JOYSTICK_LAST; i++) { + if (glfw.joystickPresent(i)) { + if (glfw.joystickIsGamepad(i)) { + var state = states[i]; + if (glfw.getGamepadState(i, state)) { + System.out.println(STR.""" + Get gamepad state for [jid=\{i},name=\{glfw.getGamepadName(i)}] successful: + Buttons: [A(Cross)=\{state.button(GLFW.GAMEPAD_BUTTON_A)}, B(Circle)=\{state.button(GLFW.GAMEPAD_BUTTON_B)}, X(Square)=\{state.button(GLFW.GAMEPAD_BUTTON_X)}, Y(Triangle)=\{state.button(GLFW.GAMEPAD_BUTTON_Y)}, + Left bumper=\{state.button(GLFW.GAMEPAD_BUTTON_LEFT_BUMPER)}, Right bumper=\{state.button(GLFW.GAMEPAD_BUTTON_RIGHT_BUMPER)}, Back=\{state.button(GLFW.GAMEPAD_BUTTON_BACK)}, Start=\{state.button(GLFW.GAMEPAD_BUTTON_START)}, + Guide=\{state.button(GLFW.GAMEPAD_BUTTON_GUIDE)}, Left thumb=\{state.button(GLFW.GAMEPAD_BUTTON_LEFT_THUMB)}, Right thumb=\{state.button(GLFW.GAMEPAD_BUTTON_RIGHT_THUMB)}, + DPAD(up=\{state.button(GLFW.GAMEPAD_BUTTON_DPAD_UP)}, right=\{state.button(GLFW.GAMEPAD_BUTTON_DPAD_RIGHT)}, down=\{state.button(GLFW.GAMEPAD_BUTTON_DPAD_DOWN)}, left=\{state.button(GLFW.GAMEPAD_BUTTON_DPAD_LEFT)})], + Axis: [Left(x=\{state.axe(GLFW.GAMEPAD_AXIS_LEFT_X)}, y=\{state.axe(GLFW.GAMEPAD_AXIS_LEFT_Y)}), Right(x=\{state.axe(GLFW.GAMEPAD_AXIS_RIGHT_X)}, y=\{state.axe(GLFW.GAMEPAD_AXIS_RIGHT_Y)}), Trigger(left=\{state.axe(GLFW.GAMEPAD_AXIS_LEFT_TRIGGER)}, right\{state.axe(GLFW.GAMEPAD_AXIS_RIGHT_TRIGGER)})] + """); + } } } } + glfw.waitEventsTimeout(3); } - glfw.waitEventsTimeout(3); } } diff --git a/modules/samples/src/main/java/overrungl/demo/opengl/GL33Test.java b/modules/samples/src/main/java/overrungl/demo/opengl/GL33Test.java index 3a913b07..62ee42d4 100644 --- a/modules/samples/src/main/java/overrungl/demo/opengl/GL33Test.java +++ b/modules/samples/src/main/java/overrungl/demo/opengl/GL33Test.java @@ -222,38 +222,40 @@ void main() { } private void loop() { - var matrix = new Matrix4f(); - var pRotationMat = Matrixn.allocate(Arena.ofAuto(), matrix); + try (var arena = Arena.ofConfined()) { + var matrix = new Matrix4f(); + var pRotationMat = Matrixn.allocate(arena, matrix); - var timer = Timer.ofGetter(20, glfw::getTime); + var timer = Timer.ofGetter(20, glfw::getTime); - while (!glfw.windowShouldClose(window)) { - timer.advanceTime(); - timer.performTicks(null); + while (!glfw.windowShouldClose(window)) { + timer.advanceTime(); + timer.performTicks(null); - gl.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT); + gl.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT); - // Draw triangle - gl.useProgram(program); + // Draw triangle + gl.useProgram(program); - // rotate 90deg per second - matrix.rotateZ((float) Math.toRadians(90 * timer.deltaTime())); - Matrixn.put(matrix, pRotationMat); + // rotate 90deg per second + matrix.rotateZ((float) Math.toRadians(90 * timer.deltaTime())); + Matrixn.put(matrix, pRotationMat); - gl.uniformMatrix4fv(rotationMat, 1, false, pRotationMat); - gl.bindVertexArray(vao); - gl.drawElementsInstanced(GL.TRIANGLES, 6, GL.UNSIGNED_BYTE, MemorySegment.NULL, INSTANCE_COUNT); - gl.bindVertexArray(0); - gl.useProgram(0); + gl.uniformMatrix4fv(rotationMat, 1, false, pRotationMat); + gl.bindVertexArray(vao); + gl.drawElementsInstanced(GL.TRIANGLES, 6, GL.UNSIGNED_BYTE, MemorySegment.NULL, INSTANCE_COUNT); + gl.bindVertexArray(0); + gl.useProgram(0); - glfw.swapBuffers(window); + glfw.swapBuffers(window); - glfw.pollEvents(); + glfw.pollEvents(); - // using lambda gets higher FPS ?? - timer.calcFPS(fps -> { - glfw.setWindowTitle(window, STR."\{WND_TITLE} FPS: \{fps}"); - }); + // using lambda gets higher FPS ?? + timer.calcFPS(fps -> { + glfw.setWindowTitle(window, STR."\{WND_TITLE} FPS: \{fps}"); + }); + } } }