JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

classic Classic list List threaded Threaded
249 messages Options
1 ... 78910111213
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

gouessej
Administrator
How can LibGDX detect Android when it doesn't use Dalvik? For example, it is now possible to enable ART (Android Runtime, AOT, no JIT) or to use another virtual machine (AvianVM).
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

Matthew
if
(
    System.getProperty("java.vm.vendor").equals("The Android Project")  ||
        System.getProperty("java.vendor").equals("The Android Project")
)
{ // This is running on an Android OS.
}
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

Sven Gothel
Administrator
On 12/04/2014 10:30 PM, Matthew [via jogamp] wrote:
> if
> (
>     System.getProperty("java.vm.vendor").equals("The Android Project")  ||
>         System.getProperty("java.vendor").equals("The Android Project")
> )
> { // This is running on an Android OS.
> }
>
https://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/com/jogamp/common/os/Platform.html#getOSType%28%29

https://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/com/jogamp/common/os/Platform.OSType.html#ANDROID

~Sven


signature.asc (828 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

Sven Gothel
Administrator
In reply to this post by Matthew
On 12/04/2014 10:34 PM, Sven Gothel wrote:

> On 12/04/2014 10:30 PM, Matthew [via jogamp] wrote:
>> if
>> (
>>     System.getProperty("java.vm.vendor").equals("The Android Project")  ||
>>         System.getProperty("java.vendor").equals("The Android Project")
>> )
>> { // This is running on an Android OS.
>> }
>>
> https://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/com/jogamp/common/os/Platform.html#getOSType%28%29
>
> https://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/com/jogamp/common/os/Platform.OSType.html#ANDROID
>
> ~Sven
>
.. and this one:

https://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/com/jogamp/common/os/AndroidVersion.html

after if AndroidVersion.isAvailable,
one may like to check its other fields.

~Sven



signature.asc (828 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

gouessej
Administrator
In reply to this post by Matthew
Matthew wrote
if
(
    System.getProperty("java.vm.vendor").equals("The Android Project")  ||
        System.getProperty("java.vendor").equals("The Android Project")
)
{ // This is running on an Android OS.
}
It doesn't allow to detect whether Android is using Dalvik or ART. This is the correct answer:
http://stackoverflow.com/a/19831208
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

Xerxes Rånby
gouessej thank you for updating the JogAmp JOGL LibGDX port to use JOGL 2.3.1 !

I have a pull request for you that re-enable OpenGL ES 2 use,
two issues had sneaked in that triggered early during GL 2 FBO detection.
https://github.com/gouessej/libgdx/pull/5


Some quick notes how to test the gdx-backend-jogamp backend with existing libgdx gradle games/projects:
After running
mvn install
inside libgdx sourcetree to build and install gdx-backend-jogamp in the local maven repository.
1. edit the build.grade file of the libgdx games/project and make sure that mavenLocal() got added to repositorys like this:
    repositories {
        mavenCentral()
        mavenLocal()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }

2. add the compiled gdx-backend-jogamp and version number to the project desktop dependencies, like this:
project(":desktop") {
    apply plugin: "java"


    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-jogamp:1.5.6-SNAPSHOT"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
    }
}

3. Update the desktop DesktopLauncher.java file to use the JogAmp JOGL port, like this:
package com.mygdx.game.desktop;

import com.badlogic.gdx.backends.jogamp.JoglApplication;
import com.badlogic.gdx.backends.jogamp.JoglApplicationConfiguration;
import com.mygdx.game.RPiGemo;

public class DesktopLauncher {
        public static void main (String[] arg) {
                JoglApplicationConfiguration config = new JoglApplicationConfiguration();
                new JoglApplication(new RPiGemo(), config);
        }
}

4. then build the libgdx grade project as usual, preferably using eclipse.
The project will now run fine on your desktop dev machine.

5. To have the project running on a ARM GNU/Linux system you have to insert you own compiled libgdxarm.so into the gdx-platform-1.6.2-natives-desktop.jar
This will be fixed when ARM GNU/Linux support is merged into libgdx: https://github.com/libgdx/libgdx/pull/3196
The project will then run fine on the RaspberryPi 2
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

gouessej
Administrator
Hi

I have just merged your pull request, thank you very much. Your notes are going to be very useful, especially for the newbies :)

Somebody asked me whether LibGDX works with the Raspberry Pi 2 and our backend, you have given him the right answer :D Keep up the good work. I have to update my repository very soon.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

Xerxes Rånby
gouessej wrote
Hi

I have just merged your pull request, thank you very much. Your notes are going to be very useful, especially for the newbies :)

Somebody asked me whether LibGDX works with the Raspberry Pi 2 and our backend, you have given him the right answer :D Keep up the good work. I have to update my repository very soon.
I have created a libgdx thread on the raspberry pi forum to collect all loose threads how to get libgdx running on the Raspberry Pi.
https://www.raspberrypi.org/forums/viewtopic.php?f=81&t=112806
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

piotrekk
This post was updated on .
In reply to this post by Xerxes Rånby
Hello,

Eveyrything is clear except point no 5:

"5. To have the project running on a ARM GNU/Linux system you have to insert you own compiled libgdxarm.so into the gdx-platform-1.6.2-natives-desktop.jar "

How can i do that? Can you explain it step by step?

The is also a lot of erros when i try to run project at Eclipse:

Exception in thread "main-AWTAnimator#00" com.jogamp.opengl.util.AnimatorBase$UncaughtAnimatorException: com.jogamp.opengl.GLException: Caught IllegalArgumentException: Error compiling shader: ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:1: 'attribute' : syntax error: syntax error
ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:7: 'varying' : syntax error: syntax error
 on thread main-AWTAnimator#00
        at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:84)
        at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:451)
        at com.jogamp.opengl.util.Animator$MainLoop.run(Animator.java:198)
        at java.lang.Thread.run(Thread.java:745)
Caused by: com.jogamp.opengl.GLException: Caught IllegalArgumentException: Error compiling shader: ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:1: 'attribute' : syntax error: syntax error
ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:7: 'varying' : syntax error: syntax error
 on thread main-AWTAnimator#00
        at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1311)
        at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1131)
        at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:680)
        at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:77)
        ... 3 more
Caused by: java.lang.IllegalArgumentException: Error compiling shader: ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:1: 'attribute' : syntax error: syntax error
ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:7: 'varying' : syntax error: syntax error

        at com.badlogic.gdx.graphics.g2d.SpriteBatch.createDefaultShader(SpriteBatch.java:157)
        at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:120)
        at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:73)
        at com.mygdx.game.MyGdxGame.create(MyGdxGame.java:15)
        at com.badlogic.gdx.backends.jogamp.JoglGraphics.init(JoglGraphics.java:88)
        at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:641)
        at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:663)
        at jogamp.opengl.GLAutoDrawableBase$1.run(GLAutoDrawableBase.java:430)
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1275)
        ... 6 more
AL lib: (EE) alc_cleanup: 1 device not closed


Greetings,
Peter
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

gouessej
Administrator
The default GLSL shader of the sprite batcher doesn't contain the "version" directive. "varying" has been replaced by "in" and "out".
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

Xerxes Rånby
In reply to this post by piotrekk
Peter wrote
The is also a lot of erros when i try to run project at Eclipse:
...
Caused by: java.lang.IllegalArgumentException: Error compiling shader: ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:1: 'attribute' : syntax error: syntax error
ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:7: 'varying' : syntax error: syntax error

        at com.badlogic.gdx.graphics.g2d.SpriteBatch.createDefaultShader(SpriteBatch.java:157)
        at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:120)
...
Like Gouessej said, this is caused by your new OpenGL driver.
This is caused by changes in the OpenGL GLSL standard between different OpenGL versions.
We have a tutorial in the jogamp wiki how to write cross GLProfile compatible GLSL shaders:
http://jogamp.org/wiki/index.php/How_to_write_cross_GLProfile_compatible_shader_using_JOGL
The default GLSL shader used by gdx SpriteBatch needs to be updated to work with non backward compatible OpenGL 3 and 4 profiles.
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

Xerxes Rånby
Xerxes Rånby wrote
Peter wrote
The is also a lot of erros when i try to run project at Eclipse:
...
Caused by: java.lang.IllegalArgumentException: Error compiling shader: ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:1: 'attribute' : syntax error: syntax error
ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:7: 'varying' : syntax error: syntax error

        at com.badlogic.gdx.graphics.g2d.SpriteBatch.createDefaultShader(SpriteBatch.java:157)
        at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:120)
...
Like Gouessej said, this is caused by your new OpenGL driver.
This is caused by changes in the OpenGL GLSL standard between different OpenGL versions.
We have a tutorial in the jogamp wiki how to write cross GLProfile compatible GLSL shaders:
http://jogamp.org/wiki/index.php/How_to_write_cross_GLProfile_compatible_shader_using_JOGL
The default GLSL shader used by gdx SpriteBatch needs to be updated to work with non backward compatible OpenGL 3 and 4 profiles.

A workaround for this bug is to explicitly request an "old" GLProfile such as GLES2 and if that is not found try with GL2. This can be done by reverting the following block inside
backends/gdx-backend-jogamp/src/com/badlogic/gdx/backends/jogamp/JoglGraphicsBase.java
https://github.com/gouessej/libgdx/commit/b44dfbb89175e549ae5d31fa32cdd6fcd6232fd9#diff-edd3ab0e3f9dee326e91e15898bf85f6R48

Maybe we should only try to use GLProfile.getMaxProgrammable(true) if the user explicitly request GL30 ?
Hence use the old logic to try GLES2 and GL2 for GL20.
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

piotrekk
so, i add my shaders with version directive, like this:

vertex shader:

#version 120
attribute vec4 a_color;
attribute vec3 a_position;
attribute vec2 a_texCoord0;

uniform mat4 u_projTrans;

varying vec4 v_color;
varying vec2 v_texCoord0;

void main() {
        v_color = a_color;
        v_texCoord0 = a_texCoord0;
        gl_Position = u_projTrans * vec4(a_position, 1.0);
}

fragment shader:

#version 120
varying vec4 v_color;
varying vec2 v_texCoord0;

uniform sampler2D u_sampler2D;
uniform mat4 u_projTrans;

void main() {

        vec3 color = texture2D(u_sampler2D, v_texCoord0).rgb;
        vec4 colorAlpha = texture2D(u_sampler2D, v_texCoord0);
        float gray = (color.r + color.g + color.b) / 3.0;
        vec3 grayscale = vec3(gray);
     
    gl_FragColor = vec4(grayscale, colorAlpha.a);
}

and still i have error messages:

Exception in thread "main-AWTAnimator#00" com.jogamp.opengl.util.AnimatorBase$UncaughtAnimatorException: com.jogamp.opengl.GLException: Caught IllegalArgumentException: Error compiling shader: ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:1: 'attribute' : syntax error: syntax error
ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:7: 'varying' : syntax error: syntax error
 on thread main-AWTAnimator#00
        at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:84)
        at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:451)
        at com.jogamp.opengl.util.Animator$MainLoop.run(Animator.java:198)
        at java.lang.Thread.run(Thread.java:745)
Caused by: com.jogamp.opengl.GLException: Caught IllegalArgumentException: Error compiling shader: ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:1: 'attribute' : syntax error: syntax error
ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:7: 'varying' : syntax error: syntax error
 on thread main-AWTAnimator#00
        at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1311)
        at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1131)
        at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:680)
        at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:77)
        ... 3 more
Caused by: java.lang.IllegalArgumentException: Error compiling shader: ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:1: 'attribute' : syntax error: syntax error
ERROR: 0:1: '' :  #version required and missing.
ERROR: 0:7: 'varying' : syntax error: syntax error

        at com.badlogic.gdx.graphics.g2d.SpriteBatch.createDefaultShader(SpriteBatch.java:157)
        at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:120)
        at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:73)
        at com.mygdx.game.MyGdxGame.create(MyGdxGame.java:18)
        at com.badlogic.gdx.backends.jogamp.JoglGraphics.init(JoglGraphics.java:88)
        at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:641)
        at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:663)
        at jogamp.opengl.GLAutoDrawableBase$1.run(GLAutoDrawableBase.java:430)
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1275)
        ... 6 more
AL lib: (EE) alc_cleanup: 1 device not closed
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

gouessej
Administrator
Your shaders don't seem to be taken into account. Moreover, you still use the keyword "varying" instead of "in" and "out".
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

gouessej
Administrator
This post was updated on .
In reply to this post by piotrekk
You should modify this method:
https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/SpriteBatch.java#L127

Edit.: We should use #ifdef GL_ES_VERSION_3_0 or GL_ES_VERSION_2_0 to use the correct modifiers.

Edit.: We should use #version 100 with OpenGL ES 2.0, #version 110 with OpenGL 2.0, #version 120 with OpenGL 2.1 and so on:
https://en.wikipedia.org/wiki/OpenGL_Shading_Language#Versions
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

Xerxes Rånby
gouessej wrote
You should modify this method:
https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/SpriteBatch.java#L127

Edit.: We should use #ifdef GL_ES_VERSION_3_0 or GL_ES_VERSION_2_0 to use the correct modifiers.

Edit.: We should use #version 100 with OpenGL ES 2.0, #version 110 with OpenGL 2.0, #version 120 with OpenGL 2.1 and so on:
https://en.wikipedia.org/wiki/OpenGL_Shading_Language#Versions
Last time i looked at this i deemed the task to make all libgdx shaders compatible with all GLProfiles a too large problem to tackle for the initial JogAmp JOGL port.

We can never patch all games using the libgdx GL20 api to stay shader compatible.
Some parts of the libgdx API still require automatic memory management only found using GL2 and GLES 2 thus the port will not be complete if we request a core profile for GL20.

Hence i would advise that we only request core profiles that require new shaders if the user has requested useGL30.
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

gouessej
Administrator
In reply to this post by piotrekk
There is a difference between desktop GLSL and embedded GLSL versions. OpenGL ES 3 supports version #300. There should be something that queries GL_SHADING_LANGUAGE_VERSION and uses it to generate the right shaders.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

gouessej
Administrator
In reply to this post by Xerxes Rånby
Xerxes Rånby wrote
Hence i would advise that we only request core profiles that require new shaders if the user has requested useGL30.
Good idea.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

gouessej
Administrator
In reply to this post by Xerxes Rånby
I thought we could use #ifdef GL_core_profile or #ifdef GL_compatibility_profile but it seems to be tricky to modify all shaders :s
https://www.opengl.org/wiki/Core_Language_%28GLSL%29
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.0 (OpenGL/OpenGL-ES) backend for LibGDX

Xerxes Rånby
Libgdx is OpenGL ES 1, 2 3 centric

thus if the user requests useGL30 we should first try to use GLES3, then
GL2ES3 and if all else fail use GLProfile.getMaxProgrammable(true)
thus if the user wants GL20 we should first try to use GLES2, then GL2,
and if all else fail GL2ES2
thus if the user wants GL10 we should first try to use GLES1, then GL2,
and if all else fail GL2ES1

the shader issue is found for all OpenGL ES 3 libgdx backends, thus it
is nothing that we need to solve in the JogAmp team.

Den 2015-06-10 17:03, gouessej [via jogamp] skrev:
> I thought we could use #ifdef GL_core_profile or #ifdef
> GL_compatibility_profile but it seems to be tricky to modify all
> shaders :s
> https://www.opengl.org/wiki/Core_Language_%28GLSL%29

1 ... 78910111213