Kamujin's picture

GameWindow.Width / Height concern.

I have noticed that if you set the Width and Height property of the GameWindow and then read them back immediately, there is the possibility that the correct values will not be returned.

It appears that when you set these properties, the private variables (which are returned by the get statements) are not updated. I believe they are eventually updated by event handlers triggered by the actually window's resizing.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
objarni's picture

It smells like the GameWindow.Width/Height-properties should be getters only. And add a method to try-to-change the size of the window:

GameWindow.SetSize(width, height)

(you wouldn't want to change first the width, then the height anyway, that would "flicker" the window)

the Fiddler's picture

Indeed, the values are updated only when the window is actually resized.

GameWindow.SetSize(width, height) would suffer from the same problem:

this.SetSize(640, 480);

This will not print 640 either.

This looks a little startling at first, but given the choice of invalid data (the property returns 640, which is not yet true!), or correct data but delayed reporting, which would you prefer?

Note that the delay will be at most 1 frame (the window will be resized before the next frame begins).

objarni's picture

OK I understand the situation better now.

Maybe change of naming:


.. or some other "will-not-happen-instantly"-word for "Post". FlagResize, ResizeLater, TryResize ...