Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (494)
Games in Android Showcase (113)
games submitted by our members
Games in WIP (562)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Struggling to get going with 3D libraries + JavaFX  (Read 722 times)
0 Members and 1 Guest are viewing this topic.
Offline brendan.hill

Junior Newbie


Exp: 1-3 months



« Posted 2014-08-19 13:08:50 »

I'm working a modelling engine which will require 100k-1m triangles in 3d space, and have decided to do as my first major Java project.

I've decided to use JavaFX for the UI, OpenGL for graphics and would prefer to work in Netbeans on Windows 7.

Options I have considered:

1) JOGL2 + JavaFX (via GLJPanel & SwingNode)

After a couple of weeks stuffing around I've failed to get JOGL2 even working in Netbeans. The version from Netbeans-OpenGL-Pack is JOGL1.1 (which lacks GLJPanel) and after following multiple sets of instructions for manually setting up JOGL2 library I still can't get the library to be recognized & run successfully. (Mostly my unfamiliarity with Java....)


2) LWJGL + JavaFX

My reading suggests that while possible, it is not optimized or a mature integration. I really don't want to waste time mucking around with experimental setups.


3) JavaFX 3d objects

The demo projects are extremely simple and I can't find anything to confirm this technology will scale up to millions of primitives.


For a poor frustrated newbie contemplating a return to the safe familiar haven of C#, can you advise:

* Is there an official solution for JavaFX + OpenGL my google-fuing has yet to reveal?

* Otherwise, which JavaFX compatible openGL library is the easiest & quickest way to get OpenGL graphics working (in Netbeans/Windows7)?

* Are there sample projects for JavaFX + OpenGL I can easily download & run successfully? (Already tried a couple which didn't work)

Sorry if I'm covering old ground here, I've been banging my head against the wall for a fortnight.

-Brendan
Offline princec

JGO Kernel


Medals: 376
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #1 - Posted 2014-08-19 13:12:46 »

No, sadly there's no optimal solution yet and it really relies on the JavaFX team providing a hook to do it properly. It would be brilliant if this happened.

Cas Smiley

Offline brendan.hill

Junior Newbie


Exp: 1-3 months



« Reply #2 - Posted 2014-08-19 23:56:34 »

Not the answer I was hoping for Sad
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline arnaud_couturier
« Reply #3 - Posted 2014-08-20 03:45:25 »

Short answer:
No, you can't.

Long answer:
The right person to contact for this is JOGL's maintainer Julien Gouesse. No doubt he will soon appear in this thread, he's very active.

You can find more details here
http://www.java-gaming.org/topics/jogl-in-javafx/26881/view.html
and here
https://jogamp.org/bugzilla/show_bug.cgi?id=607

Last time I tried to make OpenGL work in JavaFX, it was a mess. I guess not much has changed since.
And it looks like Oracle is repeating Sun's mistake to encapsulate OpenGL in a half-baked (to be polite) solution of theirs.

Better to stay with Swing (java's GUI system that JavaFX is trying to supersede) for the time being, or to move to other techs.

On a side note, I never had any problem whatsoever setting up JOGL nor LWJGL in netbeans. It should be easy.

If you come from C# and are new to java, you should perhaps be told that in the java universe, 3d is often provided by third parties (as you've found out already) and not by Oracle, unlike in the .NET world where everything evolves around Microsoft's techs, and where everything is therefore more cohesive.
Offline gouessej
« Reply #4 - Posted 2014-08-20 10:17:22 »

Hi

Some things has changed since Arnaud looked at our work, please look at my answer here:
http://www.java-gaming.org/topics/gljpanel-javafx/34103/msg/321543/view.html#msg321543

I agree with Arnaud about OpenJFX/JavaFX but now (at least since Java 1.8 update 11) the ES2 pipeline is shipped with the Oracle JRE for Windows which improves the performance especially when using JOGL.

Netbeans OpenGL pack is unmaintained (bienator abandoned it in 2011?) but our wiki explains how to use JOGL 2 in your favorite IDE:
http://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE#NetBeans_IDE

There is an example of project using Netbeans and JOGL 2 here:
https://github.com/nilshoffmann/netbeans-jogl2

I really advise you to learn how to setup your classpath which is the very minimum. Moreover, all JogAmp APIs (JOGL, JOAL, JOCL) don't require you to set the Java library path, just put the right JARs into the same directory, set your classpath and it works.

When something doesn't work, please give us much more details and anyway, if you have specific questions about any JogAmp APIs, please rather post them on our official forum so that most of your contributors and users can answer you too including those who never come here:
http://forum.jogamp.org/

princec is right, there isn't yet any equivalent of JAWT for OpenJFX/JavaFX, there are only various non public APIs subject to changes that provide some hooks which isn't currently neither mature and nor viable on the long term.

Offline brendan.hill

Junior Newbie


Exp: 1-3 months



« Reply #5 - Posted 2014-08-21 08:47:05 »

Thanks gouessej, the links you provided were helpful. I've since set up JOGL2 in netbeans, and also got a simple JavaFX 2 + JOGL2 frame using GLJPanel working:

1  
2  
3  
4  
<SwingNode id="MySwingNode"/>
...
SwingNode swingNode = (SwingNode)root.lookup("#MySwingNode");
swingNode.setContent(new GLJPanel());


The trouble I'm having now is that when I resize the window, ~30% of the time the GL redraw in GLJPanel ends up blanking out the entire window, overwriting other UI elements. They only redraw on events (hover, alt-tab etc). My google-fu suggests JavaFX does not permit a forced redraw of the other elements as a workaround. (I get the same symptoms when initializing inside SwingUtilities.invokeLater()).

1) Is this blanking out because JavaFX is using OpenGL behind the scenes?

2) Is it a symptom of an immature integration overall, which may throw up further issues as I progress?

3) Is it worth posting this on the Jogamp forum (& directing further questions there instead)?

4) What's a workaround??

I would like to use JavaFX as I love the architecture, but considering a move to Swing for the sake of avoiding these issues.

Thanks for your time & effort responding to these questions.
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 77
Projects: 15


★★★★★


« Reply #6 - Posted 2014-08-21 09:48:37 »

Another option you could consider is using one of the many GUI libraries that work inside OpenGL, some good options include TWL and LibGDX's Scene2D UI.

I know some people prefer native frameworks rather than a GUI running inside OpenGL, but in the long run you get a lot more flexibility, better integration with OpenGL and doesn't break the atmosphere of your game (probably why all AAA titles use in game GUI's).

Integrating OpenGL with GUI frameworks which and not designed for such integration (Swing, AWT, JavaFX, etc), especially if they themselves have their own OpenGL backends or hardware accelerated paths is always problematic and you'll have to jump through various hoops to get it to work properly (if at all).
Offline basil_
« Reply #7 - Posted 2014-08-21 10:43:21 »

also, going into fullscreen rendering is not going well with "outside" interfaces. "fullscreen-windowed" is ofc possible too and should be an option for PC games (imo).
Offline brendan.hill

Junior Newbie


Exp: 1-3 months



« Reply #8 - Posted 2014-08-21 12:01:40 »

Another option you could consider is using one of the many GUI libraries that work inside OpenGL, some good options include TWL and LibGDX's Scene2D UI.

I know some people prefer native frameworks rather than a GUI running inside OpenGL, but in the long run you get a lot more flexibility, better integration with OpenGL and doesn't break the atmosphere of your game (probably why all AAA titles use in game GUI's).

Integrating OpenGL with GUI frameworks which and not designed for such integration (Swing, AWT, JavaFX, etc), especially if they themselves have their own OpenGL backends or hardware accelerated paths is always problematic and you'll have to jump through various hoops to get it to work properly (if at all).

Thanks for the suggestions. I'm going to persevere with JavaFX a little longer but build on an MVC pattern allowing me to switch the UI framework if necessary.

The current problem I'm facing with JavaFX + JOGL I have posted here and will continue discussion there, FYI:

http://forum.jogamp.org/GLJPanel-in-JavaFX-blanking-out-window-td4032861.html
Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (15 views)
2014-09-12 09:08:26

Norakomi (45 views)
2014-09-10 13:57:51

TehJavaDev (57 views)
2014-09-10 06:39:09

Tekkerue (26 views)
2014-09-09 02:24:56

mitcheeb (49 views)
2014-09-08 06:06:29

BurntPizza (33 views)
2014-09-07 01:13:42

Longarmx (19 views)
2014-09-07 01:12:14

Longarmx (21 views)
2014-09-07 01:11:22

Longarmx (20 views)
2014-09-07 01:10:19

mitcheeb (30 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!