Xen 1.8.1: graphics settings initialization

May 13, 2010 at 12:57 PM

Hi StatusUnknown,

I'm meeting an issue with the GraphicsDevice initialization using Xen and couldn't find out what I'm doing wrong or if it's a bug.

So, I create a simple Application derived class and override the SetupGraphicsDeviceManager method to initialize it and set the initial resolution and fullscreen/window mode depending on a simple settings file stored on user's disk.

The result is that if I set up a resolution different from the current DisplayMode, the GraphicsDevice resets once and therefore reloads content indicated in the IContentOwner.LoadContent inherited methods.

Any idea why I'm getting this result? Where should I initialize my resolution to avoid such behavior?

Thanks

Philippe

Coordinator
May 13, 2010 at 1:16 PM

That sounds quite odd.

Are you setting the fullscreen flag, or using ToggleFullscreen() (the flag should work fine).

When SetupGraphicsDeviceManager is called the graphics device hasn't actually been created yet - you are setting up the GraphiceDeviceManager at that point.
Does this actually stop your application from starting correctly?

May 13, 2010 at 8:34 PM

I'm setting the IsFullscreen flag and also tried the ToggleFullscreen method and both give the same result.

Have you tried on your side to see if this behavior occurs also on your side?

Philippe

Coordinator
May 13, 2010 at 9:16 PM

I've tried this, and LoadContent only fires once for each asset.

I'm not sure what could be happening. Is it causing a significant problem? It shouldn't actually be leaking memory, etc.

May 13, 2010 at 11:42 PM
Edited May 13, 2010 at 11:51 PM

Yes it does as it ends up not rendering the first frames...

I've been stepping through the API but I can't get when exactly it is happening... I'm quite sure the device is reset on the first call to XNALogic.Update method when it tests for the windowForm presence and assigning some Deactivate and Activate event delegates... Still I couldn't proved it as when you use VS debugger on Fullscreen app, the Form loses its focus and therefore calls immediatelly the GraphicsDevice.Reset event...

[EDIT]

I found out that it is related to the fact that I have 2 monitors...Unplugging my second monitor, the behavior doesn't occur anymore.

I'll dig a little bit into that but if you see any portion of code why this is happening, please let me know ;)

Philippe

 

Coordinator
May 18, 2010 at 10:14 PM

Unfortunately I do all my xen dev on my personal laptop, but I'll have a crack at trying it on my work PC since that has 3 monitors.

Cheers

May 19, 2010 at 8:55 AM

I've been debugging the API and I think I found out some additional clues. It seems that this is happening on the first Update call when the UpdateState is created.

If I am right, you may have some initial code in the GetProtectedState method that resets the GraphicsDevice if there is multiple monitors. Still have to go through the StackTrace to dig even more ;)

Philippe