This discussion is archived
8 Replies Latest reply: Jul 6, 2012 8:41 AM by KonradZuse RSS

Can Open GL and FX be used together?  Is one better?  Which should I use?

KonradZuse Explorer
Currently Being Moderated
I am curious if this is possible. I am using Swing and Open GL but it seems like Java FX is the future and apparently development on swing stopped?

If they cannot be used together(I wonder why not...) which would be better in development of games/applications with 3D capabilities... It seems Open GL would be more used for games(Depending on the depth of the game World of Warcraft vs a Scrabble game...), while Java FX would be for Internet and Desktop applications?

Any information would be appreciated, thanks,

~KZ

Edited by: KonradZuse on Jul 3, 2012 10:28 AM
  • 1. Re: Can Open GL and Java FX be used together?
    805536 Journeyer
    Currently Being Moderated
    apparently development on swing stopped? 
    Yes, further development on Swing is now limited to bug fixes.
    If they cannot be used together(I wonder why not...)
    which would be better in development of games/applications
    with 3D capabilities...
    I believe there was a hack available in the past, but I doubt it works now what with the new windowing system and all. JavaFX is built over OpenGL (when DirectX is not available), but you cannot directly use OpenGL in conjunction with JavaFX. The reason for this is that JavaFX is very high level and does not currently provide any efficient mechanisms for a separate graphics system to link to it. Perhaps such a feature will be added in the future, but I would avoid depending on it.
    It seems Open GL would be more used for games
    (Depending on the depth of the game World of Warcraft
    vs a Scrabble game...), while Java FX would be
    for Internet and Desktop applications?
    I am having trouble understanding this one. How do games not fit into the internet and desktop categories?

    Anyways, the big difference between JOGL and JavaFX is that JOGL is low level and JavaFX is high level. Otherwise, they are difficult to compare. Thus, you might prefer JOGL if you need something specialized and custom fit to your needs. But since JavaFX is meant to be general purpose, I see no reason it couldn't be used for writing games, even if some of the high level features like properties might waste memory when you don't need them.
  • 2. Re: Can Open GL and Java FX be used together?
    KonradZuse Explorer
    Currently Being Moderated
    Thanks for this.

    I guess what I really want to know is should I be using Java FX vs Open GL in terms of 3D graphics only, and nothing really hardcore. Open GL has a lot of crazy graphical features like shaders and such that I do not need, and I'm not sure if FX has any of the super fancy stuff. All I really need to do is create some 3D rectangles and maybe some other shapes and that's about it. Nothing super crazy. I want to know if FX is the better way to go because honestly JOGL and LWJGL are decently supported, but it seems not as much as some would like(especially JOGL).

    Would it be better to stick to the Java code presented with FX, than trying to learn all the new GL commands that I most likely will never need?

    Also I hear that FX has a really good graphics engine, does one present better graphics than the other, or it's basically the same thing, but like I said before that Open GL might have more stuff built in?

    FX is much newer than Open GL, but it seems to be very powerful, and yes FX higher level, but does that mean it's not as good?

    Thanks for any help,

    ~KZ :)
  • 3. Re: Can Open GL and Java FX be used together?
    gimbal2 Guru
    Currently Being Moderated
    JavaFX has different uses and right now is not built to do the things you would do with a low level 3D API like OpenGL.

    I suggest you look into LibGDX in stead, which even allows you to deploy to Android.
  • 4. Re: Can Open GL and Java FX be used together?
    805536 Journeyer
    Currently Being Moderated
    >
    Also I hear that FX has a really good graphics engine, does one present better graphics than the other, or it's basically the same thing, but like I said before that Open GL might have more stuff built in?
    ...
    FX is much newer than Open GL, but it seems to be very powerful, and yes FX higher level, but does that mean it's not as good?
    >
    High level is much quicker to write and easier to use, but less flexible (you won't be able to do some things, performance might not be optimized for certain use cases, etc). Low level is more flexible so you can do more with it, but takes a lot more bootstrapping (a lot of stuff isn't already written for you so you have to write it for yourself). That's pretty much the main difference between the two. Pick your poison.

    If all you want is Rectangles and other 2D shapes in 3D space, JavaFX will work fine as long as you are running it on supported graphics cards (http://docs.oracle.com/javafx/2/system_requirements_2-1-1/jfxpub-system_requirements_2-1-1.htm).

    Of course, JavaFX's 3D features are still limited and won't be expanded until version 3.0 comes out, so you won't be able to use 3D shapes (short of constructing them from 2D shapes) for another year or so.
  • 5. Re: Can Open GL and Java FX be used together?
    KonradZuse Explorer
    Currently Being Moderated
    Thanks for the reply both of you :).

    I'm not trying to do too much craziness, just 3D shapes and rotations, clicking on the shapes to do events, etc... Not trying to create a game, using it for a business application. I'm not sure when exactly I will be implementing it, that's the last thing to basically do for this program, so if it's a year it might be worth it...

    So how exactly is it 2d shapes in 3d space? It seems like there are already 3d shapes, or is it how you said it? what exactly would the difference be? I'm speaking of the demo's from the "Ensemble" that I saw, it says 3d, and the shapes are, but maybe I'm missing something?

    Also it seems like for a business application it might not be that good to have a limited GFX market.... IF it only supports the latest cards and such it might be a huge problem for those who aren't up to date....

    Maybe I will end up doing both and having the user decide what to use(I've seen games run both Open GL and Direct X by switching back and forth), but who knows what I will do when the time comes....
  • 6. Re: Can Open GL and Java FX be used together?
    805536 Journeyer
    Currently Being Moderated
    >
    So how exactly is it 2d shapes in 3d space? It seems like there are already 3d shapes, or is it how you said it? what exactly would the difference be? I'm speaking of the demo's from the "Ensemble" that I saw, it says 3d, and the shapes are, but maybe I'm missing something?
    >
    You can put a Rectangle in a JavaFX scene. The Rectangle itself would be 2D, but you can move it around in a 3D space, like a playing card in the real world. You can technically build a cube in JavaFX, but there is no cube class. You would have to assemble 6 rectangles into a cube shape and manipulate them appropriately. You could similarly assemble a sphere from a large number of triangles, but that would be innefficient. And there definetly aren't any 3D model loaders, so you wouldn't be able to import a 3DS model drawn in Blender, Maya, or Autodesk.

    >
    Also it seems like for a business application it might not be that good to have a limited GFX market.... IF it only supports the latest cards and such it might be a huge problem for those who aren't up to date....
    >
    JavaFX can run 2D graphics on any computer that supports Java 2D. As to 3D graphics, it would seem that there is no guarantee. Some features are not supported on some platforms: http://docs.oracle.com/javafx/2/api/javafx/application/Platform.html#isSupported%28javafx.application.ConditionalFeature%29

    JavaFX's 3D features are reliant on hardware acceleration, which in turn is built over OpenGL and DirectX. As such, I would expect it to work on any graphics card that supports them (which would be most). That page I linked merely includes all the drivers JavaFX was tested on, not necessarily all of them. But bear in mind that I am NOT clear on the details at all. Only an Oracle employee would be able to adequetly answer this question.
  • 7. Re: Can Open GL and Java FX be used together?
    jsmith Guru
    Currently Being Moderated
    And there definetly aren't any 3D model loaders, so you wouldn't be able to import a 3DS model drawn in Blender . . . if it only supports the latest cards and such it might be a huge problem for those who aren't up to date
    I ported a simple JavaScript Blender model loader and HTML5 canvas renderer to Java to software render the models into a JavaFX canvas - pretty limited in functionality and not all that performant, but perhaps useful for some use cases. For me it was just a fun tech demo thing.
  • 8. Re: Can Open GL and Java FX be used together?
    KonradZuse Explorer
    Currently Being Moderated
    To me it actually looks like a 3D model in a 2D space from the ensemble pack... They would move around, but only using x,y...


    IT seems like JavaFX still has a ways to go, I figured it could do a lot of cool things, but I guess 3D is still lacking... Will FX 3.0 pick up the slack in this completely, or do we have to wait even longer?


    So I guess for now I will have to stick with JavaSE and see how that goes, and eventually go with EE when I do Client-Server(At least that's what I think EE's advantage over SE is). But if I cannot use Open GL with FX then there isn't much point to using FX, which is sad since it seems like the GUI is much better and all that jazz...

    Edited by: KonradZuse on Jul 6, 2012 8:40 AM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points