How to make LibGDX Desktop go fullscreen by default

Viewed 13904

I was wondering how to make my desktop app go fullscreen upon start-up. I am new to LibGDX and any help is greatly appreciated. Thank you.

3 Answers

To set the game to full screen when the user presses F, and set to windowed on G (in Kotlin):

    override fun render() {
        ...
        if (Gdx.input.isKeyPressed(Input.Keys.F))
            Gdx.graphics.setFullscreenMode(Gdx.graphics.displayMode)
        if (Gdx.input.isKeyPressed(Input.Keys.G))
            Gdx.graphics.setWindowedMode(1280, 720)
        ...
    }

I'll change my answer to Java later and I'll add a way to toggle it.

Related