Hi, I just wanted to share my experiences on this topic:
Short version: on Mac OS X it can be done, although hacky.
At work we use JavaFX 2 on MacOSX for an editor / content management system with some fancy 3D graphic
We needed to integrate an existing 3D engine (standalone app) and used IOSurface to show the result in JavaFX.
On Mac OS X it’s rather simple to write a custom node an overwrite the _impl_createNGNode (or something).
Until 2.2 you even got a graphics object in the render call that can be cast into a jogl GL interface to access OpenGL directly.
You needed to take care about setting / saving some render states but it works pretty nice. After one beta update in 2.2 the
GLESPipeline changed and did not allow full access to OpenGL
functionality anymore. But you can still simple call opengl commands since the NGNode.render() function is called in the OpenGL render
We had to use a outdated openGL java binding because unfortunatly neither JOGL nor LWJGL could be used (JOGL needs some
kind of window handle even though you just want to call some openGL commands, and LWJGL crashes because some static
initializer starts up AWT with makes JavaFX2 crash). But it still works very nice.
I suppose we will have to patch our hacky solution when the internal structure changes. Ideally they would implement a
factory pattern that creates the NGRender nodes corresponding to the ui data models.
There are also hints in the class files that an JavaFX 2 OpenGL implementation for Windows already exists, some strings starting
with WGLXXX, compared to the mac implementation starting with CGLXXX. But those files aren’t released. I’ve fiddled
a bit with an own “class GLPipeline extends GraphicsPipeline” for windows, and think it can be done with about 10 classes,
but I’m not sure about legal implications till it’s open sourced.
IMO it’s very important that JavaFX 2 will allow low level access to 3D hardware. Many cool effects like complex
3D objects, raytracing, screen space ambient occlusion, shadow mapping, particles etc are only possible with
direct access to hardware.
I really hope that JavaFX 2 will indeed become open source. If they release the prism part it wouldn’t be
much trouble to add an optional OpenGL pipeline for Windows. This would allow writing platform independent OpenGL
Instead of the Canvas node, they should add a “OpenGL” node where you pass an “RenderNode” interface where
you can call openGL commands, with a predefined render state. A kind of “use at your own risk” node would be fine
with me =)
Another good feature for JavaFX 2 would be a “SharedSurface” node via DirectX shared surface / mac os x IOSurface,
so you can integrate framebuffers from other processes. This would help integrate any existing rendering solution.