3
\$\begingroup\$

I'm loading a simple texture and rotating it in XNA, and this works.

But when I run it in full screen 1920x1080 mode I see spikes while my texture is rotating.

If I run it windowed with 1920x1080 resolution, I don't get the spikes.

The size of the texture does not seem to matter, I tried 512 texture size and 2048 texture size, same thing happens. Spikes in full screen, no spikes in windowed, resolution does not seem to matter, Debug or Release does not seem to do anything either.

Anyone got ideas of what could be the problem?

Edit:

I think this problem has something to do with the vertical retrace. Set this property: _graphicsDeviceManager.SynchronizeWithVerticalRetrace = false;

you'll lose vsync but it will not stutter.

\$\endgroup\$
1

2 Answers 2

2
\$\begingroup\$

Use maximised border-less windows to 'simulate' fullscreen mode. I actually prefer games that have this option - it works MUCH better with multiple screens and there's no delay when alt-tabbing out. The main issue is that you can't minimise the game easily so it will cover the desktop unless you use the minimise shortcut or show desktop shortcut.

I use this code in my Game.Initialize() method to do it:

var myScreen = Screen.AllScreens[0]; // Change 0 for other screens

graphics.PreferredBackBufferWidth = myScreen.Bounds.Width;
graphics.PreferredBackBufferHeight = myScreen.Bounds.Height;
graphics.ApplyChanges(); // Not necessary, however this is a method in my code

Form gameForm = (Form)Form.FromHandle(Window.Handle);
gameForm.FormBorderStyle = FormBorderStyle.None;

gameForm.Left = myScreen.WorkingArea.Left;
gameForm.Top = myScreen.WorkingArea.Top;

I'm not sure if there's a performance hit, I haven't checked.

EDIT:

If you want to come out of this mode you need to do this:

Form gameForm = (Form)Form.FromHandle(Window.Handle);
gameForm.FormBorderStyle = FormBorderStyle.Sizable;

gameForm.Icon = System.Drawing.Icon.ExtractAssociatedIcon(
    Process.GetCurrentProcess().ProcessName + ".exe");
// IMPORTANT - XNA loses it's icon when going from no border back to having a border

graphics.PreferredBackBufferWidth = 800;
graphics.PreferredBackBufferHeight = 600;
graphics.ApplyChanges();
\$\endgroup\$
5
  • 1
    \$\begingroup\$ yes there is a perf. hit because if you go into 'true fullscreen', nothing else except that window is rendered, its not the same when maximized. however, if you have a good enough computer, it shouldn't be noticable \$\endgroup\$
    – CobaltHex
    Sep 12, 2012 at 22:11
  • \$\begingroup\$ But no more so that if you run in a window, right? \$\endgroup\$ Sep 12, 2012 at 23:16
  • \$\begingroup\$ no but when you're maximized, you're using more pixels \$\endgroup\$
    – CobaltHex
    Sep 13, 2012 at 13:44
  • 1
    \$\begingroup\$ Yeah, I guess. It's probably wise just to assume the performance hit is tiny then, I've never heard of someone to choosing to run a game in fullscreen over window because for performance reasons. \$\endgroup\$ Sep 13, 2012 at 14:00
  • \$\begingroup\$ When your game is run in fullscreen mode, it has dedicated access to the graphics card. When in windowed mode, it does not. The difference this makes in the performance of any given game is completely subjective on the requirements and complexity of that game. There are also a few things you can't do when not in fullscreen mode, such as vsync. \$\endgroup\$
    – Cypher
    Sep 13, 2012 at 17:15
2
\$\begingroup\$

A potential explanation found in a Steam forum of all places.

It's a bug in XNA framework's fixed timestep code. I have the same problem.

Only way developers will fix this issue is that they don't use XNA's fixed timestep loop for PC version of the game. They have to make their own fixed step gameloop, but it's really easy to do.

Even official XNA code samples that use XNA's fixed step, stutter on my computer in fullscreen.

\$\endgroup\$
2
  • \$\begingroup\$ The time-step apparently isn't the issue, and developers of some well known games can't fix the problem. Looks like I can't do anything about it. :( \$\endgroup\$ Sep 12, 2012 at 18:38
  • \$\begingroup\$ Hmm, well that's a shame :(. Guess it's something I'll have to look out for too when I finally get into XNA. \$\endgroup\$ Sep 12, 2012 at 18:42

You must log in to answer this question.

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