4 Replies Latest reply on May 14, 2013 8:40 PM by 1008054

    JavaFX 2.2: Enable OpenGL on Windows

    1008054
      Hi,

      I have an application that was built on swing and opengl using jogl. I am starting V2 and I want to include JavaFX for the many benefits it provides. My main problem is this:

      I Cannot force OpenGL on Windows! it's always Direct3d. I googled everything, it doesn't seem to be possible without hacking my way into a custom jre which seems like an incredibly unstable/bad idea to me.

      I tried to force GPU and get the OpenGL context like this:

      -Dprism.forceGPU -Dprism.order=es2,j2d

      I even copied the jfxrt from the mac distribution to get the missing java/classes and I even downloaded the prism-es2.dll library, and the logs show me this:

      Is there a way? Can I get the WinGLFactory and relative classes from somewhere?

      Thanks,

      Beess

      Log

      Prism pipeline init order: es2 j2d
      Using t2k for text rasterization
      Using dirty region optimizations
      Prism pipeline name = com.sun.prism.es2.ES2Pipeline
      Loading ES2 native library ... prism-es2
           succeeded.
      GLFactory using com.sun.prism.es2.gl.win.WinGLFactory
      Prism pipeline name = com.sun.prism.j2d.J2DPipeline
      (X) Got class = class com.sun.prism.j2d.J2DPipeline
      Initialized prism pipeline: com.sun.prism.j2d.J2DPipeline
      GLFactory.static - Platform: Windows 7 - not available: com.sun.prism.es2.gl.win.WinGLFactory
      java.lang.ClassNotFoundException: com.sun.prism.es2.gl.win.WinGLFactory
           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:423)
           at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
           at java.lang.Class.forName0(Native Method)
           at java.lang.Class.forName(Class.java:188)
           at com.sun.prism.es2.gl.GLFactory$1.run(GLFactory.java:70)
           at com.sun.prism.es2.gl.GLFactory$1.run(GLFactory.java:64)
           at java.security.AccessController.doPrivileged(Native Method)
           at com.sun.prism.es2.gl.GLFactory.<clinit>(GLFactory.java:64)
           at com.sun.prism.es2.ES2Pipeline.<clinit>(ES2Pipeline.java:60)
           at java.lang.Class.forName0(Native Method)
           at java.lang.Class.forName(Class.java:188)
           at com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:150)
           at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:73)
           at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:97)
           at java.lang.Thread.run(Thread.java:722)
      GraphicsPipeline.createPipeline failed for com.sun.prism.es2.ES2Pipeline
      java.lang.ExceptionInInitializerError
           at java.lang.Class.forName0(Native Method)
           at java.lang.Class.forName(Class.java:188)
           at com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:150)
           at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:73)
           at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:97)
           at java.lang.Thread.run(Thread.java:722)
      Caused by: java.lang.RuntimeException: No native platform GLFactory available.
           at com.sun.prism.es2.gl.GLFactory.getFactory(GLFactory.java:91)
        • 1. Re: JavaFX 2.2: Enable OpenGL on Windows
          Artem Ananiev-Oracle
          ES2 Prism pipeline is not shipped with JavaFX. Just check your Windows version of jfxrt.jar and observe there is no com.sun.prism.es2 package there. However, the code is open sourced, see openjfx/rt/prism-es2-win for details, so it can be built and used. You'll also need to modify Prism build scripts to not strip prism-es2.dll and com.sun.prism.es2 on Windows, though.
          • 2. Re: JavaFX 2.2: Enable OpenGL on Windows
            1008054
            Hi,

            The question remains, If i do this "custom build", What guarantees do I have that oracle won't blackbox the prism api completely in a few months, therefore rendering my "Solution" superfluous...

            And the only reason I asked about prism-es is because I assume that's the only way to get opengl on windows, is there any other way? because es is meant for embedded-systems, I am on desktop and I would like to use the full power of my opengl drivers...

            Best,

            Beess
            • 3. Re: JavaFX 2.2: Enable OpenGL on Windows
              jsmith
              I very much doubt you will get an Oracle supported opengl pipeline in the JavaFX 8.0 timeframe - perhaps subsequently, if you make a request - not even sure where you would make such a request (perhaps https://javafx-jira.kenai.com or you could sound out the idea and request some info on openfx-dev).

              http://mail.openjdk.java.net/mailman/listinfo/openjfx-dev

              Take a look at:
              https://bitbucket.org/dejayberlin/joglfxpipeline/src (Experimental JOGL Pipeline for JavaFX 8)

              That project does not solve all your issues or concerns either, but may be of interest to you.

              The JavaFX team leader stated: http://mail.openjdk.java.net/pipermail/openjfx-dev/2013-May/007451.html
              One thing I want to see done (for example) for the 8 update is to have an OpenGLNode or NativeSurfaceNode or something along those lines so that if you are doing your own D3D / OpenGL you can have a way to send those raw commands down to the graphics card but still have your node composited in the scene graph.
              So perhaps if the stars align, you will get the feature you are interested in for an update.
              Also, the JavaFX team would likely be happy to accept contributions to allow this to happen.

              One thought is that for a standard JavaFX runtime distribution, it doesn't make a lot of sense to ship both an OpenGL and DirectX back end which accomplish pretty much the same thing, so what you are requesting might always need to be done via a custom openjfx build (at least until Java itself can be properly modularized in Java 9).
              What guarantees do I have that oracle won't blackbox the prism api completely in a few months
              I think that is blackboxing is pretty unlikely - prism is a fundamental component of the JavaFX architecture and Oracle seems completely committed to JavaFX.
              http://docs.oracle.com/javafx/2/architecture/jfxpub-architecture.htm
              Prism does not have a public API though, so you need to code to private API if you want to make use of it directly and that private API can change between releases - building off of public APIs is always a preferred solution when you can.
              And the only reason I asked about prism-es is because I assume that's the only way to get opengl on windows, is there any other way? because es is meant for embedded-systems, I am on desktop and I would like to use the full power of my opengl drivers...
              I'm not really sure what you expect here:

              Do you just want JavaFX to run utilizing OpenGL for it's internal back end rendering rather than JavaFX?
              If es is sufficient for that task, then it probably doesn't matter that the back end rendering is not using the full power of the opengl drivers.

              Do you want to write your own OpenGL code and have that rendered in a custom node composited in a JavaFX scene?
              If that's the case, a simple JavaFX rendering pipeline switch won't be sufficient to accomplish what you want, because you still have to have a node in JavaFX capable of accepting raw OpenGL drawing instructions - and such a node isn't in the current JavaFX releases.

              Anyway, I think you will receive your best answers to these kind of questions from the openjfx-dev mailing list rather than from forum posts.
              • 4. Re: JavaFX 2.2: Enable OpenGL on Windows
                1008054
                Thank you jsmith for taking the time to write a detailed response.

                It's pretty much what I expected. I hate taking a risk in coding against private api, as they might change and break my solution.

                I did come across the deejay (jogl/javafx) hybrid port, but like I said, it seemed risky/experimental.

                In the end, I ended up keeping a swing panel with Jogl 2 as it leverages the power of opengl completely to me with java easily. I will use Javafx for UI and components.

                It's a shame though that Oracle would limit the backend implementation on windows to Direct3d, knowing that a lot of applications/games are built on the cross-platform opengl.

                It would have been very useful to ship javafx with 2 prism implementation for windows (direct3d,opengl) and allow the clients to choose which implementation based on their needs. ( They are allowing it for Mac already so it should be easy to do for windows).

                Based on this issue alone, I almost decided NOT to use JavaFX, which is a big shame.

                Best,

                Beess