summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.editorconfig18
-rw-r--r--.gitattributes2
-rw-r--r--.gitignore164
-rw-r--r--assets/.gitkeep3
-rw-r--r--build.gradle69
-rw-r--r--core/build.gradle15
-rw-r--r--core/src/main/java/coffee/liz/dyl/FirstScreen.java45
-rw-r--r--core/src/main/java/coffee/liz/dyl/Main.java11
-rw-r--r--gradle.properties22
-rw-r--r--gradle/gradle-daemon-jvm.properties12
-rw-r--r--gradle/wrapper/gradle-wrapper.jarbin0 -> 46175 bytes
-rw-r--r--gradle/wrapper/gradle-wrapper.properties7
-rwxr-xr-xgradlew248
-rwxr-xr-xgradlew.bat93
-rw-r--r--lwjgl3/build.gradle184
-rw-r--r--lwjgl3/icons/logo.icnsbin0 -> 201876 bytes
-rw-r--r--lwjgl3/icons/logo.icobin0 -> 4286 bytes
-rw-r--r--lwjgl3/icons/logo.pngbin0 -> 9545 bytes
-rw-r--r--lwjgl3/nativeimage.gradle54
-rw-r--r--lwjgl3/src/main/java/coffee/liz/dyl/lwjgl3/Lwjgl3Launcher.java48
-rw-r--r--lwjgl3/src/main/java/coffee/liz/dyl/lwjgl3/StartupHelper.java227
-rw-r--r--lwjgl3/src/main/resources/libgdx128.pngbin0 -> 9545 bytes
-rw-r--r--lwjgl3/src/main/resources/libgdx16.pngbin0 -> 806 bytes
-rw-r--r--lwjgl3/src/main/resources/libgdx32.pngbin0 -> 2071 bytes
-rw-r--r--lwjgl3/src/main/resources/libgdx64.pngbin0 -> 4929 bytes
-rw-r--r--settings.gradle8
26 files changed, 1230 insertions, 0 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..67df35c
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,18 @@
+# https://editorconfig.org
+root = true
+
+[*]
+indent_style = space
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.{java,scala,groovy,kt,kts}]
+indent_size = 4
+
+[*.gradle]
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..6c84be0
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+* text=auto eol=lf
+*.bat text=auto eol=crlf
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..bf713c6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,164 @@
+## Gradle:
+.gradle/
+gradle-app.setting
+/build/
+/android/build/
+/core/build/
+/lwjgl2/build/
+/lwjgl3/build/
+/html/build/
+/teavm/build/
+/ios/build/
+/ios-moe/build/
+/headless/build/
+/server/build/
+/shared/build/
+
+## Java:
+*.class
+*.war
+*.ear
+hs_err_pid*
+.attach_pid*
+
+## Android:
+/android/libs/armeabi-v7a/
+/android/libs/arm64-v8a/
+/android/libs/x86/
+/android/libs/x86_64/
+/android/gen/
+/android/out/
+local.properties
+com_crashlytics_export_strings.xml
+
+## Robovm:
+/ios/robovm-build/
+
+## iOS:
+/ios/xcode/*.xcodeproj/*
+!/ios/xcode/*.xcodeproj/xcshareddata
+!/ios/xcode/*.xcodeproj/project.pbxproj
+/ios/xcode/native/
+/ios/IOSLauncher.app
+/ios/IOSLauncher.app.dSYM
+
+## GWT:
+/html/war/
+/html/gwt-unitCache/
+.apt_generated/
+/html/war/WEB-INF/deploy/
+/html/war/WEB-INF/classes/
+.gwt/
+gwt-unitCache/
+www-test/
+.gwt-tmp/
+
+## TeaVM:
+# Not sure yet...
+
+## IntelliJ, Android Studio:
+.idea/
+*.ipr
+*.iws
+*.iml
+
+## Eclipse:
+.classpath
+.project
+.metadata/
+/android/bin/
+/core/bin/
+/lwjgl2/bin/
+/lwjgl3/bin/
+/html/bin/
+/teavm/bin/
+/ios/bin/
+/ios-moe/bin/
+/headless/bin/
+/server/bin/
+/shared/bin/
+*.tmp
+*.bak
+*.swp
+*~.nib
+.settings/
+.loadpath
+.externalToolBuilders/
+*.launch
+
+
+## NetBeans:
+
+/nbproject/private/
+/android/nbproject/private/
+/core/nbproject/private/
+/lwjgl2/nbproject/private/
+/lwjgl3/nbproject/private/
+/html/nbproject/private/
+/teavm/nbproject/private/
+/ios/nbproject/private/
+/ios-moe/nbproject/private/
+/headless/nbproject/private/
+/server/nbproject/private/
+/shared/nbproject/private/
+
+/nbbuild/
+/android/nbbuild/
+/core/nbbuild/
+/lwjgl2/nbbuild/
+/lwjgl3/nbbuild/
+/html/nbbuild/
+/teavm/nbbuild/
+/ios/nbbuild/
+/ios-moe/nbbuild/
+/headless/nbbuild/
+/server/nbbuild/
+/shared/nbbuild/
+
+/dist/
+/android/dist/
+/core/dist/
+/lwjgl2/dist/
+/lwjgl3/dist/
+/html/dist/
+/teavm/dist/
+/ios/dist/
+/ios-moe/dist/
+/headless/dist/
+/server/dist/
+/shared/dist/
+
+/nbdist/
+/android/nbdist/
+/core/nbdist/
+/lwjgl2/nbdist/
+/lwjgl3/nbdist/
+/html/nbdist/
+/teavm/nbdist/
+/ios/nbdist/
+/ios-moe/nbdist/
+/headless/nbdist/
+/server/nbdist/
+/shared/nbdist/
+
+nbactions.xml
+nb-configuration.xml
+
+## OS-Specific:
+.DS_Store
+Thumbs.db
+
+## Miscellaneous:
+*~
+*.*#
+*#*#
+/.kotlin/
+/assets/assets.txt
+
+## Special cases:
+
+## There is a resource-config.json file generated by nativeimage.gradle if you use Graal Native Image.
+## Some usage may need extra resource configuration in a different file with the same name.
+## You could also add that configuration to the text in nativeimage.gradle .
+## You should delete or comment out the next line if you have configuration in a different resource-config.json .
+**/resource-config.json
diff --git a/assets/.gitkeep b/assets/.gitkeep
new file mode 100644
index 0000000..944e008
--- /dev/null
+++ b/assets/.gitkeep
@@ -0,0 +1,3 @@
+This file can be deleted if there are any other files present in this folder.
+It is only here to ensure this folder is added to Git, instead of being
+ignored because it is empty. \ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..072a5c9
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,69 @@
+buildscript {
+ repositories {
+ mavenCentral()
+ gradlePluginPortal()
+ mavenLocal()
+ google()
+ maven { url = 'https://central.sonatype.com/repository/maven-snapshots/' }
+ }
+ dependencies {
+
+
+ }
+}
+
+allprojects {
+ apply plugin: 'eclipse'
+ apply plugin: 'idea'
+
+ // This allows you to "Build and run using IntelliJ IDEA", an option in IDEA's Settings.
+ idea {
+ module {
+ outputDir = file('build/classes/java/main')
+ testOutputDir = file('build/classes/java/test')
+ }
+ }
+}
+
+configure(subprojects) {
+ apply plugin: 'java-library'
+ java.sourceCompatibility = 17
+
+ // From https://lyze.dev/2021/04/29/libGDX-Internal-Assets-List/
+ // The article can be helpful when using assets.txt in your project.
+ tasks.register('generateAssetList') {
+ inputs.dir("${project.rootDir}/assets/")
+ // projectFolder/assets
+ File assetsFolder = new File("${project.rootDir}/assets/")
+ // projectFolder/assets/assets.txt
+ File assetsFile = new File(assetsFolder, "assets.txt")
+ // delete that file in case we've already created it
+ assetsFile.delete()
+
+ // iterate through all files inside that folder
+ // convert it to a relative path
+ // and append it to the file assets.txt
+ fileTree(assetsFolder).collect { assetsFolder.relativePath(it) }.sort().each {
+ assetsFile.append(it + "\n")
+ }
+ }
+ processResources.dependsOn 'generateAssetList'
+
+ compileJava {
+ options.incremental = true
+ }
+}
+
+subprojects {
+ version = "$projectVersion"
+ ext.appName = 'dyl'
+ repositories {
+ mavenCentral()
+ // You may want to remove the following line if you have errors downloading dependencies.
+ mavenLocal()
+ maven { url = 'https://central.sonatype.com/repository/maven-snapshots/' }
+ maven { url = 'https://jitpack.io' }
+ }
+}
+
+eclipse.project.name = 'dyl' + '-parent'
diff --git a/core/build.gradle b/core/build.gradle
new file mode 100644
index 0000000..a27dcd6
--- /dev/null
+++ b/core/build.gradle
@@ -0,0 +1,15 @@
+[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
+eclipse.project.name = appName + '-core'
+
+dependencies {
+ api "com.badlogicgames.ashley:ashley:$ashleyVersion"
+ api "com.badlogicgames.box2dlights:box2dlights:$box2dlightsVersion"
+ api "com.badlogicgames.gdx:gdx-ai:$aiVersion"
+ api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
+ api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
+ api "com.badlogicgames.gdx:gdx:$gdxVersion"
+
+ if(enableGraalNative == 'true') {
+ implementation "io.github.berstanio:gdx-svmhelper-annotations:$graalHelperVersion"
+ }
+}
diff --git a/core/src/main/java/coffee/liz/dyl/FirstScreen.java b/core/src/main/java/coffee/liz/dyl/FirstScreen.java
new file mode 100644
index 0000000..4901283
--- /dev/null
+++ b/core/src/main/java/coffee/liz/dyl/FirstScreen.java
@@ -0,0 +1,45 @@
+package coffee.liz.dyl;
+
+import com.badlogic.gdx.Screen;
+
+/** First screen of the application. Displayed after the application is created. */
+public class FirstScreen implements Screen {
+ @Override
+ public void show() {
+ // Prepare your screen here.
+ }
+
+ @Override
+ public void render(float delta) {
+ // Draw your screen here. "delta" is the time since last render in seconds.
+ }
+
+ @Override
+ public void resize(int width, int height) {
+ // If the window is minimized on a desktop (LWJGL3) platform, width and height are 0, which causes problems.
+ // In that case, we don't resize anything, and wait for the window to be a normal size before updating.
+ if(width <= 0 || height <= 0) return;
+
+ // Resize your screen here. The parameters represent the new window size.
+ }
+
+ @Override
+ public void pause() {
+ // Invoked when your application is paused.
+ }
+
+ @Override
+ public void resume() {
+ // Invoked when your application is resumed after pause.
+ }
+
+ @Override
+ public void hide() {
+ // This method is called when another screen replaces this one.
+ }
+
+ @Override
+ public void dispose() {
+ // Destroy screen's assets here.
+ }
+} \ No newline at end of file
diff --git a/core/src/main/java/coffee/liz/dyl/Main.java b/core/src/main/java/coffee/liz/dyl/Main.java
new file mode 100644
index 0000000..24fa3de
--- /dev/null
+++ b/core/src/main/java/coffee/liz/dyl/Main.java
@@ -0,0 +1,11 @@
+package coffee.liz.dyl;
+
+import com.badlogic.gdx.Game;
+
+/** {@link com.badlogic.gdx.ApplicationListener} implementation shared by all platforms. */
+public class Main extends Game {
+ @Override
+ public void create() {
+ setScreen(new FirstScreen());
+ }
+} \ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..fc47d0e
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,22 @@
+# This doesn't need to be false, and some projects may be able to take advantage of setting daemon to true.
+# We set it to false by default in order to avoid too many daemons from being created and persisting; each needs RAM.
+org.gradle.daemon=false
+# Sets starting memory usage to 512MB, maximum memory usage to 1GB, and tries to set as much to use Unicode as we can.
+org.gradle.jvmargs=-Xms512M -Xmx1G -Dfile.encoding=UTF-8 -Dconsole.encoding=UTF-8
+# "Configure on-demand" must be false because it breaks projects that have Android modules. The default is also false.
+org.gradle.configureondemand=false
+# The logging level determines which messages get shown about how Gradle itself is working, such as if build.gradle
+# files are fully future-proof (which they never are, because Gradle constantly deprecates working APIs).
+# You can change 'quiet' below to 'lifecycle' to use Gradle's default behavior, which shows some confusing messages.
+# You could instead change 'quiet' below to 'info' to see info that's important mainly while debugging build files.
+# Note that if you want to use Gradle Build Scans, you should set the below logging level to 'lifecycle', otherwise
+# the link to the scan won't get shown at all.
+# Documented at: https://docs.gradle.org/current/userguide/command_line_interface.html#sec:command_line_logging
+org.gradle.logging.level=quiet
+aiVersion=1.8.2
+ashleyVersion=1.7.4
+box2dlightsVersion=1.5
+graalHelperVersion=2.0.1
+enableGraalNative=false
+gdxVersion=1.14.0
+projectVersion=1.0.0
diff --git a/gradle/gradle-daemon-jvm.properties b/gradle/gradle-daemon-jvm.properties
new file mode 100644
index 0000000..e5d86a4
--- /dev/null
+++ b/gradle/gradle-daemon-jvm.properties
@@ -0,0 +1,12 @@
+#This file is generated by updateDaemonJvm
+toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/73c462e34475aeb6509ab7ba3eda218f/redirect
+toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/54001d0b636ad500b432d20ef3d580d0/redirect
+toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/73c462e34475aeb6509ab7ba3eda218f/redirect
+toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/54001d0b636ad500b432d20ef3d580d0/redirect
+toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/29c55e6bad8a0049163f0184625cecd9/redirect
+toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/3ac7a5361c25c0b23d933f44bdb0abd9/redirect
+toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/73c462e34475aeb6509ab7ba3eda218f/redirect
+toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/54001d0b636ad500b432d20ef3d580d0/redirect
+toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/dd5b582862cacd4b8e0d82037f92a53f/redirect
+toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/16008c489780dfb402c44316e612a16c/redirect
+toolchainVersion=17
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..61285a6
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..37f78a6
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..adff685
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,248 @@
+#!/bin/sh
+
+#
+# Copyright © 2015 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# 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/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# 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 -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100755
index 0000000..c4bdd3a
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,93 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@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 ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/lwjgl3/build.gradle b/lwjgl3/build.gradle
new file mode 100644
index 0000000..26356c4
--- /dev/null
+++ b/lwjgl3/build.gradle
@@ -0,0 +1,184 @@
+
+buildscript {
+ repositories {
+ gradlePluginPortal()
+ }
+ dependencies {
+ classpath "io.github.fourlastor:construo:2.1.0"
+ if(enableGraalNative == 'true') {
+ classpath "org.graalvm.buildtools.native:org.graalvm.buildtools.native.gradle.plugin:0.9.28"
+ }
+ }
+}
+plugins {
+ id "application"
+}
+apply plugin: 'io.github.fourlastor.construo'
+
+
+import io.github.fourlastor.construo.Target
+
+sourceSets.main.resources.srcDirs += [ rootProject.file('assets').path ]
+application.mainClass = 'coffee.liz.dyl.lwjgl3.Lwjgl3Launcher'
+application.applicationName = appName
+eclipse.project.name = appName + '-lwjgl3'
+java.sourceCompatibility = 17
+java.targetCompatibility = 17
+if (JavaVersion.current().isJava9Compatible()) {
+ compileJava.options.release.set(17)
+}
+
+dependencies {
+ implementation "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
+ implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
+ implementation "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
+ implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
+ implementation project(':core')
+
+ if(enableGraalNative == 'true') {
+ implementation "io.github.berstanio:gdx-svmhelper-backend-lwjgl3:$graalHelperVersion"
+ implementation "io.github.berstanio:gdx-svmhelper-extension-box2d:$graalHelperVersion"
+ implementation "io.github.berstanio:gdx-svmhelper-extension-freetype:$graalHelperVersion"
+
+ }
+}
+
+def os = System.properties['os.name'].toLowerCase(Locale.ROOT)
+
+run {
+ workingDir = rootProject.file('assets').path
+// You can uncomment the next line if your IDE claims a build failure even when the app closed properly.
+ //setIgnoreExitValue(true)
+
+ if (os.contains('mac')) jvmArgs += "-XstartOnFirstThread"
+}
+
+jar {
+// sets the name of the .jar file this produces to the name of the game or app, with the version after.
+ archiveFileName.set("${appName}-${projectVersion}.jar")
+// the duplicatesStrategy matters starting in Gradle 7.0; this setting works.
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+ dependsOn configurations.runtimeClasspath
+ from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
+// these "exclude" lines remove some unnecessary duplicate files in the output JAR.
+ exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA')
+ dependencies {
+ exclude('META-INF/INDEX.LIST', 'META-INF/maven/**')
+ }
+// setting the manifest makes the JAR runnable.
+// enabling native access helps avoid a warning when Java 24 or later runs the JAR.
+ manifest {
+ attributes 'Main-Class': application.mainClass, 'Enable-Native-Access': 'ALL-UNNAMED'
+ }
+// this last step may help on some OSes that need extra instruction to make runnable JARs.
+ doLast {
+ file(archiveFile).setExecutable(true, false)
+ }
+}
+
+// Builds a JAR that only includes the files needed to run on macOS, not Windows or Linux.
+// The file size for a Mac-only JAR is about 7MB smaller than a cross-platform JAR.
+tasks.register("jarMac") {
+ dependsOn("jar")
+ group("build")
+ jar.archiveFileName.set("${appName}-${projectVersion}-mac.jar")
+ jar.exclude("windows/x86/**", "windows/x64/**", "linux/arm32/**", "linux/arm64/**", "linux/x64/**", "**/*.dll", "**/*.so",
+ 'META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA')
+ dependencies {
+ jar.exclude("windows/x86/**", "windows/x64/**", "linux/arm32/**", "linux/arm64/**", "linux/x64/**",
+ 'META-INF/INDEX.LIST', 'META-INF/maven/**')
+ }
+}
+
+// Builds a JAR that only includes the files needed to run on Linux, not Windows or macOS.
+// The file size for a Linux-only JAR is about 5MB smaller than a cross-platform JAR.
+tasks.register("jarLinux") {
+ dependsOn("jar")
+ group("build")
+ jar.archiveFileName.set("${appName}-${projectVersion}-linux.jar")
+ jar.exclude("windows/x86/**", "windows/x64/**", "macos/arm64/**", "macos/x64/**", "**/*.dll", "**/*.dylib",
+ 'META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA')
+ dependencies {
+ jar.exclude("windows/x86/**", "windows/x64/**", "macos/arm64/**", "macos/x64/**",
+ 'META-INF/INDEX.LIST', 'META-INF/maven/**')
+ }
+}
+
+// Builds a JAR that only includes the files needed to run on Windows, not Linux or macOS.
+// The file size for a Windows-only JAR is about 6MB smaller than a cross-platform JAR.
+tasks.register("jarWin") {
+ dependsOn("jar")
+ group("build")
+ jar.archiveFileName.set("${appName}-${projectVersion}-win.jar")
+ jar.exclude("macos/arm64/**", "macos/x64/**", "linux/arm32/**", "linux/arm64/**", "linux/x64/**", "**/*.dylib", "**/*.so",
+ 'META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA')
+ dependencies {
+ jar.exclude("macos/arm64/**", "macos/x64/**", "linux/arm32/**", "linux/arm64/**", "linux/x64/**",
+ 'META-INF/INDEX.LIST', 'META-INF/maven/**')
+ }
+}
+
+construo {
+ // name of the executable
+ name.set(appName)
+ // human-readable name, used for example in the `.app` name for macOS
+ humanName.set(appName)
+
+ targets.configure {
+ register("linuxX64", Target.Linux) {
+ architecture.set(Target.Architecture.X86_64)
+ jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.15%2B6/OpenJDK17U-jdk_x64_linux_hotspot_17.0.15_6.tar.gz")
+ // Linux does not currently have a way to set the icon on the executable
+ }
+ register("macM1", Target.MacOs) {
+ architecture.set(Target.Architecture.AARCH64)
+ jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.15%2B6/OpenJDK17U-jdk_aarch64_mac_hotspot_17.0.15_6.tar.gz")
+ // macOS needs an identifier
+ identifier.set("coffee.liz.dyl." + appName)
+ // Optional: icon for macOS, as an ICNS file
+ macIcon.set(project.file("icons/logo.icns"))
+ }
+ register("macX64", Target.MacOs) {
+ architecture.set(Target.Architecture.X86_64)
+ jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.15%2B6/OpenJDK17U-jdk_x64_mac_hotspot_17.0.15_6.tar.gz")
+ // macOS needs an identifier
+ identifier.set("coffee.liz.dyl." + appName)
+ // Optional: icon for macOS, as an ICNS file
+ macIcon.set(project.file("icons/logo.icns"))
+ }
+ register("winX64", Target.Windows) {
+ architecture.set(Target.Architecture.X86_64)
+ // Optional: icon for Windows, as a PNG
+ icon.set(project.file("icons/logo.png"))
+ jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.15%2B6/OpenJDK17U-jdk_x64_windows_hotspot_17.0.15_6.zip")
+ // Uncomment the next line to show a console when the game runs, to print messages.
+ //useConsole.set(true)
+ }
+ }
+}
+
+// Equivalent to the jar task; here for compatibility with gdx-setup.
+tasks.register('dist') {
+ dependsOn 'jar'
+}
+
+distributions {
+ main {
+ contents {
+ into('libs') {
+ project.configurations.runtimeClasspath.files.findAll { file ->
+ file.getName() != project.tasks.jar.outputs.files.singleFile.name
+ }.each { file ->
+ exclude file.name
+ }
+ }
+ }
+ }
+}
+
+startScripts.dependsOn(':lwjgl3:jar')
+startScripts.classpath = project.tasks.jar.outputs.files
+
+if(enableGraalNative == 'true') {
+ apply from: file("nativeimage.gradle")
+}
diff --git a/lwjgl3/icons/logo.icns b/lwjgl3/icons/logo.icns
new file mode 100644
index 0000000..5e41ad7
--- /dev/null
+++ b/lwjgl3/icons/logo.icns
Binary files differ
diff --git a/lwjgl3/icons/logo.ico b/lwjgl3/icons/logo.ico
new file mode 100644
index 0000000..c4f2d5e
--- /dev/null
+++ b/lwjgl3/icons/logo.ico
Binary files differ
diff --git a/lwjgl3/icons/logo.png b/lwjgl3/icons/logo.png
new file mode 100644
index 0000000..f810616
--- /dev/null
+++ b/lwjgl3/icons/logo.png
Binary files differ
diff --git a/lwjgl3/nativeimage.gradle b/lwjgl3/nativeimage.gradle
new file mode 100644
index 0000000..bee3fd2
--- /dev/null
+++ b/lwjgl3/nativeimage.gradle
@@ -0,0 +1,54 @@
+
+project(":lwjgl3") {
+ apply plugin: "org.graalvm.buildtools.native"
+
+ graalvmNative {
+ binaries {
+ main {
+ imageName = appName
+ mainClass = application.mainClass
+ requiredVersion = '23.0'
+ buildArgs.add("-march=compatibility")
+ jvmArgs.addAll("-Dfile.encoding=UTF8")
+ sharedLibrary = false
+ resources.autodetect()
+ }
+ }
+ }
+
+ run {
+ doNotTrackState("Running the app should not be affected by Graal.")
+ }
+
+ // Modified from https://lyze.dev/2021/04/29/libGDX-Internal-Assets-List/ ; thanks again, Lyze!
+ // This creates a resource-config.json file based on the contents of the assets folder (and the libGDX icons).
+ // This file is used by Graal Native to embed those specific files.
+ // This has to run before nativeCompile, so it runs at the start of an unrelated resource-handling command.
+ generateResourcesConfigFile.doFirst {
+ def assetsFolder = new File("${project.rootDir}/assets/")
+ def lwjgl3 = project(':lwjgl3')
+ def resFolder = new File("${lwjgl3.projectDir}/src/main/resources/META-INF/native-image/${lwjgl3.ext.appName}")
+ resFolder.mkdirs()
+ def resFile = new File(resFolder, "resource-config.json")
+ resFile.delete()
+ resFile.append(
+ """{
+ "resources":{
+ "includes":[
+ {
+ "pattern": ".*(""")
+ // This adds every filename in the assets/ folder to a pattern that adds those files as resources.
+ fileTree(assetsFolder).each {
+ // The backslash-Q and backslash-E escape the start and end of a literal string, respectively.
+ resFile.append("\\\\Q${it.name}\\\\E|")
+ }
+ // We also match all of the window icon images this way and the font files that are part of libGDX.
+ resFile.append(
+ """libgdx.+\\\\.png|lsans.+)"
+ }
+ ]},
+ "bundles":[]
+}"""
+ )
+ }
+}
diff --git a/lwjgl3/src/main/java/coffee/liz/dyl/lwjgl3/Lwjgl3Launcher.java b/lwjgl3/src/main/java/coffee/liz/dyl/lwjgl3/Lwjgl3Launcher.java
new file mode 100644
index 0000000..a8c9c4f
--- /dev/null
+++ b/lwjgl3/src/main/java/coffee/liz/dyl/lwjgl3/Lwjgl3Launcher.java
@@ -0,0 +1,48 @@
+package coffee.liz.dyl.lwjgl3;
+
+import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
+import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
+import coffee.liz.dyl.Main;
+
+/** Launches the desktop (LWJGL3) application. */
+public class Lwjgl3Launcher {
+ public static void main(String[] args) {
+ if (StartupHelper.startNewJvmIfRequired()) return; // This handles macOS support and helps on Windows.
+ createApplication();
+ }
+
+ private static Lwjgl3Application createApplication() {
+ return new Lwjgl3Application(new Main(), getDefaultConfiguration());
+ }
+
+ private static Lwjgl3ApplicationConfiguration getDefaultConfiguration() {
+ Lwjgl3ApplicationConfiguration configuration = new Lwjgl3ApplicationConfiguration();
+ configuration.setTitle("dyl");
+ //// Vsync limits the frames per second to what your hardware can display, and helps eliminate
+ //// screen tearing. This setting doesn't always work on Linux, so the line after is a safeguard.
+ configuration.useVsync(true);
+ //// Limits FPS to the refresh rate of the currently active monitor, plus 1 to try to match fractional
+ //// refresh rates. The Vsync setting above should limit the actual FPS to match the monitor.
+ configuration.setForegroundFPS(Lwjgl3ApplicationConfiguration.getDisplayMode().refreshRate + 1);
+ //// If you remove the above line and set Vsync to false, you can get unlimited FPS, which can be
+ //// useful for testing performance, but can also be very stressful to some hardware.
+ //// You may also need to configure GPU drivers to fully disable Vsync; this can cause screen tearing.
+
+ configuration.setWindowedMode(640, 480);
+ //// You can change these files; they are in lwjgl3/src/main/resources/ .
+ //// They can also be loaded from the root of assets/ .
+ configuration.setWindowIcon("libgdx128.png", "libgdx64.png", "libgdx32.png", "libgdx16.png");
+
+ //// This could improve compatibility with Windows machines with buggy OpenGL drivers, Macs
+ //// with Apple Silicon that have to emulate compatibility with OpenGL anyway, and more.
+ //// This uses the dependency `com.badlogicgames.gdx:gdx-lwjgl3-angle` to function.
+ //// You would need to add this line to lwjgl3/build.gradle , below the dependency on `gdx-backend-lwjgl3`:
+ //// implementation "com.badlogicgames.gdx:gdx-lwjgl3-angle:$gdxVersion"
+ //// You can choose to add the following line and the mentioned dependency if you want; they
+ //// are not intended for games that use GL30 (which is compatibility with OpenGL ES 3.0).
+ //// Know that it might not work well in some cases.
+// configuration.setOpenGLEmulation(Lwjgl3ApplicationConfiguration.GLEmulation.ANGLE_GLES20, 0, 0);
+
+ return configuration;
+ }
+} \ No newline at end of file
diff --git a/lwjgl3/src/main/java/coffee/liz/dyl/lwjgl3/StartupHelper.java b/lwjgl3/src/main/java/coffee/liz/dyl/lwjgl3/StartupHelper.java
new file mode 100644
index 0000000..e47ba51
--- /dev/null
+++ b/lwjgl3/src/main/java/coffee/liz/dyl/lwjgl3/StartupHelper.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2020 damios
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Note, the above license and copyright applies to this file only.
+package coffee.liz.dyl.lwjgl3;
+
+import com.badlogic.gdx.Version;
+import com.badlogic.gdx.backends.lwjgl3.Lwjgl3NativesLoader;
+
+import org.lwjgl.system.JNI;
+import org.lwjgl.system.linux.UNISTD;
+import org.lwjgl.system.macosx.LibC;
+import org.lwjgl.system.macosx.ObjCRuntime;
+
+import java.io.File;
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * A helper object for game startup, featuring three utilities related to LWJGL3 on various operating systems.
+ * <p>
+ * The utilities are as follows:
+ * <ul>
+ * <li> Windows: Prevents a common crash related to LWJGL3's extraction of shared library files.</li>
+ * <li> macOS: Spawns a child JVM process with {@code -XstartOnFirstThread} in the JVM args (if it was not already).
+ * This is required for LWJGL3 to work on macOS.</li>
+ * <li> Linux (NVIDIA GPUs only): Spawns a child JVM process with the {@code __GL_THREADED_OPTIMIZATIONS}
+ * {@link System#getenv(String) Environment Variable} set to {@code 0} (if it was not already). This is required for
+ * LWJGL3 to work on Linux with NVIDIA GPUs.</li>
+ * </ul>
+ * <a href="https://jvm-gaming.org/t/starting-jvm-on-mac-with-xstartonfirstthread-programmatically/57547">Based on this java-gaming.org post by kappa</a>
+ * @author damios
+ */
+public class StartupHelper {
+
+ private StartupHelper() {}
+
+ private static final String JVM_RESTARTED_ARG = "jvmIsRestarted";
+
+ /**
+ * Must only be called on Linux. Check OS first (or use short-circuit evaluation)!
+ * @return whether NVIDIA drivers are present on Linux.
+ */
+ public static boolean isLinuxNvidia() {
+ String[] drivers = new File("/proc/driver").list(
+ (dir, path) -> path.toUpperCase(Locale.ROOT).contains("NVIDIA")
+ );
+ if (drivers == null) return false;
+ return drivers.length > 0;
+ }
+
+ /**
+ * Applies the utilities as described by {@link StartupHelper}'s Javadoc.
+ * <p>
+ * All {@link System#getenv() Environment Variables} are copied to the child JVM process (if it is spawned), as
+ * specified by {@link ProcessBuilder#environment()}; the same applies for
+ * {@link System#getProperties() System Properties}.
+ * <p>
+ * <b>Usage:</b>
+ * <pre><code>
+ * public static void main(String[] args) {
+ * if (StartupHelper.startNewJvmIfRequired()) return;
+ * // ... The rest of main() goes here, as normal.
+ * }
+ * </code></pre>
+ * @return whether a child JVM process was spawned or not.
+ */
+ public static boolean startNewJvmIfRequired() {
+ return startNewJvmIfRequired(true);
+ }
+
+ /**
+ * Applies the utilities as described by {@link StartupHelper}'s Javadoc.
+ * <p>
+ * All {@link System#getenv() Environment Variables} are copied to the child JVM process (if it is spawned), as
+ * specified by {@link ProcessBuilder#environment()}; the same applies for
+ * {@link System#getProperties() System Properties}.
+ * <p>
+ * <b>Usage:</b>
+ * <pre><code>
+ * public static void main(String[] args) {
+ * // The parameter on the next line could instead be false if you don't want to inherit IO.
+ * if (StartupHelper.startNewJvmIfRequired(true)) return;
+ * // ... The rest of main() goes here, as normal.
+ * }
+ * </code></pre>
+ * @param inheritIO whether I/O should be inherited in the child JVM process. Please note that enabling this will
+ * block the thread until the child JVM process stops executing.
+ * @return whether a child JVM process was spawned or not.
+ */
+ public static boolean startNewJvmIfRequired(boolean inheritIO) {
+ String osName = System.getProperty("os.name").toLowerCase(Locale.ROOT);
+ if (osName.contains("mac")) return startNewJvm0(/*isMac =*/ true, inheritIO);
+ if (osName.contains("windows")) {
+ // Here, we are trying to work around an issue with how LWJGL3 loads its extracted .dll files.
+ // By default, LWJGL3 extracts to the directory specified by "java.io.tmpdir": usually, the user's home.
+ // If the user's name has non-ASCII (or some non-alphanumeric) characters in it, that would fail.
+ // By extracting to the relevant "ProgramData" folder, which is usually "C:\ProgramData", we avoid this.
+ // We also temporarily change the "user.name" property to one without any chars that would be invalid.
+ // We revert our changes immediately after loading LWJGL3 natives.
+ String programData = System.getenv("ProgramData");
+ if (programData == null) programData = "C:\\Temp"; // if ProgramData isn't set, try some fallback.
+ String prevTmpDir = System.getProperty("java.io.tmpdir", programData);
+ String prevUser = System.getProperty("user.name", "libGDX_User");
+ System.setProperty("java.io.tmpdir", programData + "\\libGDX-temp");
+ System.setProperty(
+ "user.name",
+ ("User_" + prevUser.hashCode() + "_GDX" + Version.VERSION).replace('.', '_')
+ );
+ Lwjgl3NativesLoader.load();
+ System.setProperty("java.io.tmpdir", prevTmpDir);
+ System.setProperty("user.name", prevUser);
+ return false;
+ }
+ return startNewJvm0(/*isMac =*/ false, inheritIO);
+ }
+
+ private static final String MAC_JRE_ERR_MSG = "A Java installation could not be found. If you are distributing this app with a bundled JRE, be sure to set the '-XstartOnFirstThread' argument manually!";
+ private static final String LINUX_JRE_ERR_MSG = "A Java installation could not be found. If you are distributing this app with a bundled JRE, be sure to set the environment variable '__GL_THREADED_OPTIMIZATIONS' to '0'!";
+ private static final String CHILD_LOOP_ERR_MSG = "The current JVM process is a spawned child JVM process, but StartupHelper has attempted to spawn another child JVM process! This is a broken state, and should not normally happen! Your game may crash or not function properly!";
+
+ /**
+ * Spawns a child JVM process if on macOS, or on Linux with NVIDIA drivers.
+ * <p>
+ * All {@link System#getenv() Environment Variables} are copied to the child JVM process (if it is spawned), as
+ * specified by {@link ProcessBuilder#environment()}; the same applies for
+ * {@link System#getProperties() System Properties}.
+ * @param isMac whether the current OS is macOS. If this is `false` then the current OS is assumed to be Linux (and
+ * an immediate check for NVIDIA drivers is performed).
+ * @param inheritIO whether I/O should be inherited in the child JVM process. Please note that enabling this will
+ * block the thread until the child JVM process stops executing.
+ * @return whether a child JVM process was spawned or not.
+ */
+ public static boolean startNewJvm0(boolean isMac, boolean inheritIO) {
+ long processID = getProcessID(isMac);
+ if (!isMac) {
+ // No need to restart non-NVIDIA Linux
+ if (!isLinuxNvidia()) return false;
+ // check whether __GL_THREADED_OPTIMIZATIONS is already disabled
+ if ("0".equals(System.getenv("__GL_THREADED_OPTIMIZATIONS"))) return false;
+ } else {
+ // There is no need for -XstartOnFirstThread on Graal native image
+ if (!System.getProperty("org.graalvm.nativeimage.imagecode", "").isEmpty()) return false;
+
+ // Checks if we are already on the main thread, such as from running via Construo.
+ long objcMsgSend = ObjCRuntime.getLibrary().getFunctionAddress("objc_msgSend");
+ long nsThread = ObjCRuntime.objc_getClass("NSThread");
+ long currentThread = JNI.invokePPP(nsThread, ObjCRuntime.sel_getUid("currentThread"), objcMsgSend);
+ boolean isMainThread = JNI.invokePPZ(currentThread, ObjCRuntime.sel_getUid("isMainThread"), objcMsgSend);
+ if (isMainThread) return false;
+
+ if ("1".equals(System.getenv("JAVA_STARTED_ON_FIRST_THREAD_" + processID))) return false;
+ }
+
+ // Check whether this JVM process is a child JVM process already.
+ // This state shouldn't usually be reachable, but this stops us from endlessly spawning new child JVM processes.
+ if ("true".equals(System.getProperty(JVM_RESTARTED_ARG))) {
+ System.err.println(CHILD_LOOP_ERR_MSG);
+ return false;
+ }
+
+ // Spawn the child JVM process with updated environment variables or JVM args
+ List<String> jvmArgs = new ArrayList<>();
+ // The following line is used assuming you target Java 8, the minimum for LWJGL3.
+ String javaExecPath = System.getProperty("java.home") + "/bin/java";
+ // If targeting Java 9 or higher, you could use the following instead of the above line:
+ //String javaExecPath = ProcessHandle.current().info().command().orElseThrow()
+ if (!(new File(javaExecPath).exists())) {
+ System.err.println(getJreErrMsg(isMac));
+ return false;
+ }
+
+ jvmArgs.add(javaExecPath);
+ if (isMac) jvmArgs.add("-XstartOnFirstThread");
+ jvmArgs.add("-D" + JVM_RESTARTED_ARG + "=true");
+ jvmArgs.addAll(ManagementFactory.getRuntimeMXBean().getInputArguments());
+ jvmArgs.add("-cp");
+ jvmArgs.add(System.getProperty("java.class.path"));
+ String mainClass = System.getenv("JAVA_MAIN_CLASS_" + processID);
+ if (mainClass == null) {
+ StackTraceElement[] trace = Thread.currentThread().getStackTrace();
+ if (trace.length > 0) mainClass = trace[trace.length - 1].getClassName();
+ else {
+ System.err.println("The main class could not be determined.");
+ return false;
+ }
+ }
+ jvmArgs.add(mainClass);
+
+ try {
+ ProcessBuilder processBuilder = new ProcessBuilder(jvmArgs);
+ if (!isMac) processBuilder.environment().put("__GL_THREADED_OPTIMIZATIONS", "0");
+
+ if (!inheritIO) processBuilder.start();
+ else processBuilder.inheritIO().start().waitFor();
+ } catch (Exception e) {
+ System.err.println("There was a problem restarting the JVM.");
+ // noinspection CallToPrintStackTrace
+ e.printStackTrace();
+ }
+
+ return true;
+ }
+
+ private static String getJreErrMsg(boolean isMac) {
+ if (isMac) return MAC_JRE_ERR_MSG;
+ else return LINUX_JRE_ERR_MSG;
+ }
+
+ private static long getProcessID(boolean isMac) {
+ if (isMac) return LibC.getpid();
+ else return UNISTD.getpid();
+ }
+} \ No newline at end of file
diff --git a/lwjgl3/src/main/resources/libgdx128.png b/lwjgl3/src/main/resources/libgdx128.png
new file mode 100644
index 0000000..f810616
--- /dev/null
+++ b/lwjgl3/src/main/resources/libgdx128.png
Binary files differ
diff --git a/lwjgl3/src/main/resources/libgdx16.png b/lwjgl3/src/main/resources/libgdx16.png
new file mode 100644
index 0000000..a6b1327
--- /dev/null
+++ b/lwjgl3/src/main/resources/libgdx16.png
Binary files differ
diff --git a/lwjgl3/src/main/resources/libgdx32.png b/lwjgl3/src/main/resources/libgdx32.png
new file mode 100644
index 0000000..9447b39
--- /dev/null
+++ b/lwjgl3/src/main/resources/libgdx32.png
Binary files differ
diff --git a/lwjgl3/src/main/resources/libgdx64.png b/lwjgl3/src/main/resources/libgdx64.png
new file mode 100644
index 0000000..7513f3b
--- /dev/null
+++ b/lwjgl3/src/main/resources/libgdx64.png
Binary files differ
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..11d1983
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,8 @@
+plugins {
+ // Applies the foojay-resolver plugin to allow automatic download of JDKs.
+ id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
+}
+// A list of which subprojects to load as part of the same larger project.
+// You can remove Strings from the list and reload the Gradle project
+// if you want to temporarily disable a subproject.
+include 'lwjgl3', 'core'