Processing P3D, Raspberry Pi, OpenGL doesn't work

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Processing P3D, Raspberry Pi, OpenGL doesn't work

cicciottino@libero.it
Processing P3D, Raspberry Pi, OpenGL doesn't work

in order to make "Processing" working on the RaspberryPI 2
i've downloaded and copied the content of
the package http://jogamp.org/deployment/jogamp-current/archive/jogamp-all-platforms.7z
inside the core\library folder of "processing 2.2.1"
(to solve the problem related to OpenGL  ...at least i hope to have understood something about the problem )


before this operation the "Processing" error was:
[code]
glGetError 0x500
glGetError 0x500
java.lang.ClassCastException: javax.media.nativewindow.DefaultGraphicsConfiguration cannot be cast to com.jogamp.nativewindow.awt.AWTGraphicsConfiguration
        at javax.media.opengl.awt.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:1421)
        at javax.media.opengl.awt.GLCanvas.addNotify(GLCanvas.java:630)
        at java.awt.Container.addImpl(Container.java:1114)
        at java.awt.Container.add(Container.java:966)
        at processing.opengl.PJOGL.initSurface(PJOGL.java:347)
        at processing.opengl.PGraphicsOpenGL.initPrimary(PGraphicsOpenGL.java:6310)
        at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1653)
        at processing.core.PApplet.run(PApplet.java:2256)
        at java.lang.Thread.run(Thread.java:724)
[/code]


after that the error changed in :
[code]
java.lang.NoClassDefFoundError: javax/media/opengl/GLException
        at processing.opengl.PGraphicsOpenGL.createPGL(PGraphicsOpenGL.java:1744)
        at processing.opengl.PGraphicsOpenGL.<init>

(PGraphicsOpenGL.java:518)
        at processing.opengl.PGraphics3D.<init>(PGraphics3D.java:37)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at

sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance

(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at processing.core.PApplet.makeGraphics(PApplet.java:1919)
        at

processing.core.PApplet.size(PApplet.java:1771)
        at processing.core.PApplet.size(PApplet.java:1742)
        at MoveEye.setup(MoveEye.java:25)
        at processing.core.PApplet.handleDraw

(PApplet.java:2361)
        at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240)
        at processing.core.PApplet.run(PApplet.java:2256)
        at java.lang.Thread.run

(Thread.java:724)
Caused by: java.lang.ClassNotFoundException: javax.media.opengl.GLException
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run

(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass

(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 15 more

[/code]


have i forgotten to do something after having copied the jars? do i need to update some path or change some configuration? or do something else?

i'm not so skilled with linux, sorry
Don't ban me if i've used the wrong section of the forum or the question was already discussed, please :-(

-Raspberry 2
-Oracle Java 1.7.0_40-b43
-Processing 2.2.1
Reply | Threaded
Open this post in threaded view
|

Re: Processing P3D, Raspberry Pi, OpenGL doesn't work

Xerxes Rånby
This post was updated on .
Hi Processing 2.x.x is built around the concept that all windows inherit a java applet surface and thus indirectly is using an AWT X11 Window surface.
The properitary Broadcom Raspbery Pi OpenGL ES driver is using a dispmanx surface for that is incompatible with AWT X11 Window surfaces.

JogAmp can initialize the Broadcom specifix dispmanx surface using the NEWT API.
Processing 3.x.x has removed all support for applets and thus switched from using AWT to NEWT for all P3D sketches!
This means that hardware acceleration with processing on the raspberry pi is possible when using Processing 3.

As a proof of concept


As you can see in this image NEWT uses the dispmanx api to provide a hardware accelerated window on top of the xorg window, NEWT also provide a "white" mousepointer.

The above image was generated by combining the latest jogl git + a patched version of processing to initialize a gl2es2 profile and removing some calls that cased runtime exceptions using the raspberry pi opengl es 2 driver.
https://github.com/xranby/processing/commits/arm-3.0-rebased


There exist one alternative by using the new free software Mesa3D vc4 OpenGL 2 driver you can get processing 3 running on the raspberry pi similar to a desktop system. The Mesa3D vc4 driver expects use of AWT X11 Windows thus it shall work with both Processing 2 and Processing 3.
http://labb.zafena.se/?p=972

Reply | Threaded
Open this post in threaded view
|

Re: Processing P3D, Raspberry Pi, OpenGL doesn't work

Xerxes Rånby
http://labb.zafena.se/jogamp/vc4/video20150717_163245117.mp4 video of Processing 3 running the RGB Cube demo using the Broadcom OpenGL ES 2 driver using NEWT and dispmanx

there was some odd heuristics in the processing 3 codebase that prevented the animator to start, the following trick to replace all use of FPSAnimator with Animator and forcing the Animator to start when the window became visible made it work:
https://github.com/xranby/processing/commit/f9d170b33bf727d881a0de2e796f9a1e50b5b0b4
Reply | Threaded
Open this post in threaded view
|

Re: Processing P3D, Raspberry Pi, OpenGL doesn't work

cicciottino@libero.it
thanks for the detailed explanation, this will help me to move better inside the linux and java world.

So, the more practicable way seems to me being the "modified" version of "Processing 3" that you suggested me: https://github.com/xranby/processing/commits/arm-3.0-rebased


After having cloned/downloaded the repository, should i build the software? or is it ready to be copied in the raspberry?

if the first option, is it enough to use these commands to build?
[code]
sudo make
sudo make install
[/code]

from the  downloaded folder? (from elsewhere?)


sorry for the stupid questions but i'm trying to understan well what i'm doing
might you assist me a little bit :-) thanks a lot
Reply | Threaded
Open this post in threaded view
|

Re: Processing P3D, Raspberry Pi, OpenGL doesn't work

Xerxes Rånby
For each project you want to build its crucial to familiarize yourself with the projects build instructions, it is likely that your system is configured slightly different compared to how the projects developers have organized their build machines and each difference in the setup may break the build.

In processing's case you shall read the
https://github.com/processing/processing/wiki/Build-Instructions

To build processing 3 you fist need to checkout the processing 3 source code and switch to my branch
git clone https://github.com/xranby/processing
cd processing
git checkout arm-3.0-rebased

the processing build instructions for linux can be summarized by using a linux machine and running:
cd processing/build
ant

the generated processing image is found in
processing/build/linux/work
we are especially interested in the jars that are found inside
processing/build/linux/work/core/library/
here you will find all the jogamp jar's and the processing core.jar
only the core.jar got built during the above mentioned build process.

if you have downloaded processing 3 then you can simply replace the core.jar to test the new functionality.

if you for some reason need to change any of the jogamp jars then you need to build jogamp jogl from source using jogamp's build process,
http://jogamp.org/jogl/doc/HowToBuild.html
...or wait for jogamp's build bots to build and publish the next release and then copy the new jars into you processing/core/library folder
Reply | Threaded
Open this post in threaded view
|

Re: Processing P3D, Raspberry Pi, OpenGL doesn't work

cicciottino@libero.it
so i did exactly this:

-  swithced to java 8 with "update-alternative --config java" (as build instructions require)
-  update the JAVA_HOME to the new java 8
-  installed ant (seems to work)
-  cloned your repository
-  built (apparently without error)
-  when i lunched ./processing from .....build/linux/work i got this message:

[code]
/opt/processing/build/linux/work/java/bin/java: l: /opt/processing/build/linux/work/java/bin/java: Syntax error: "(" unexpected
[code]
 
Reply | Threaded
Open this post in threaded view
|

Re: Processing P3D, Raspberry Pi, OpenGL doesn't work

Xerxes Rånby
cicciottino@libero.it wrote
-  when i lunched ./processing from .....build/linux/work i got this message:
/opt/processing/build/linux/work/java/bin/java: l: /opt/processing/build/linux/work/java/bin/java: Syntax error: "(" unexpected
Processing like to bundle a JVM into the work/java directory of the build depending on the arch you use during the build.
The error you see is caused when you are trying to run a x86 JVM on a ARM system.
If you had performed the build directly on the Pi then is expected that the build had download a ARM JVM into java folder.

Gottfried Haider is working part of this years google summer of code 2015 to make processing work on ARM. If you run into any build issues/ usage issues related to processing then I suggest that you contact Gottfried so you two can collaborate on how to resolve the issues.

A workaround is to delete the work/java directory. Processing will then use system installed java if the processing/java folder can't be found.

Reply | Threaded
Open this post in threaded view
|

Re: Processing P3D, Raspberry Pi, OpenGL doesn't work

cicciottino@libero.it
ok thanks for the valuable information
i'll contact Gottfried Haider to have further information.

just  a clarification about how ant works, if i build the source more than once, every
built process is clean(as the first time)? or have i run some sort of command to clean
manulally the build folder before to run a new "ant"?

i did a step forward removing the java folder inside the work directory and creating a
symbolic link to the current java installation (that i have in the JAVA_HOME)
in this case the error message is different:

[code]
Annotation processing got disabled, since it requires a 1.6 compliant JVM
 /tmp/Array5624396829394994548temp/Array.java:1: error: The type
 java.util.Map$Entry cannot be resolved. It is indirectly referenced
 from required .class files
         import processing.core.*;
         ^
 1 problem (1 error)
[/code]
Reply | Threaded
Open this post in threaded view
|

Re: Processing P3D, Raspberry Pi, OpenGL doesn't work

Xerxes Rånby
This post was updated on .
cicciottino@libero.it wrote
ok thanks for the valuable information
i'll contact Gottfried Haider to have further information.
Gottfried Haider runs a build bot that produces daily builds of processing 3 and a complete system image that you can download and install on your raspberry pi.
Thus the easiest route is for you to simply downloads gohais system image!
http://sukzessiv.net/~gohai/vc4-buildbot/build/

sourcecode and instructions how to setup this buildbot that generated the processing 3 images for arm is found at:
https://github.com/gohai/vc4-buildbot/

cicciottino@libero.it wrote
just  a clarification about how ant works, if i build the source more than once, every
built process is clean(as the first time)? or have i run some sort of command to clean
manulally the build folder before to run a new "ant"?
You need to take a look at the ant manual.
https://ant.apache.org/manual/
https://ant.apache.org/manual/using.html#buildfile
as you can see ant tasks are quite simple, ant only do whats instructed in the build.xml
if the build.xml say ant shall run and jump off a cliff then ant will do that.
likewise if you run ant clean ant only do what is instructed in the build.xml clean task.

cicciottino@libero.it wrote
i did a step forward removing the java folder inside the work directory and creating a
symbolic link to the current java installation (that i have in the JAVA_HOME)
in this case the error message is different:

[code]
Annotation processing got disabled, since it requires a 1.6 compliant JVM
 /tmp/Array5624396829394994548temp/Array.java:1: error: The type
 java.util.Map$Entry cannot be resolved. It is indirectly referenced
 from required .class files
         import processing.core.*;
         ^
 1 problem (1 error)
[/code]
If you do too many manual workarounds you will end up with a build system that is only supported by you!
Reply | Threaded
Open this post in threaded view
|

Re: Processing P3D, Raspberry Pi, OpenGL doesn't work

Xerxes Rånby
This post was updated on .
In reply to this post by cicciottino@libero.it
cicciottino@libero.it wrote
[code]
Annotation processing got disabled, since it requires a 1.6 compliant JVM
 /tmp/Array5624396829394994548temp/Array.java:1: error: The type
 java.util.Map$Entry cannot be resolved. It is indirectly referenced
 from required .class files
         import processing.core.*;
         ^
 1 problem (1 error)
[/code]
last time i saw this bug was in 2013, caused by trying to use an old version of ecj with jdk 8.
https://github.com/processing/processing/issues/2260

Updating java/mode/ecj.jar inside Processing 2.1
to eclipse ecj version 4.3.1 or later
http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops4/R-4.3.1-201309111000/ecj-4.3.1.jar
fixes this issue.

This issue is supposed to have been fixed when processing 3 switched to use jdk 8, check if processing has replaced the ecj.jar with a new jdk 8 compatible verison!