wwwxwww

How in XNA Game Studio Express correctly to include a full-screen mode

I write a code:

graphics.PreferredBackBufferWidth = 1024;

graphics.PreferredBackBufferHeight = 768;

graphics.PreferMultiSampling = false;

graphics.ToggleFullScreen();

Then I draw on the screen 2D the sprite and I move it on the screen. During the moment of moving of the sprite on the screen, he brakes and twitches, such impression that copying of the sprite occurs on without usage Z-buffer. How correctly to customize in project XNA Game Studio Express using class Game1 a full-screen mode

In DirectX earlier, it was so:

D3DDISPLAYMODE Display;

if( FAILED( pd3d9->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &Display ) ) )

return E_FAIL;

D3DPRESENT_PARAMETERS d3d9pp;

ZeroMemory( &d3d9pp, sizeof(d3d9pp) );

d3d9pp.Windowed = FALSE;

d3d9pp.SwapEffect = D3DSWAPEFFECT_DISCARD;

d3d9pp.BackBufferFormat = Display.Format;

d3d9pp.EnableAutoDepthStencil = TRUE;

d3d9pp.AutoDepthStencilFormat = D3DFMT_D16;

d3d9pp.BackBufferWidth = Display.Width;

d3d9pp.BackBufferHeight = Display.Height;

d3d9pp.BackBufferCount = 2;

d3d9pp.FullScreen_RefreshRateInHz = Display.RefreshRate;

if( FAILED( pd3d9 -> CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,

D3DCREATE_HARDWARE_VERTEXPROCESSING,

&d3d9pp, &pDevice ) ) )

How to achieve precisely such in Game Studio Express using class Game1

In help to Studio about it is not spoken. I cannot understand, help!



Re: XNA Game Studio Express How in XNA Game Studio Express correctly to include a full-screen mode?

The ZMan

Take a look at the SpaceWar sample - it implements full screenmode if you press alt-enter




Re: XNA Game Studio Express How in XNA Game Studio Express correctly to include a full-screen mode?

wwwxwww

I looked project SpaseWar, but could not understand. There are errors. Why about this problem there is no not a word in help to XNA





Re: XNA Game Studio Express How in XNA Game Studio Express correctly to include a full-screen mode?

Bill Reiss

Dr. Popper implements a full screen mode as well with a toggle between full screen and windowed mode. It includes source so you can check it out.




Re: XNA Game Studio Express How in XNA Game Studio Express correctly to include a full-screen mode?

wwwxwww

In class Game1 there is a following code:

public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
ContentManager content;

public Game1()
{
graphics = new GraphicsDeviceManager(this);
content = new ContentManager(Services);

// this full-screen mode code not correctly!!!
graphics.PreferredBackBufferWidth = 1024;
graphics.PreferredBackBufferHeight = 768;
graphics.PreferMultiSampling = false;
graphics.ToggleFullScreen();
}

protected override void Initialize()
{
base.Initialize();
}

protected override void LoadGraphicsContent(bool loadAllContent)
{
if (loadAllContent)
{
}
}


How all the same correctly to create a full-screen mode !





Re: XNA Game Studio Express How in XNA Game Studio Express correctly to include a full-screen mode?

Bill Reiss

This is my full screen code from Dr. Popper:

using SF = System.Windows.Forms;

private void GoFullScreen()
{
  
int width = 1024;
  
int height = 768;
  
foreach (SF.Screen s in SF.Screen.AllScreens)
   {
     
string tmp = s.DeviceName;
      tmp = tmp.Substring(0, tmp.IndexOf(
'\0'));
     
if (tmp == this.Window.ScreenDeviceName)
      {
         height = s.Bounds.Height;
         width = s.Bounds.Width;
      }
   }
   Graphics.PreferredBackBufferWidth = width;
   Graphics.PreferredBackBufferHeight = height;
  
if (Graphics.IsFullScreen == false) Graphics.ToggleFullScreen();
}

If you want to see more of the source, go to http://www.bluerosegames.com to download.






Re: XNA Game Studio Express How in XNA Game Studio Express correctly to include a full-screen mode?

wwwxwww

I tasted this code, but XNA Game Studio Express 1.0 at compilation gives an error:

-------------------------------------------------------------------------------------------

Error 1 The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference ) C:\Screen\Game1.cs 4 19 Screen

------------------------------------------------------------------------------------------

Here this line of a code gives an error:

#region Using Statements

using System;

using SF = System.Windows.Forms; <----- Here this line of a code gives an error:

using System.Collections.Generic;

.........





Re: XNA Game Studio Express How in XNA Game Studio Express correctly to include a full-screen mode?

Bill Reiss

Yes you need to add a reference to the project for System.Windows.Forms since XNA Game projects don't include it by default. I added that reference so that I can display a message box.