ok, so after corrections my shaders looks like:
vertex: #version 120 in vec4 a_color; in vec3 a_position; in vec2 a_texCoord0; uniform mat4 u_projTrans; out vec4 v_color; out vec2 v_texCoord0; void main() { v_color = a_color; v_texCoord0 = a_texCoord0; gl_Position = u_projTrans * vec4(a_position, 1.0); } fragment: #version 120 in vec4 v_color; in 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 i have still errors: 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 |
Administrator
|
Please provide a patch. How do you modify the shaders? According to the stack trace, the sprite batcher still uses the default shaders and your changes aren't taken into account. Moreover, which version of OpenGL or OpenGL ES do you target? If you target OpenGL 2.1, #version 120 makes sense; if you target OpenGL ES 2.0, it doesn't. Please ensure that you rebuild the JogAmp backend after making any change.
Julien Gouesse | Personal blog | Website
|
Administrator
|
In reply to this post by Xerxes Rånby
I've just updated my repository ;)
Julien Gouesse | Personal blog | Website
|
Dear Julien,
I have cloned again your repo, maybe tomorrow i will fight with default libgdx shaders code and then i'll let you know if I succeeded :) Goodnight, Peter |
Administrator
|
In reply to this post by gouessej
On 06/10/2015 04:52 PM, gouessej [via jogamp] wrote:
> 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. This is being used - if available - in GLContext: <http://jogamp.org/wiki/index.php/How_to_write_cross_GLProfile_compatible_shader_using_JOGL#GLSL_Version_Directive> ~Sven signature.asc (828 bytes) Download Attachment |
In reply to this post by piotrekk
I quickly prepared a patch that would allow your hardware to compile the non-modified shaders https://github.com/xranby/libgdx/commit/aafb0c1fbe9d377a530129a838124d7de2a0f166 It is untested but should fix your issue by avoiding trying to compile the shaders using a core profile. Cheers Xerxes |
Xerxes, how to apply that patch to check it?
|
You can cherry-pick it using git git remote add xranby https://github.com/xranby/libgdx git fetch xranby git cherry-pick aafb0c1fbe9d377a530129a838124d7de2a0f166 This will apply the patch on your current work tree |
Dear Xerxes,
Thank you for tip with cherry-pick. First i do that: git remote add xranby https://github.com/xranby/libgdx git fetch xranby git cherry-pick aafb0c1fbe9d377a530129a838124d7de2a0f166 at my local copy of repository: https://github.com/gouessej/libgdx after that i go to that repo and execute this command: mvn install after that i load my libgdx project to eclipse, refresh all gradle dependencies and try to build, but i have still these errors: 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 what is wrong with my workflow? You sad that your patch will fix these problems :/ Greetings, Peter |
This post was updated on .
Remember to update the dependency of your project to match the latest libgdx version that you have compiled. in your project edit the build.gradle and if you are using gouessej's latest libgdx verison then you should use gdxVersion = '1.6.3-SNAPSHOT' i think i have given errornous instructions before in this thread to set an explicit version of the gdx-backend-jogamp, best is ofcourse to use the same version of libgdx and the gdx-backend-jogamp ! thus in your projects build.gradle you should use this dependencies section project(":desktop") { apply plugin: "java" dependencies { compile project(":core") compile "com.badlogicgames.gdx:gdx-backend-jogamp:$gdxVersion" compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" } } I think i also found the root cause why this correct dependencies section did not work before and the answer is that the gdx-backend-jogamp pom compiled against the wrong libgdx version! https://github.com/xranby/libgdx/commit/376290b8b198fef12ee4e4bdb55878a92105a34a In your case this may explain why your changes to the libgdx shaders did not fix anything because you worked on 1.6.3-SNAPSHOT while the jogamp backend errornously pulled in some old snapshot. try this new cherry pick and tell if it fixes your issues. git fetch xranby git cherry-pick 376290b8b198fef12ee4e4bdb55878a92105a34a |
Take an extra look at the build.gradle of one of the libgdx demos
https://github.com/libgdx/libgdx-demo-pax-britannica/blob/master/build.gradle This build.gradle query the official libgdx homepage to allways use the latest snapshot version this means that you do not need to update the projects gdxVersion = when you focus your work on the libgdx system files.
|
YEAH! It works!!! Thank you so much Xerxes!
So now i need this, as you sad: "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? |
This post was updated on .
thank you for verifying that the fixes worked! I have sent a pull request to gouessej for these two regressions. https://github.com/gouessej/libgdx/pull/6 First build the libgdx.so file, I will explain how by using the patch from my libgdx pull request that is under review. https://github.com/libgdx/libgdx/pull/3196 lets start by applying the ARM 32 GNU/Linux cross compile support patch. git cherry-pick 9f5f99a2e7532827c631d54abc331c8c83df1dea On my x86_64 development machine i will first install a cross compile toolchain that can cross compile for armhf. sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf then i will run from inside the libgdx sourcetree cd gdx/jni ant -f build-linux32-arm.xml ant -f build-linux32-armgnueabihf.xml after this you will find the two freshly cross compiled libraries in: libgdx/gdx/libs/linux32arm/libgdxarm.so and libgdx/gdx/libs/linux32armhf/libgdxarmgnueabihf.so good now we need to copy these to libs to a place where they are picked up when you run your game or project on the Raspberry Pi 2. I have only tested to export my project for use on my Pi's using eclipse runnable jars so i will explain this way of deploying. After you have exported your project as a runnable jar using eclipse: Export -> Java -> Runnable jar file Select the Launch configuration that matches your DesktopLauncher Select the export destination directory and jar file name. Select Library handling * Package required libraries into generated JAR (one jar) OR Library handling * Copy required libraries into a sub-folder next to the generated JAR Then click on Finnish now you have two options A) copy the generated libgdx/gdx/libs/linux32arm/libgdxarm.so next to the exported jar file B) open the gdx-platform-1.6.3-natives-desktop.jar that has been bundled inside the exported JAR file or is found in a subfolder next to the exported JAR file. JAR files are basically .zip files thus you can open a jar file using the gnome Archive Manager and then add the libgdxarm.so to the JAR file (zip) A) is probably the easiest and will work because libgdx will try to load libgdxarm.so from the java.library.path and the launch directory when it fail to find the library inside the jar. |
This post was updated on .
Example how to change an existing libgdx grade project to use the gdx-backend-jogamp:
https://github.com/xranby/libgdx-demo-pax-britannica/commit/4c2bafc104c2d7104dad5299d196423d932cf7c5 The only prerequsite is that you have cloned, built and installed gouessej's libgdx git git clone https://github.com/gouessej/libgdx/ cd libgdx mvn install I have picked the libgdx-demo-pax-britannica https://github.com/xranby/libgdx-demo-pax-britannica/tree/gdx-backend-jogamp check it out, compile it and then run it using git clone -b gdx-backend-jogamp https://github.com/xranby/libgdx-demo-pax-britannica cd libgdx-demo-pax-britannica ./gradlew run I have published a binary pre-release of this build here: https://github.com/xranby/libgdx-demo-pax-britannica/releases/tag/gdx-backend-jogamp-libgdx-1.6.3-SNAPSHOT |
Dear Xerxes,
i have a problem with this: "On my x86_64 development machine i will first install a cross compile toolchain that can cross compile for armhf. sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf" I have only mac machine with latest osx, i have read a little about cross compiling for arm but it is too difficult for me :/ Can you help me with that? If it is too difficult to do on mac maybe i could do that on raspberry? Greetings, Peter |
You can compile it on a raspberry. I have posted a pre-compiled demo jar (that work on both desktop and mobile systems) and pre-compiled .so files , compiled using my raspberry pi raspbian system for use on armhf here: https://github.com/xranby/libgdx-demo-pax-britannica/releases/tag/gdx-backend-jogamp-libgdx-1.6.3-SNAPSHOT |
Hello Xerxes,
I have exported sample project from libgdx, when i try to lunch on Rpi i have this: pi@raspberrypi ~/Desktop $ ls libgdxarmgnueabihf.so libgdxarm.so libgdx-demo-pax-britannica-1.6.3-SNAPSHOT.jar test.jar test_lib pi@raspberrypi ~/Desktop $ java -jar test.jar glGetError 0x500 glGetError 0x500 Exception in thread "main" com.jogamp.opengl.GLException: Profile GL2 is not available on null, but: [GLProfile[GLES1/GLES1.hw], GLProfile[GLES2/GLES2.hw], GLProfile[GL2ES1/GLES1.hw], GLProfile[GL2ES2/GLES2.hw], GLProfile[GLES2/GLES2.hw]] at com.jogamp.opengl.GLProfile.get(GLProfile.java:990) at com.jogamp.opengl.GLProfile.get(GLProfile.java:1003) at com.badlogic.gdx.backends.jogamp.JoglGraphicsBase.initialize(JoglGraphicsBase.java:62) at com.badlogic.gdx.backends.jogamp.JoglGraphics.<init>(JoglGraphics.java:50) at com.badlogic.gdx.backends.jogamp.JoglApplication.initialize(JoglApplication.java:83) at com.badlogic.gdx.backends.jogamp.JoglApplication.<init>(JoglApplication.java:77) at com.mygdx.game.desktop.DesktopLauncher.main(DesktopLauncher.java:24) my sample app is here: (and it works fine on osx) http://tinyurl.com/orxho4u what is wrong? greetings, Peter |
Hi When I wrote the code to fix your desktop OpenGL core shader issue by switching to GL2 I forgot to catch the GLException on OpenGL ES 2 systems. The following commit fixes the above exception. https://github.com/xranby/libgdx/commit/fac3bc895e5aeb69eb85237936a2fe3cb6a3fbe1 try cherry pick this commit. gouessej has merged this commit thus if you use his master branch then all will work. |
Thank you for patch, now application runs on RPi but i have a few problems with this:
Application running in "window" mode looks like this: And question is: is it possible to have a window border on RPi? Application running in window, when you move a mouse cursor to the top of screen shows this glitches: Application running in fullscreen mode don't draw a texture: fullscreen mode i activate with this code at DesktopLauncher libgdx class: public class DesktopLauncher { public static void main (String[] arg) { JoglApplicationConfiguration config = new JoglApplicationConfiguration(); config.fullscreen = true; new JoglApplication(new MyGdxGame(), config); } } And question is: what is wrong with my code? and last thing - Xerxes pax-britannica running in window mode, I think that is malfunctioning with cursor mapping in application Greetings, Peter |
This post was updated on .
Nice to see that you have your libgdx application running! Thank you for documenting your effort with pictures. I will start describe what you actually see in the pictures. All OpenGL ES applications using the closed source Broadcom videocore driver must use the Broadcom specific API named DispmanX to show graphics, this includes all the OpenGL ES examples found in /opt/vc/src OpenGL ES on Raspberry Pi using the Broadcom videocore driver is "special", the window you see is not using X11 instead it is a DispmanX window. The application can run from text console without starting X11. The only manual available how DispmanX operate is the examples and headers in the raspberrypi userland git: example: https://github.com/raspberrypi/userland/blob/d4aa617de3b196399bb8e2ce32e181768cb52179/host_applications/linux/apps/hello_pi/hello_triangle/triangle.c#L111-L171 header: https://github.com/raspberrypi/userland/blob/d4aa617de3b196399bb8e2ce32e181768cb52179/interface/vmcs_host/vc_dispmanx.h implementation: https://github.com/raspberrypi/userland/blob/d4aa617de3b196399bb8e2ce32e181768cb52179/interface/vmcs_host/vc_vchi_dispmanx.c There is an alternative free software driver for the raspberry pi that is being created by Eric Anholt that will implement a full OpenGL X11 Glamour Mesa3d driver, if you manage to use Eric's new driver then you will have better experience using your application inside X11. Erics driver do not use dispmanx http://www.anholt.net/ http://anholt.livejournal.com/ This needs to be implemented we have a documented the blueprints required here: https://jogamp.org/bugzilla/show_bug.cgi?id=626#c3 the main idea is to render offscreen and then use code similar to the example code on how to do efficient DMA GPU to CPU memory copy on the Pi to update the X11 window https://github.com/shirro/pi-eglonx - "OpenGL ES rendering to X window" alternative 2: if you want NEWT to render window borders in textmode then we need to add it similar code to how we added the NEWT mousepointer. https://jogamp.org/bugzilla/show_bug.cgi?id=676 A new enhancement bugreport is required with a topic such as "Add support for native WindowBorder rendering (Rasp.-Pi. .. etc)" alternative 3: if you use Anholts driver then X11 will work and you will get a window border for free. Nice effect :) The "mousepointer" is a dispmanx overlay. The overlay looks to have an unexplainable offset in the other direction -100 pixels in X to the left and +100 pixels in Y upward compared to the whole screen. When graphics is rendered outside the screen then you see this nice demoeffect. The question is what adds the offset? i think your code is correct its possible that the image is outside the screen, the application is designed to show much red, you should try with an example that render the texture on the whole visible surface. I have tested to use disable_overscan=1 in the /boot/config.txt and the problem still persist thus I think I can rule out the overscan setting. all demos in /opt/vc/src/hello_pi starts at the top left corner thus i have to examine the jogl code closer. I will do some extra rounds of code review of the three commits inside JOGL that implement the RaspberryPi mousepointer. 1a0b3287870beca22b0a03aa604fc6a5574a962b bf0e93260dbd6cb8b6ee0cd10d81341906e62da9 667eca532d3749b0f08e694f36624ff7f621a9c8 https://jogamp.org/bugzilla/show_bug.cgi?id=676 |
Free forum by Nabble | Edit this page |