jME3 Application Display Settings

Every class that extends jme3.app.SimpleApplication has properties that can be configured by customizing a com.jme3.system.AppSettings object. Configure the settings before you call app.start() on the application object. If you change display settings during runtime, call app.restart() to make them take effect.

Note: Other runtime settings are covered in SimpleApplication.

Code Sample

public static void main(String[] args) {
  AppSettings settings = new AppSettings(true);
  settings.setResolution(640,480);
  ... // other properties see below
 
  MyGame app = new MyGame(); // or Main or whatever you called your SimpleApplication
  app.setSettings(settings);
  app.start();
}

Set the boolean in the AppSettings contructor to true if you want to keep the default settings for everything that you do not specify. Set this parameter to false if you want to change some of the settings, but otherwise want the application to load user settings from previous launches.

Use app.setShowSettings(true); to present the user with a splashscreen and display settings dialog when starting the game, or app.setShowSettings(false); to hide the custom splashscreen. Set this boolean before calling app.start() on the SimpleApplication.

Properties

Settings Property (Video)DescriptionDefault
setRenderer(AppSettings.LWJGL_OPENGL2)
setRenderer(AppSettings.LWJGL_OPENGL3)
Switch Video RendererOpenGL 2
setBitsPerPixel(8)Set color depth.
1 = black and white, 2 bit = gray,
4 = 16 colors, 8 = 256 colors, 24 or 32 = "truecolor".
24
setFrequency(60)The screen frequency (refresh rate of the graphics card), usually 60 or 75 fps.60 fps
setFramerate(60)How often per second the engine should try to refresh the frame. For the release, usually 60 fps. Can be lower (59-30) for FX-intensive games. No use setting it to a higher value than the screen frequency. If the framerate goes below 30 fps, viewers start to notice choppiness or flickering.-1 (auto)
setFullscreen(true)Set this to true to make the game window fill the whole screen; you need to provide a key that calls app.stop() to exit the fullscreen view gracefully (default: escape).
Set this to false to play the game in a normal window of its own.
False (windowed)
setHeight(480), setWidth(640)
setResolution(640,480)
Two equivalent ways of setting the display resolution.640x480 pixels
setSamples(4)Set multisampling to 0 to switch antialiasing off (harder edges, faster.)
Set multisampling to 2 or 4 to activate antialising (softer edges, may be slower.)
Depending on your graphic card, you may be able to set multisampling to higher values such as 8, 16, or 32 samples.
0
setVSync(true)Set vertical syncing to true to time the frame buffer to coincide with the refresh interval of the screen: Prevents page tearing, but slower; recommened for release.
Set to false to deactivate vertical syncing (faster, but possible page tearing artifacts); can be deactivated during development.
false
Settings Property (Input)DescriptionDefault
setUseInput(false)Respond to user input by mouse and keyboard. Can be deactivated for use cases where you only display a 3D scene on the canvas without any interaction.true
setUseJoysticks(true)Activate optional joystick supportfalse
Settings Property (Audio)DescriptionDefault
setAudioRenderer(AppSettings.LWJGL_OPENAL)
setAudioRenderer(AppSettings.LWJGL_JOAL)
Switch Audio RendererOpenAL
setStereo3D(true)Enable 3D stereo. This feature requires hardware support from the GPU driver. See .false
Settings Property (Branding)DescriptionDefault
setTitle("My Game")This string will be visible in the titlebar, unless the window is fullscreen."jMonkey Engine 3.0"
setIcons(new BufferedImage[]{
ImageIO.read(new File("")), …});
This specifies the little application icon in the titlebar of the application. You should specify the icon in various sizes (256,128,32,16) to look good on each OS. Note: This is not the application icon on the desktop.null
setSettingsDialogImage("/path/to/splash.png")A custom splashscreen image in the assets directory which is displayed when the settings dialog is shown."/com/jme3/app/Monkey.png"

Saving and Loading Settings

An AppSettings object also supports the following methods:

Usage:

Provide the unique name of your jME3 application as the String argument. For example com.foo.MyCoolGame3.

    try { settings.save("com.foo.MyCoolGame3"); } 
    catch (BackingStoreException ex) { /** could not save settings */ }

view online version