Hi!
I’ve decided to give this GUI-lib a try, and my initial impression is good!
I am having an issue though, and maybe someone here can explain why (I am looking at you @t0neg0d =P).
The code I’m using is copied straight from the forum documentation topic.
The first window that appears is fine, and after the framerate stabilizes I get ~1700 fps. After clicking the button and making another window appear then the framerate drops to about ~170 fps and stays there. Adding more windows after the initial drop is cheap though.
1 window, ~1700 fps
2 windows, ~170 fps
36 windows, ~120 fps
Why that big initial fps drop?
[java]
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.math.Vector2f;
import com.jme3.system.AppSettings;
import tonegod.gui.controls.buttons.ButtonAdapter;
import tonegod.gui.controls.windows.Window;
import tonegod.gui.core.Screen;
/**
- test
-
@author kwando
*/
public class Main extends SimpleApplication {
public static void main(String[] args) {
Main app = new Main();
AppSettings settings = new AppSettings(true);
settings.setResolution(1280, 720);
app.setSettings(settings);
app.setShowSettings(false);
app.start();
}
public int winCount = 0;
private Screen screen;
@Override
public void simpleInitApp() {
flyCam.setDragToRotate(true);
inputManager.setCursorVisible(true);
screen = new Screen(this, "tonegod/gui/style/def/style_map.xml");
screen.initialize();
guiNode.addControl(screen);
// Add window
Window win = new Window(screen, "win", new Vector2f(15, 15));
// create button and add to window
ButtonAdapter makeWindow = new ButtonAdapter(screen, "Btn1", new Vector2f(15, 55)) {
@Override
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
createNewWindow("New Window " + winCount);
}
};
// Add it to out initial window
win.addChild(makeWindow);
// Add window to the screen
screen.addElement(win);
//*/
}
public final void createNewWindow(String someWindowTitle) {
Window nWin = new Window(screen, “Window” + winCount, new Vector2f((screen.getWidth() / 2) - 175, (screen.getHeight() / 2) - 100));
nWin.setWindowTitle(someWindowTitle);
screen.addElement(nWin);
winCount++;
}
}
[/java]