Originally written for the Lemur GUI framework by @pspeed - this is a straight rip to work for the JavaFx framework.
The propertyPanel is a JavaFx GridPane that automatically adds properties or fields from a class and binds them to a control. Changes made to the controls are set on the fields automatically.
So if you bind a float you get a slider. If you change the slider the float will also be changed.
Also, one of these days I want to pick your brain on what performance you are seeing. I am seeing noticeable drops in my fps when I have JavaFX running inside JME3. (JavaFX 11, JDK11)
I mean there’s frame drop, but I don’t really notice it. What’s more noticeable is that they aren’t synced. They run on separate timelines. I guess it depends on how you set it up. I spent the first day I used jfx on a clean integration.
Yes, I have cleaned up the integration I am using. There were a couple bugs that needed fixed. I am seeing framerate drops that are very significant, in the range of 80 to 90%. I can only get 150 fps on a RTX Titan with an empty scene right now.
I get the same frame rate as I normally would when the GUI is static. From what I have seen in the code the gui is only updated when it’s being interacted with or animating - i.e. updating. I use the @javasabr implementation in an appstate.
I am using the same setup. I have made a couple changed to @javasabr’s implementation to fix some bugs in JavaFX 11, but nothing that effects how it is drawn or updated. I also have an issue when I show a new UI, the old one appears for a second. I will build a test case to look into this further.
Thinking about it, maybe on the line below in your implementation you limit the update cycle to 60fps or something lower than max fps. The thinking here is that for one javafx operates at 60fps anyway and secondly not so much garbage is being generated needlessly for no gain. It might be the GC slowing the cycle down. It’s worth a shot.
float limit = 1.0f / 60;
float time = 0;
@override
public void update(float tpf) {
time += tpf;
if (time < limit) {
return;
}
time = 0;
if (container.isNeedWriteToJme()) {
container.writeToJme();
}
}