0
\$\begingroup\$

I'm a bit baffled by a specific bit of behaviour in LibGDX.

The resize method of my screens is as simple as can be, because right now I don't need anything more:

    override fun resize(width: Int, height: Int) {
        log.info { "Window resize to $width x $height" }
        stage.viewport.update(width, height, true)
    }

It works perfectly, if I resize the window manually. If I however change the size programmatically by calling setWindowedMode(), the blasted thing doesn't seem to do anything. I can clearly see in the log that it's being executed, that much is fine, but my viewport doesn't care. If I go and manually change the size of the window by whatever amount, everything goes "plop" and falls into place.

Sooo... Why is this not working when I call setWindowedMode()? It feels like resize is getting called too early in the event queue and that therefore the changes have no effect, but that's purely speculation. What am I supposed to use instead or in addition of setWindowedMode() to make the viewport do its job?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Ok, it was an oversight on my part. I had an old line of code lying around from back when I experimented, that updated the viewport with the old dimensions after resize() was called when I changed the setting in the menu.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .