Skip to content

Window and rendering

The Saxion Game App allows you to control the game window and rendering settings on desktop platforms. This includes fullscreen/windowed mode, resizing, window title, FPS, and VSync.

⚠️ Note: These methods only work on desktop platforms. They will throw an exception if used on mobile or web platforms.

Starting the application

To launch your game, use GameApp.start():

GameApp.start(
    "My Game",   // Window title
    800,         // Width of the window
    600,         // Height of the window
    60,          // FPS
    false,       // Fullscreen
    "MainMenu"   // First screen to show
);

Quitting the application

You can programmatically exit the game application by calling:

GameApp.quit();

This signals LibGDX to terminate the application and close the game window. Use this method when you want to close the game, for example when the player selects an “Exit” option from a menu.

Window size

Gives you the exact size of the current window.

int width = GameApp.getWindowWidth();
int height = GameApp.getWindowHeight();

Current FPS

int fps = GameApp.getFramesPerSecond();

Switching to fullscreen

You can switch the game window to fullscreen using the current display mode:

GameApp.switchToFullscreen();

This will make the game fill the entire screen.

Switching to windowed mode

To switch back to a window with a specific size:

GameApp.switchToWindowedMode(800, 600);

Here 800 and 600 are the width and height of the window in pixels.

Enable or disable Resizing

You can allow or prevent the user from resizing the game window:

GameApp.setResizable(true); // allow resizing
GameApp.setResizable(false); // prevent resizing

Changing the window title

You can dynamically change the title of the game window:

GameApp.setTitle("My New Game Title");

Check if fullscreen

You can check whether the game is currently in fullscreen mode:

boolean fullscreen = GameApp.isFullscreen();

Returns true if fullscreen, otherwise false.

Setting the target FPS

You can control how many frames per second the game tries to render:

GameApp.setFPS(60);

This is useful for controlling the speed of the game loop and reducing CPU/GPU usage. The value must be greater than 0.

Enabling or disabling VSync

VSync synchronizes the frame rate with the monitor's refresh rate to prevent screen tearing:

GameApp.setVSync(true);  // enable VSync
GameApp.setVSync(false); // disable VSync