User avatar
Fidelius
Posts: 460
Joined: Wed Jan 01, 2014 8:40 pm
Location: Germany

Accelerated 2D & 3D with JavaFX8 or ...?

Mon Jan 27, 2014 10:21 am

What's a good way to do hardware accelerated 2D and 3D graphics on the nice PI with Java?

I saw Henrik's older post on the forum pointing to an article on the OpenJDK's Wiki (~summer 2013) with the following nice sentence:
JDK 8 EA builds for the Raspberry Pi include full support for hardware accelerated graphics, with everything from the base, graphics, controls and FXML modules. Media and Web modules are not included.
The few demos of the JDK-8 EA from January 2014 run excellent on Windows, and seeing the good old Java3D inside Java 8 is amazing (I hadn't seen JavaFX before). And the importer! which was missing badly in Java3d.
It's great to have 2D and 3D acceleration in the upcoming standard Java 8 for all platforms. I really hope it's for all platforms. Also Linux, and Pi, etc. Does anybody know details here?

In case Java 8 uses HW acceleration on the Pi too, does it use OpenVG for 2D operations, and OpenGL-ES for 3D operations, so that we could run both together in parallel via overlay or such? Or does JavaFX render 2D and 3D always via OpenGL-ES "only" ?


I downloaded the JDK8 preview for the ARM built in January 2014, and tried to run the few JavaFX8 examples on the PI with the latest Raspbian. Unfortunately, I wasn't successful so far... See next post please for details.

(Others showed accelerated 3D via Java on the PI half a year ago, for example in the OpenJDK's mailing-list there's been an article: Raspberry Pi + JavaFX 3D demo, which links to an interesting Youtube video...)
Last edited by Fidelius on Tue Jan 28, 2014 4:05 pm, edited 10 times in total.

User avatar
Fidelius
Posts: 460
Joined: Wed Jan 01, 2014 8:40 pm
Location: Germany

Re: Accelerated 2d & 3d with JavaFX8 or ...?

Mon Jan 27, 2014 10:23 am

1) The Ensemble8.jar demo starts and shows the 2D section of demos, but without 2D accleration and so terrible slow.
Also an error message glGetError 0x505 is printed, and so the 3D section of Ensemble8 are missing completely -- like is the case with Linux PCs which use the standard Mesa graphics driver only.

Some own tests with a simple JavaFX 2D animation show there's no 2D HW accleration (but then without the "glGetError 0x505").

A pity. What am I missing? There must be something missing, because of what the Wiki said in sommer of 2013:
JDK 8 EA builds for the Raspberry Pi include full support for hardware accelerated graphics, with everything from the base, graphics, controls and FXML modules. Media and Web modules are not included.


P.S. It doesn't matter if I run java with or without a X-Server.

-------------------------------------------------------------------------------

2) The very promising 3DViewer.jar demo reports the same glGetError 0x505 error, then shows just a JavaFX window with borders and menus but black content. It doesn't crash, though, but black content until exit via Ctrl-C.

Code: Select all

[..]
javafx.scene.PerspectiveCamera <init>
WARNING: System can't support ConditionalFeature.SCENE3D

javafx.scene.LightBase <init>
WARNING: System can't support ConditionalFeature.SCENE3D

javafx.scene.SubScene <init>
WARNING: System can't support ConditionalFeature.SCENE3D

javafx.scene.SubScene$2 invalidated
WARNING: System can't support ConditionalFeature.SCENE3D

javafx.scene.SubScene <init>
WARNING: System can't support antiAliasing

javafx.scene.SubScene$2 invalidated
WARNING: System can't support ConditionalFeature.SCENE3D

javafx.scene.paint.Material <init>
WARNING: System can't support ConditionalFeature.SCENE3D

javafx.scene.shape.Mesh <init>
WARNING: System can't support ConditionalFeature.SCENE3D

javafx.scene.shape.Shape3D <init>
WARNING: System can't support ConditionalFeature.SCENE3D

glGetError 0x505
Last edited by Fidelius on Wed Jan 29, 2014 10:24 am, edited 10 times in total.

User avatar
Fidelius
Posts: 460
Joined: Wed Jan 01, 2014 8:40 pm
Location: Germany

Re: Accelerated 2d & 3d with JavaFX8 or ...?

Tue Jan 28, 2014 8:30 am

(text moved into my opening post)
Last edited by Fidelius on Tue Jan 28, 2014 8:50 am, edited 1 time in total.

User avatar
clicky
Posts: 425
Joined: Thu Oct 25, 2012 7:34 am

Re: Accelerated 2d & 3d with JavaFX8 or ...?

Tue Jan 28, 2014 8:50 am

Fidelius wrote:What's the best way to do fast -- aka hardware accelerated -- 2d and 3d graphics on the nice PI with Java?
I don't know what is the 'best' way, but I had some previous experience with LibGDX (and I really like the framework) + I saw: http://www.habitualcoder.com/?page_id=257 and managed to set it up for myself.

I've got 5 java Eclipse projects:
  • main with 3D code (2D is supported in same setup directly - maybe even better than 3D)
  • desktop 'starter'
  • android starter/wrapper
  • html5 (gwt project)
  • ios
and I added 6th:
  • raspberry pi 'starter'
Also, using little app I did (http://remotevm.abstracthorizon.org/) I was doing all development on a PC (well mac laptop, but any Eclipse supported platform with enough memory would do) and starting app (for debug and development) on RPi through it.

If you are interested in that setup, do PM me as I don't mind sharing that 'demo' setup. I'll just zip up those Eclipse projects and all you'll need to do is unzip them, copy one jar to RPi, start it on the RPi and setup Eclipse Run Configurations (I don't mind helping you with them as well) and you're ready to type code and run it directly on RPi (through Run... menu in Eclipse).

I am supposed to write a little article about it, but didn't get time to do so, yet.

User avatar
Fidelius
Posts: 460
Joined: Wed Jan 01, 2014 8:40 pm
Location: Germany

Re: Accelerated 2D & 3D with JavaFX8 or ...?

Tue Jan 28, 2014 9:07 am

Thank you Clicky, I'm going to take a closer look, as soon as the habitualcoder.com website is reachable again.
(With "best way to do" I meant "fastest way", and I just corrected that in my initial posting.)

Out of interest, since you're doing accelerated 2D and 3D with Java on the PI : Have you maybe had any luck to get the Java 8 Early-Access demos to run? They mainly use the new Java 8 media library named JavaFX to do 2D and 3D, but unfortunately they don't work yet on my Pi. Once it would also work on the Pi, Java8's JavaFX could present a good standard library for all Java developers to do accelerated 2D and 3D, without the need of external platform dependant libraries.

User avatar
clicky
Posts: 425
Joined: Thu Oct 25, 2012 7:34 am

Re: Accelerated 2D & 3D with JavaFX8 or ...?

Tue Jan 28, 2014 11:02 am

Fastest way is, definitively, for me to send you zip file with a few instructions and you can be up and typing the code in 10 minutes... :)

User avatar
Fidelius
Posts: 460
Joined: Wed Jan 01, 2014 8:40 pm
Location: Germany

Re: Accelerated 2D & 3D with JavaFX8 or ...?

Tue Jan 28, 2014 5:15 pm

Thanks Clicky for the offer, but I first need to take a closer look at your mentioned LibGDX from a general point of view, since I already know Jogl1 (not Jogl2 aka Joamp, though). Secondly I'm not using Eclipse but Netbeans.

Also, I need to test JavaFX in order to see if it's an option to do accelerated 2D and 3D on the PI with a high-level-language approach.
If somebody could please help me to sort out the problems I see when my Pi wants to run the JavaFX demos of Java8-EA (build January 2014), in particular that "glGetError 0x505" error, I'd be very thankful.


Meanwhile for those looking for more details on what JavaFX could give to us developers, here's two articles from Oracle developers. Very interesting, but currently only visible in action (for me) on the big platforms like Windows, unfortunately:

1) On the OpenJDK dev mailing list, Mr. Richard Bair @ SUN/Oracle in May 2013 outlines some general details of how JavaFX would perform on 2D and 3D applications. The entire thread there is interesting.
He's probably the same rbair here on the Raspberry forum who started the informative thread in December 2012: JavaSE Embedded 8 + JavaFX for Raspberry PI (hard float)

2) And again on the dev mailing list Mr. Stephen F Northover explains in January 2014 this interesting bit:
I'll let others describe hardware acceleration in AWT/Swing but in JavaFX, D3D and ES2 shaders are used to draw. These run directly on the graphics card and render data that is downloaded there. Because JavaFX has a scene graph, it has a notion of what has been changed and can render only a subset of the scene graph nodes.

This is a very high level description of JavaFX but captures the essence of what is happening.

danielblaukopf
Posts: 42
Joined: Thu Dec 20, 2012 8:03 pm

Re: Accelerated 2D & 3D with JavaFX8 or ...?

Wed Jan 29, 2014 10:28 am

Hi Fidelius,
Fidelius wrote: It's great to have 2D and 3D acceleration in the upcoming standard Java 8 for all platforms. I really hope it's for all platforms. Also Linux, and Pi, etc. Does anybody know details here?
Not *all* platforms, but a good selection. Windows, OS X, Linux/x86 and Linux/ARM. For Linux/ARM the supported platform in Java 8 is the TI OMAP3 chipset in the BeagleBoard xM. We also ported to the Raspberry and that is included in JDK for ARM. However this is on a "known to work" basis, since this is not the supported platform for the release.
For update releases we plan to support the Freescale i.MX6Q Sabre Device Platform.
Fidelius wrote: In case Java 8 uses HW acceleration on the Pi too, does it use OpenVG for 2D operations, and OpenGL-ES for 3D operations, so that we could run both together in parallel via overlay or such? Or does JavaFX render 2D and 3D always via OpenGL-ES "only" ?
OpenGL ES 2.0 is used for both 2D and 3D rendering operations, when available. When OpenGL is not available, a software rendering pipeline is used. On the Raspberry Pi, OpenGL is used.
Fidelius wrote: I downloaded the JDK8 preview for the ARM built in January 2014, and tried to run the few JavaFX8 examples on the PI with the latest Raspbian. Unfortunately, I wasn't successful so far... See next post please for details.
I will respond separately to your specific points in that post.

Thanks,
Daniel

User avatar
Fidelius
Posts: 460
Joined: Wed Jan 01, 2014 8:40 pm
Location: Germany

Re: Accelerated 2D & 3D with JavaFX8 or ...?

Wed Jan 29, 2014 10:35 am

Great to read your detailed infos, Daniel.
A big thank you; herzlichen Dank.

danielblaukopf
Posts: 42
Joined: Thu Dec 20, 2012 8:03 pm

Re: Accelerated 2d & 3d with JavaFX8 or ...?

Wed Jan 29, 2014 10:40 am

Fidelius wrote:1) The Ensemble8.jar demo starts and shows the 2D section of demos, but without 2D accleration and so terrible slow.
Also an error message glGetError 0x505 is printed
This means you are running with hardware acceleration but OpenGL is running out of memory. The first thing to try is changing the memory split between the CPU and GPU. https://wiki.openjdk.java.net/display/O ... spberry+Pi has a note on how to do that.
Fidelius wrote: and so the 3D section of Ensemble8 are missing completely -- like is the case with Linux PCs which use the standard Mesa graphics driver only.
3D is an experimental feature in JavaFX for Linux/ARM and not completely implemented (see https://javafx-jira.kenai.com/browse/RT-33209). However some parts should work if you enable the feature with the command-line option:

-Dcom.sun.javafx.experimental.embedded.3d=true

You will probably also need to enable the depth buffer (https://javafx-jira.kenai.com/browse/RT-32386):

-Dprism.glDepthSize=24

- Daniel

User avatar
Fidelius
Posts: 460
Joined: Wed Jan 01, 2014 8:40 pm
Location: Germany

Re: Accelerated 2d & 3d with JavaFX8 or ...?

Wed Jan 29, 2014 1:12 pm

danielblaukopf wrote:[.. glGetError 0x505 ..]
This means you are running with hardware acceleration but OpenGL is running out of memory. The first thing to try is changing the memory split between the CPU and GPU. https://wiki.openjdk.java.net/display/O ... spberry+Pi has a note on how to do that.
Oh, I see, good to know. Indeed, then it works. So far 128 MB VRAM does the job for my simple tasks, but maybe larger 2D or 3D scenegraphs could need more; we'll see.
Now the 2D demos like Ensemble8, BrickBreaker, etc are well usable. Impressive.

3D is an experimental feature in JavaFX for Linux/ARM and not completely implemented (see https://javafx-jira.kenai.com/browse/RT-33209). However some parts should work if you enable the feature with the command-line option:
-Dcom.sun.javafx.experimental.embedded.3d=true
That worked, too. Great. Thanks a lot for your precise help!

Nota bene, since the 3DViewer demo uses a native file chooser dialogue when you want to click the load model button, it does not open something on the PI with its JavaFX's full-screen and no X11 (JavaFX doc). Adding the model's name as parameter in the console works.
Is there a way to also use a pure Java file chooser in JavaFX, like it is possible in Swing? (SwingInterop.jar didn't work, btw.)

You will probably also need to enable the depth buffer (https://javafx-jira.kenai.com/browse/RT-32386):
-Dprism.glDepthSize=24
It wasn't needed so far, for loading some medium sized Blender exported OBJ models with 3DViewer, but I'll remember this switch in case something's looking "depth-buffer-less". :-)

(And only now I see the Dukepad by Richard Blair.)

danielblaukopf
Posts: 42
Joined: Thu Dec 20, 2012 8:03 pm

Re: Accelerated 2d & 3d with JavaFX8 or ...?

Sun Feb 02, 2014 4:36 pm

Fidelius wrote:Nota bene, since the 3DViewer demo uses a native file chooser dialogue when you want to click the load model button, it does not open something on the PI with its JavaFX's full-screen and no X11 (JavaFX doc). Adding the model's name as parameter in the console works.
Is there a way to also use a pure Java file chooser in JavaFX, like it is possible in Swing? (SwingInterop.jar didn't work, btw.)
JavaFX for ARM doesn't support a desktop model of interaction. So there are a few things you don't get, such as window decorations and iconization, system clipboard, Swing integration - and file choosers. It's not that you couldn't have an all-JavaFX file chooser make sense on an embedded FX stack, it's that since this is a desktop-style feature it is not a priority for the ARM stack. The primary focus of JavaFX for ARM is not on ARM desktops but on embedded systems that don't share the screen with other applications.
The JIRA for file choosers on ARM is here: https://javafx-jira.kenai.com/browse/RT-23680 if you want to comment.

User avatar
Fidelius
Posts: 460
Joined: Wed Jan 01, 2014 8:40 pm
Location: Germany

Re: Accelerated 2D & 3D with JavaFX8 or ...?

Sat Feb 22, 2014 9:08 am

Thanks Daniel for the reply and for your and your colleagues' good work on JavaFx and on its port to the ARM devices like the Raspberry Pi.

The Java8's missing media package on the ARM devices is a pity though, because for example finally we have a simple way to play sounds (compared to the very unhandy old javax.sound.sampled package) on the bigger Java8 platforms, but not on the Pi...

Aside this, the hardware accelerated 2D & 3D Scene-graph works very well in full-screen on the Pi. It's a pleasure to see smoothly moving large nodes in Java8 on the Pi as well as on the big JVM platforms, coming from the binary identical Java Archive file (JAR). The development of platform-neutral multi-media applications has never been more straight-forward, it seems.


For those who want to see a mini-demo with JavaFx on the Pi, I made a video of a little sprite test, which I too mentioned in Grimmy's thread Programming a 2D game. Software suggestions anyone?
My intention with this is to show also to younger programmers how straightforward it is to develop own applications or even games in Java on the Pi (which then run on other platforms, too, "as a bonus"), since programming games is usually motivating the younger people a lot, when they soon see pleasing optical results of their efforts.

henrik
Posts: 65
Joined: Tue Dec 18, 2012 4:24 pm

Re: Accelerated 2D & 3D with JavaFX8 or ...?

Thu Feb 27, 2014 4:27 pm

Fidelius wrote:Thanks Daniel for the reply and for your and your colleagues' good work on JavaFx and on its port to the ARM devices like the Raspberry Pi.

The Java8's missing media package on the ARM devices is a pity though, because for example finally we have a simple way to play sounds (compared to the very unhandy old javax.sound.sampled package) on the bigger Java8 platforms, but not on the Pi...
Help us add it? JavaFX is fully open source:
https://wiki.openjdk.java.net/dashboard.action

Henrik, Oracle Java team

Return to “Java”