Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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();
share|improve this answer
1  
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 –  CobaltHex Sep 12 '12 at 22:11
    
But no more so that if you run in a window, right? –  Joe Sep 12 '12 at 23:16
    
no but when you're maximized, you're using more pixels –  CobaltHex Sep 13 '12 at 13:44
    
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. –  Joe Sep 13 '12 at 14:00
    
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. –  Cypher Sep 13 '12 at 17:15
add comment

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.

share|improve this answer
    
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. :( –  ProgrammerAtWork Sep 12 '12 at 18:38
    
Hmm, well that's a shame :(. Guess it's something I'll have to look out for too when I finally get into XNA. –  Orin MacGregor Sep 12 '12 at 18:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.