AppSettings do not apply to applets

Appsettings such as limiting the fps don’t have any effect in applets.
AppSettings settings=new AppSettings(true);
settings.setResolution(1280, 720);
settings.setFrameRate(100);
TerrainGridTest app = new TerrainGridTest();
app.setShowSettings(false);
app.setSettings(settings);
app.start();[/java]
works fine running the exe file and from the ide, but not from an applet, any ideas?

It seems that at school the fps is capped but at home it isnt…
It may be because the card isnt very powerful (though I doubt it).
anyone else care to share their results? fps uncapped or about 100?
http://gamershut.net/Applets/Racer/

I tried it and the resolution looks good but the frame rate is not capped indeed, i have around 1700

@nehon said: I tried it and the resolution looks good but the frame rate is not capped indeed, i have around 1700
The Applet only takes arguments from the html page / applet context. This should be changed at some point but I think only Momoko_Fan knows about how this really works.
@normen said: The Applet only takes arguments from the html page / applet context. This should be changed at some point but I think only Momoko_Fan knows about how this really works.

Just wanted to shed some light on this as I recently concluded why the FPS is speeding in applets which
even resulted in wrong character speed (very strange) despite all debugging concluded the walkDirection v3f was correct.

Yes, the applet only takes “java”-arguments, which means you need to define those in the HTML file for example if you wish to use specific memory or GC settings,
however its not related to the AppSettings or capping the FPS.

The regular way of launching a JME, or any for that matter, application is by using the main(String[] args) method, and
per following the documentation and tutorials for JME that is where the appSettings are changed.

This is a valid approach for application-wise execution, however it is not doing anything for applets considering we’re not launching the
JME application using main() in this case.

In order to apply a cap to framerate (and other appSettings) you are required to set the appSettings elswhere and performing a context restart,
by calling application.restart().

The simplest way of doing this is by checking whether or not we’re running as applet and then do your actions in the initiation as seen below.
Notable is that you in both cases need to ensure that the appsettings are changed before applying them, so if you previously was altering
them in the main() method, you also need to do this for the applet.

Note: I’m uncertain if VSync is required for applet to cap it, but users at LWJGL forums mentioned it as a good strategy to ensure it.

[java]
public class GameClient extends SimpleApplication implements Settings {

...
...
...

private boolean isApplet = false;

public static void initAppSettings() {
	// Create instance
	appSettings = new AppSettings(true);

	// Monitor device
	device = GraphicsEnvironment.getLocalGraphicsEnvironment()
			.getDefaultScreenDevice();

	// Title
	appSettings.setTitle(GameGlobals.NAME + " Client v."
			+ GameGlobals.CLIENT_VERSION + "."
			+ GameGlobals.CLIENT_SUBVERSION);

	// Resolution
	appSettings.setResolution(RESOLUTION_W, RESOLUTION_H);

	// Full screen
	appSettings.setFullscreen(FULL_SCREEN);

	// FPS Cap
	appSettings.setFrameRate(GameGlobals.SCENE_FPS);

	// Multisampling
	appSettings.setSamples(SAMPLING);

	// Vertical Synch
	appSettings.setVSync(VSYNC);
	appSettings.setFrequency(device.getDisplayModes()[0].getRefreshRate());

	// Renderer
	appSettings.setRenderer(AppSettings.LWJGL_OPENGL2);
}

// This is application execution
public static void main(final String[] args) {
	instance = new GameClient();
	initAppSettings();
	instance.setSettings(appSettings);
	instance.setShowSettings(false);
	instance.start();
}

@Override
public void restart() {
	super.restart();
	System.out.println("Context restarted with new settings");
}

@Override
public void simpleInitApp() {
	final Applet a = AppletHarness.getApplet(this);
	if (!(isApplet = a != null)) {
		System.out.println("Running as application");
		assetManager.registerLocator("assets", FileLocator.class);
	} else {
		System.out.println("Running as applet");
		initAppSettings();
		setSettings(appSettings);
		restart();
	}

	...
	...
	...

}

}
[/java]

Further more I suppose it would be good to find this information in the documentation for future reference.

3 Likes
@perfecticus said: Further more I suppose it would be good to find this information in the documentation for future reference.
Thank you for this!