An open API service indexing awesome lists of open source software.

https://github.com/chirontt/lwjgl3-helloworld-native

HelloWorld demo for LWJGL 3, compiled to native executable by GraalVM native-image utility.
https://github.com/chirontt/lwjgl3-helloworld-native

graalvm-native-image java lwjgl3 opengl

Last synced: 5 months ago
JSON representation

HelloWorld demo for LWJGL 3, compiled to native executable by GraalVM native-image utility.

Awesome Lists containing this project

README

          

# lwjgl3-helloworld demo + GraalVM native image

HelloWorld [demo](https://www.lwjgl.org/guide) for LWJGL 3,
compiled to native executable by GraalVM native-image utility.



Gradle/Maven wrappers & build scripts are provided for building the project,
which requires JDK 11+ or GraalVM 21+ (for native image).

## GraalVM pre-requisites

The [GraalVM native-image](https://www.graalvm.org/reference-manual/native-image) page
shows how to set up GraalVM and its native-image utility for common platforms.
[Gluon](https://gluonhq.com/) also provides some setup
[details](https://docs.gluonhq.com/#_platforms) for GraalVM native-image creation.

The GraalVM native-image utility will use the configuration files in
`src/main/resources/META-INF/native-image` folder to assist in the native-image generation.

## Gradle build tasks

To build and run the HelloWorld demo in standard JVM with Gradle, execute the `run` task:

gradlew run

To see some debug info generated by LWJGL, run it with relevant system properties
to show some debug messages in the console:

gradlew run -Dorg.lwjgl.util.Debug=true

The above tasks can use any standard JDK 11+.

To generate native executable, GraalVM 21+ need be set up as mentioned in
*GraalVM pre-requisites* section above.

Once GraalVM is set up and available in the path, run the `nativeCompile` task:

gradlew nativeCompile

The `nativeCompile` task would take a while to compile the demo source code and
link them with the LWJGL libraries into a native executable file.
The resulting `lwjgl3-helloworld` executable file is:

build/native/nativeCompile/lwjgl3-helloworld

(or if building on a Windows machine:

build\native\nativeCompile\lwjgl3-helloworld.exe

)

which can then be run directly:

./build/native/nativeCompile/lwjgl3-helloworld

or, run it with relevant system properties to see some debug info in the console:

./build/native/nativeCompile/lwjgl3-helloworld -Dorg.lwjgl.util.Debug=true

(or if building on a Windows machine:

build\native\nativeCompile\lwjgl3-helloworld.exe
build\native\nativeCompile\lwjgl3-helloworld.exe -Dorg.lwjgl.util.Debug=true

)

## Maven build tasks

To build and run the HelloWorld demo in standard JVM with Maven, execute the
`compile` then `exec:exec` tasks:

mvnw compile
mvnw exec:exec

To see some debug info generated by LWJGL, run it with relevant system properties
to show some debug messages in the console:

mvnw exec:exec -Dsys.props="-Dorg.lwjgl.util.Debug=true"

The above tasks can use any standard JDK 11+.

To generate native executable, GraalVM 21+ need be set up as mentioned in
*GraalVM pre-requisites* section above.

Once GraalVM is set up and available in the path, run the `package` task:

mvnw package

The `package` task would take a while to compile the demo source code and
link them with the LWJGL libraries into an executable file.
The resulting `lwjgl3-helloworld` executable file is:

target/lwjgl3-helloworld

(or if building on a Windows machine:

target\lwjgl3-helloworld.exe

)

which can then be run directly:

./target/lwjgl3-helloworld

or, run it with relevant system properties to see some debug info in the console:

./target/lwjgl3-helloworld -Dorg.lwjgl.util.Debug=true

(or if building on a Windows machine:

target\lwjgl3-helloworld.exe
target\lwjgl3-helloworld.exe -Dorg.lwjgl.util.Debug=true

)