I have a WPF window full of some WPF3D elements, and I decided when I maximized my WPF window, I'd like it to do more a 'fullscreen' display, and remove the various window dressings, so I did this:
protected override void OnStateChanged(EventArgs e)
{
if (this.WindowState == WindowState.Maximized)
{
this.WindowStyle = WindowStyle.None;
this.ResizeMode = ResizeMode.NoResize;
}
}
This takes the borders and titlebars off of my window, and it goes ahead and fills up the screen, respecting the windows task bars "auto-hide" and "on top" properties.
Only, the performance when animating my 3D objects was suddenly horrible, my CPU usage went through the roof, and the smooth animations i did have suddenly were < 1 FPS.
Changing the WindowStyle.None to anything else (SingleBorder, for example), didn't exhibit this problem.
I'd seen this terrible behaviour before, when playing with transparent windows - when you set WindowStyle to None, and AllowsTransparency=True, and all of your windows content is blended with the rest of your desktop - forcing a slow software rendering which has to test each and every pixel as it renders your desktop back to front, which is a heavily fill rate limited operation. It's a cute effect, but slow and worthless.
So I wondered, could something be setting AllowsTransparency=True internally, when I flip the WindowStyle = None switch? I placed AllowsTransparency="False" in the Window element of the .xaml file, and there was no change in behaviour.
I tried setting AllowsTransparency=false in code, right after changing the WindowStyle, and this throws an exception - as this property can only be set before the window is shown. So I put this line in the constructor, before InitializeComponent().
This fixed the issue - on my home machine - however it appears to remain on my machine at work.
This is weird all around. Explicitly setting it in code before InitializeComponent works, even though it is already explicitly set in the xaml - which does nothing. It works on a 32 bit Windows 7 machine with a ATI 4650 agp (WDDM 1.0 vista drivers), but seems to have no effect on a 64 bit Windows 7 machine with an NVidia card (WDDM 1.0 ).
I haven't peeked under the hood, but I'd chalk this up to Windows 7 growing pains, probably a bug in one or the other driver sets. This isn't the right way to do fullscreen with my emulator anyways (i should give the monitor over completely to DX), but certainly weird.
Wednesday, October 28, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment