Hot questions for Using Lightweight Java Game Library in gradle

Question:

I'm new to gradle and I'm trying to configure gradle with lwjgl3. Because I didn't found a repo where lwjgl3 is hosted i decided that everybody who use this project has to define the path to the lwjgl lib. I created a user.gradle file with contains the paths to the jar and to the natives.

My build.gradle looks like this at the moment.

apply plugin: 'java'
apply from: 'user.gradle'
apply plugin: 'application'

sourceCompatibility = 1.8
targetCompatibility = 1.8

mainClassName = "mp.Main"

println("LWJGL jar path is configured to: ${config.lwjgl3Jar}")
println("LWJGL natives path is configured to: ${config.lwjgl3Natives}")

repositories {
    mavenCentral()
    flatDir {
        dir config.lwjgl3Jar
    }
}

dependencies {
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'net.java.dev.jna:jna:4.1.0'
    testCompile 'junit:junit:4.+'
    testCompile 'com.carrotsearch:junit-benchmarks:0.7.2'
    compile name: 'lwjgl'
}

tasks.withType(Test) {
    scanForTestClasses = false
    include "**/*Test.class" // whatever Ant pattern matches your test class files
}

sourceSets{
    main {
        java {
            srcDir 'src'
            exclude 'mp/graphics/gl/scene/Mesh.java'
            exclude 'test'
        }
    }

    test{
        java {
            srcDir 'src/test'
            exclude '**/UnsafeTest.java'
            exclude '**/DispatchTests/*'
            exclude '**/MemoryTest.java'
            exclude '**/SuperFastListTest.java'
            exclude '**/MatrixTest.java'
            exclude '**/SimulationTest.java'
        }
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.3'
}

How to set the natives? I tried it different ways. Google didn't helped me out this time. All results are related to older versions of this lib and all are using repositories. Maybe I'm missing the forest for the trees in between. Any ideas?

Best regards!

PS: Not sure if it is important: We are using different IDE's like intelliJ and Eclipse on Windows, Linux, and Mac.


Answer:

I have run into the same problem and wrote a plugin for handling the natives associated with Java jar files.

http://cjstehno.github.io/gradle-natives/

It will unpack them from the jar files so that you can use them and deploy them in your project.

Question:

I'm having issues getting my IDEA IntelliJ workspace to work with a Gradle script that should setup LWJGL and other libs automatically. The script does setup the workspace and everything compiles without issues. The problem is when running my code I get missing a missing .dll error.

Log of error: http://pastebin.com/P8e7AgVW build script: http://pastebin.com/XSmskKyj

Checking the folder the code outputs the .dll shows the file is missing. The problem is that LWJGL should auto extra .dlls according to the site. https://github.com/LWJGL/lwjgl3-wiki/wiki/1.2.-Install

In short, I have no clue what I'm doing and could use help getting LWJGL setup. As well I have googled setup instructions, watched videos, and searched for error help. Everything is either not related or outdated for the current version.


Answer:

Not sure if LWGL 3.1.1 includes libGLESv2.dll and its companion libEGL.dll.

If they were not provided by LWJGL you can use the PowerVR SDK GLES emulator, which runs on top of your native OpenGL.

Another option is Google's ANGLE, wich runs on top of DirectX 9 and/or DirectX 11. Angle is lighting fast and runs very well on low end GPUs -I mean notebooks with Intel GPU-. If you are in hurry or would like to skip compiling ANGLE from sources, just go to your Chrome web browser install folder and look for libegl.dll, libglesv2.dll and d3dcompiler_47.dll.

Once you already choosed your OpenGL ES emulator, put above files in your PATH and/or java.classpath and be happy. In your case, seems the native path is set at org.lwjgl.librarypath and assigned to folder C:\Users\Rober\AppData\Local\Temp\lwjglRober\3.1.1-build-16.

Question:

I'm following this tutorial (http://www.kilobolt.com/day-2-setting-up-libgdx.html). But in step 18 where I run the project as a java application, I get the following errors:

I've tried looking around but found no solution for the errors i had.

Any ideas?

Edit:

Running a java --version returns

openjdk 11.0.4 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3, mixed mode, sharing)

My libgdx version is 1.9.10 which i think is the newest?


Answer:

What version of libgdx and java are you using?


For the error check this question

Like you the questioner used libgdx under ubuntu with a newer version of the open jdk.Downgrading to version 8 seemed to have resolved that issue.


The warnings basically says something along the lines that the underlying code uses functionality that has been deprecated and is pending for removal. Using a newer version of libgdx might solves that issue.

However some of those issues might not be resolved as libgdx does not seem to be under (much) active development anymore. The usual recommondetation is to not use anything beyond JDK 8.

According to the repo (for example this) 1.9.10 is indeed the latest version.

Note as well that those are just warnings you could potentially igore. However as your are facing other issues with the open-jdk implementation ignoring them is not an option for you.