Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (715)
Games in Android Showcase (214)
games submitted by our members
Games in WIP (788)
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  
  LWJGL3FX - A sneak peek  (Read 2150 times)
0 Members and 1 Guest are viewing this topic.
Offline Spasi
« Posted 2017-01-21 01:32:14 »

This is an effort by @KaiHH and me to integrate LWJGL 3 with JavaFX.

Some of you may remember LWJGL-FX, which was a proof of concept to simply show how nice it would be to render OpenGL graphics within JavaFX. Technically it wasn't doing anything worthwhile, it was just trying to use the existing public JavaFX APIs in an efficient manner. Despite my efforts, the end-result was very inefficient in terms of both memory and CPU usage.

Some time before LWJGL 3.0.0 was released, I had written a Prism backend (the part of JavaFX that does the actual rendering) using LWJGL 3. It worked, but other stuff got in the way and I never had time to do anything with it. A few days ago I recruited KaiHH to help me do it right this time. The old code was ported to the latest LWJGL releases and we figured out a good approach for the integration. This is the first result.

The images below are screenshots of this JavaFX sample, modified so that the classic Gears OpenGL demo is rendered behind the main content. The drop shadow effect is enabled on the JavaFX image. The window is maximized in a 1920x1200 monitor. Minus the menu and taskbar, the OpenGL view is slightly larger than 1080p. The background color animates, that's why it isn't the same in all screenshots. Open the images in a new-tab for the full size.

V-sync enabled, 60 fps, 3.9% CPU



The following were launched with -Djavafx.animation.fullspeed=true. Despite the name, there's a hard cap at 1000Hz for the animation pulses. This means that there's a fixed overhead of 1ms and we cannot go lower than that (i.e. cannot go higher than 1000fps).

V-sync disabled, 1.0 + 0.41ms per frame



V-sync disabled, HUD disabled, 1.0 + 0.01ms per frame

Online princec

« JGO Spiffy Duke »


Medals: 899
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #1 - Posted 2017-01-31 10:40:01 »

Hey guys... what is the actual status of this then?

Cas Smiley

Offline Spasi
« Reply #2 - Posted 2017-01-31 14:56:07 »

We have decided to prioritize the Android/ARM builds over this. Other than limited time, this project has several difficulties:

- Needs quite a bit of work to be production ready.
- We're not sure if it's worth doing lots of unpaid work for something that Oracle ought to support out of the box and if there will actually be people that want to use an unofficial backend.
- We're not sure about licensing issues and if Oracle is going to come after us. Which is why the code isn't public yet.

Anyway, current status:

It's still at a proof-of-concept stage but works very well. As you could probably tell by the measurements above, it's a pure GPU solution with no CPU copies. In fact, there are not even GPU copies, other than the compositing JavaFX does anyway. We render directly to the texture backing the GL viewport, without disrupting JavaFX's context state. Issues and pending work:

- It currently works on Windows and Linux. We must add support for CGL and EGL + real OpenGL ES. The plan is to add a cross-platform API for GL context management to lwjgl3. What ContextAttribs did in lwjgl2, but probably closer to GLFW's hint-based API and implementation.
- We'll need some kind of API that configures the FBO associated with the GL viewport.
- Overriding the default Prism implementation requires the backend code to be loaded via -Djava.ext.dirs. Won't be friendly to novice users.
- Prism is not documented and does not have a stable API. This means that new JDK versions will likely break our implementation. We'll need multiple versions and have maintenance overhead. The current implementation is compatible with JavaFX 8 only. Java 9 has also dropped -Djava.ext.dirs, we'll probably need module workarounds to run there.
- Long-term: Prism looks like it's been hacked until it worked. It's really quite a bad code base to work in. We'd really like to do a cleanup where possible. Being able to do everything in Java will help a lot.
- Longer-term: It'd be fun to add a Vulkan backend for improved performance.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline basil_

« JGO Bitwise Duke »


Medals: 413
Exp: 13 years



« Reply #3 - Posted 2017-01-31 19:07:41 »

@cas : did you go with jawt plus swing/javafx yet ?
Online princec

« JGO Spiffy Duke »


Medals: 899
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #4 - Posted 2017-01-31 22:00:19 »

The one time I've used it was LWJGL3+JavaFX using the dreaded buffer blitting. Performance was barely acceptable for the thing I needed Sad

Has anyone heard/seen of the Marlin renderer?

Cas Smiley

Offline Archive
« Reply #5 - Posted 2017-01-31 22:06:19 »

Has anyone heard/seen of the Marlin renderer?
Yeah I've heard of the Marlin renderer.

Online princec

« JGO Spiffy Duke »


Medals: 899
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #6 - Posted 2017-01-31 22:15:15 »

Wonder if it's any easier to integrate than Pisces?

Cas Smiley

Offline Spasi
« Reply #7 - Posted 2017-03-11 08:36:56 »

There's now an alternative implementation available, JFXGL. It was created by Jeff Martin. Compared to ours:

Pros

- It uses GLFW for context management and as the windowing system.
- You have full control of the render loop (the fixed 1ms per frame overhead mentioned above does not apply).
- Doesn't have the -Djava.ext.dirs issue.
- You can use it right now.

Cons

- It handles JavaFX graphics only, other features are not supported (pickers, popups, etc.).

We've shared our code with Jeff and his code is obviously also available, so both approaches will likely improve soon.
Pages: [1]
  ignore  |  Print  
 
 

 
CopyableCougar4 (214 views)
2017-03-24 15:39:42

theagentd (196 views)
2017-03-24 15:32:08

Rule (255 views)
2017-03-19 12:43:22

Rule (237 views)
2017-03-19 12:42:17

Rule (242 views)
2017-03-19 12:36:21

theagentd (261 views)
2017-03-16 05:07:07

theagentd (257 views)
2017-03-15 22:37:06

theagentd (186 views)
2017-03-15 22:32:18

theagentd (180 views)
2017-03-15 22:31:11

ral0r2 (166 views)
2017-03-03 11:52:41
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!