Jump to:

When setting (I use Windows 7 x64)WindowState = WindowState.Fullscreen;OnResize() is called 2 times, and when going back from fullscreen by settingWindowState = WindowState.NormalOnResize() is called 3 times. This is not you expect should happen.

In my project I need to do some initialization every time the window is resized.

protectedoverridevoid OnResize(EventArgs e){
Init();
}

And calling Init() three times causes a noticeable delay. I solved this with the following code that works, but is not very intuitive (and has a high probability of failing in an upcoming version or on another platform).

Comment viewing options

The window is actually resized multiple times when changing to/from fullscreen mode on Windows (most changes to WindowBorder or WindowState will first change the window into Resizable/Normal, apply the new value, and finally restore the window to its previous state if necessary. Some state changes cannot work reliably without this roundabout approach). In that sense, multiple events are correct, even if conceptually surprising.

I'm trying to determine whether there is a good way to suppress unnecessary resize events in a clean manner.

Edit: I should mention that, in my experience, it may be better to avoid reinitializing resources like FBOs inside the Resize event. It is usually slightly more efficient to set a flag inside the Resize event and check it at some later point (RenderFrame is a good place) - not only does this avoid unnecessary strain on the drivers and video memory, it also avoids UI lag while the user is dragging the window border.