VILLAIN bryan
VILLAIN bryan

Reputation: 741

LibGDX Automatically Scaling GWT Window to Monitor Resolution

I'm creating an application with LibGDX and deploying exclusively to a GWT HTML5 environment. The below code sets up my environment with a 1280x720 resolution as expected:

public class HtmlLauncher extends GwtApplication {

    @Override
    public GwtApplicationConfiguration getConfig() {
        return new GwtApplicationConfiguration(1280, 720); // <-- here is line of code in question
    }

    @Override
    public ApplicationListener getApplicationListener() {
        return Engine.getInstance();
    }
}

I would like my application to be dynamically sized at load-time as essentially "full screen" (filling up the entire browser space), and not a fixed 1280x720. How can I achieve this behavior without knowing specifically the client's monitor size? (Gdx.graphics.getWidth() and Gdx.graphics.getHeight() return NPE as I believe getConfig() initializes them)

Upvotes: 2

Views: 621

Answers (1)

noone
noone

Reputation: 19776

You will have to do this with platform specific code. In case of GWT, this seems to be Window.

return new GwtApplicationConfiguration(Window.getClientWidth(), Window.getClientHeight());

Upvotes: 4

Related Questions