Sunday, August 16, 2009

JavaFX with JOGL



JavaFX carries one big advantage over other technologies: it can have full access to OpenGL. It may take a couple of seconds longer to load, but instead of minimal games you have the opportunity to play modern, fully accelerated 3D games.

Moreover, JavaFX makes it easier to develop these games. You can fully utilize JavaFX widgets and effects on top of your 3D world view.

Soon we will be able to see many games running full 3D, right inside our browsers. Here is a proof of concept demo. Of course you are required to have 3D drivers installed to run it. Also requires Java version 1.6u15 or higher.

run applet

Perhaps the most interesting part of this applet is that the JOGL Gears demo can be embedded in JavaFX without any modifications. The changes were made only to introduce new functionality (pause gears, change the speed, and read fps counter).
In general, minimum to no changes are required to embed JOGL games in JavaFX.

7 comments:

  1. ER...So how did it go? I'm looking into trying to mix Scala with 3D too so I'm wondering how your experiments went.

    Barry

    ReplyDelete
  2. Well, this experiment was pure Java. Currently I'm working on two ways to mix scala and 3d: jMonekeyEngine, which is Java, should mix well with scala and I'm writing a math library for scala.
    Stay tuned :)

    ReplyDelete
  3. Hi, this is a quite impressive demo. I am learning opengl and jogl at the moment to achieve 3d applets but have little experiance with javafx yet. Could you maybe post the javafx-code that is embedding the gearsdemo? Would be a real help!!! Thanks. I'm curious on the development here. Keep it Up ;)

    ReplyDelete
  4. to Lex: Thanks for the great idea of mixing javafx+opengl!

    to Tom (and anybody interested): I created a small project in Netbeans mixing javafx+opengl. It is very silly compared to what Lex did, but I placed the source code here:

    http://drop.io/9he7cax/asset/javafxapplication1-zip

    so you can see it and get the "initial base" of how to mix javafx+openl. Basically you need to create a GLJPanel and then use SwingComponent.wrap to put it inside a javafx application.

    Just look (and run) the file PruebaSwing_2.fx

    Taksan
    ( taksantong@yahoo.com )

    ReplyDelete
  5. Thanks for the code samples, Taksan. I have posted the source as well. I wanted to do a full tutorial, but code highlighting on blogger is lacking and I am too busy to be messing with css to get it working.

    ReplyDelete
  6. Hi!

    I see the GUI but I don't see the gears. I'm using the JDK 1.6 update 21. My First Person Shooter that uses JOGL 1.1.1a works fine on my machine so I think the problem comes from JavaFX. Best regards.

    ReplyDelete
  7. @gouessej
    That is entirely possible.

    I feel like JavaFX has become a victim of Sun's buyout by Oracle. Add the Oracle's lawsuit against Android to the equation and I can no longer recommend the proprietary JavaFX stack.
    It has been a very interesting technology to play with, but it's time to move on.

    ReplyDelete