Full-screen mode execution


For performing in full-screen mode, the following codes are added to the constructor of Game1 class.
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // It performs in full-screen mode.
            graphics.IsFullScreen = true;
        }

Exit processing of game


When terminating a game, Game.Exit method is called within a Game1.Update method.
A code is as follows.
protected override void Update(GameTime gameTime)
{
    // Game logic is described here.

    // A game is ended.
    if (gameExit)
    {
        this.Exit();
        return;
    }

    base.Update(gameTime);
}

Change of resolution


For changing resolution, the following codes are added to the constructor of Game1 class.
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Change of resolution.
            graphics.PreferredBackBufferWidth = 1280;
            graphics.PreferredBackBufferHeight = 720;
        }

Input(Keyboard, Mouse, GamePad)


A keyboard, a mouse, and Xbox 360 controller can be used in PC.
A keyboard, and Xbox 360 controller can be used in Xbox 360.

Coding.
// Game1.cs

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Sample
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

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

        protected override void LoadContent()
        {
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            KeyboardState keyboardState = Keyboard.GetState();
            MouseState mouseState = Mouse.GetState();
            GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);

            // As an example getting some input state.

            if (keyboardState.IsKeyDown(Keys.Space))
            {
                // Processing when pushing the space key of a keyboard.
            }

            if (mouseState.LeftButton == ButtonState.Pressed)
            {
                // Processing when carrying out the left click of the mouse.
            }

            if (gamePadState.IsConnected)
            {
                if (gamePadState.Buttons.A == ButtonState.Pressed)
                {
                    // Processing when pushing the A button of a gamepad.
                }
            }

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

            base.Draw(gameTime);
        }
    }
}

SpriteFont


The right click of the Content project.
"Sprite Font" is added from a template.
As an example it named "SpriteFont1.spritefont".
Please set up the font of liking(.spritefont file is an easy XML format).

And coding.
// Game1.cs

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Sample
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;

        SpriteBatch spriteBatch;
        SpriteFont spriteFont;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

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

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            spriteFont = Content.Load<SpriteFont>("SpriteFont1");
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();
            spriteBatch.DrawString(spriteFont, "Hello, XNA world!", new Vector2(0, 0), Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}

4xMSAA(Multi Sampling Anti Aliasing)


Let's use multisample anti-aliasing(MSAA).

The code hooked in a PreparingDeviceSetting event is added to the constructor of a Game1 class.
    graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(GraphicsPreparingDeviceSettings);
And the following codes are added.
void GraphicsPreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
{
    PresentationParameters pp = e.GraphicsDeviceInformation.PresentationParameters;
#if XBOX
    pp.MultiSampleQuality = 1;
    pp.MultiSampleType = MultiSampleType.FourSamples;
    return;
#endif
    GraphicsAdapter adapter = e.GraphicsDeviceInformation.Adapter;
    SurfaceFormat format = adapter.CurrentDisplayMode.Format;

    int quality = 0;
    if (adapter.CheckDeviceMultiSampleType(DeviceType.Hardware, format, false, MultiSampleType.FourSamples, out quality))
    {
        pp.MultiSampleQuality = 0;
        pp.MultiSampleType = MultiSampleType.FourSamples;
    }
    else if (adapter.CheckDeviceMultiSampleType(DeviceType.Hardware, format, false, MultiSampleType.TwoSamples, out quality))
    {
        pp.MultiSampleQuality = 0;
        pp.MultiSampleType = MultiSampleType.TwoSamples;
    }
}
Reference
Higeneko diary

Multi-core in Xbox 360


Xbox 360 has 3 core composition which can use 6 hardware threads (HWT).
The number is shaken at HWT.

Core HWT Use
0 0 Use is impossible. System notice, Transformer port, Service.
0 1 Use is possible. Game main thread, GSE host, .NetCF.
1 2 Use is impossible. Asynchronous Xbox 360 content operation.
1 3 Use is possible. Xbox 360 guide, Dashboard.
2 4 Use is possible. Xbox Live market place download.
2 5 Use is possible. Xbox 360 guide, Dashboard.

Thread.SetProcessorAffinity method is used for assignment of HWT.
However, since only assignment of the thread under execution can do this method now, it is necessary to specify it as the beginning of the entry point of a thread.
The technique of the multithread of C#/.NET can be used as it is.

Reference
Higeneko diary

Inline method by XNA on Xbox 360


The inline method which mitigates the overhead of a call of a method.
JIT forms into an inline what fulfills the following conditions.
  • The IL code size is 16 bytes or less.
  • The branch command is not used (if sentence etc.).
  • The local variable is not used.
  • Exception handling has not been carried out (try, catch, etc.).
  • float is not used as the argument or return value of a method (probably by the Xbox 360, not applied).
  • When two or more arguments are in a method, it uses for the turn declared.
However, a virtual function is not formed into an inline.

Reference
Higeneko diary

TCR(Technical Certification Requirements)

  • If connection of a controller goes out, the message which changes a game into a pause state and demands re-connection of a controller from a user will be displayed.
  • The same screen is not displayed continuously 5 seconds or more.
  • When the state where a user cannot operate it continues 15 seconds or more, the work in which a user is not bored is carried out.
  • A message is displayed in safe area.
  • Antialiasing is used.
Reference
Hinikeni XNA

Supposition of GraphicsDevice in XNA 2.0


In XNA2.0, the treatment of a graphics resource becomes easy and the necessity of caring about problems, such as device lost generated on Windows, can generate a graphics resource now easily within Game.LoadContent almost newly added in nothing.
In order that a LoadGraphicsContent method may also maintain compatibility with XNA 1.0, it is called only at once.

Once it generates all graphics resources, such as Texture2D, VertexBuffer, and RenderTarget, on XNA2.0, the instance will be in an always effective state.
Of course, even when it moves between monitors in a window in size change of the case which device lost and device reset generate, for example, a window, the change to a full screen, and a multi-monitor environment, the instance made first can be used satisfactory.

However, the contents of graphics resources which rewrite the contents dynamically, such as RenderTarget and DynamicVertexBuffer, will be canceled on restriction of the driver model of DirectX 9 at the time of device lost.
Usually, since it is generated with the following frame even if the contents are canceled, since many of graphics resources generated dynamically are generated for every frame, it is not necessary to carry out special processing.
Only when using techniques, such as motion blur by drawing in piles the contents of the graphics resource which must hold the contents between frames, for example, the brightness texture for tone mapping used by the HDR rendering, and a front frame, it is necessary to make it the initial value right at the time of device lost.

Conclusion
  • A graphics resource is generated within Game.LoadContent.
  • It is only at the time of a program start that Game.LoadContent is called.
  • DrawableGameComponent.LoadContent is called only at the time of initialization of a component.
  • It became unnecessary to remake the instance of a graphics resource.
  • As for the graphics resource which holds the contents between frames, the contents are canceled at the time of device lost.
    • The instance itself is effective also at the time of device lost, as.
    • SetData<T> etc. is used at the time of a GraphicsDevice.DeviceReset event, and changing into an initial value is only.
Reference
Hinikeni XNA

SpriteBatch


The example which draws "GameThumbnail.png".
  • "GameThumbnail.png" is copied.
  • It pastes into the "Content" project.
  • It checks that the asset name is "GameThumbnail".
And coding.
// Game1.cs

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Sample
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;

        SpriteBatch spriteBatch;
        Texture2D texture;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

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

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            texture = Content.Load<Texture2D>("GameThumbnail");
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin(SpriteBlendMode.None, SpriteSortMode.Immediate, SaveStateMode.None);
            spriteBatch.Draw(texture, new Vector2(0, 0), Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}
SpriteBatch can specify and draw the arbitrary domains of Texture for a position, a color, an angle, the rate of expansion reduction, vertical / horizontal reversal, and depth by the overload of a SpriteBatch.Draw method.

Moreover, alpha blend / addition drawing and sorting processing of batching can also be specified by the overload of a SpriteBatch.Begin method.

Template


It is the easy template code which displays a window by XNA.
// Game1.cs

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Sample
{
   public class Game1 : Microsoft.Xna.Framework.Game
   {
       GraphicsDeviceManager graphics;

       public Game1()
       {
           graphics = new GraphicsDeviceManager(this);
           Content.RootDirectory = "Content";
       }

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

       protected override void LoadContent()
       {
       }

       protected override void UnloadContent()
       {
       }

       protected override void Update(GameTime gameTime)
       {
           base.Update(gameTime);
       }

       protected override void Draw(GameTime gameTime)
       {
           graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

           base.Draw(gameTime);
       }
   }
}

What is mesothelioma


There are a good nature and malignancy in mesothelioma.

The most occurs by suction of asbestos.
It has generated not only in asbestos mining laborers or the laborers treating asbestos but in the residents around a mine or a factory or laborers' family.

A risk becomes high, so that an exposure history is so long that there is much exposure.

An exposure history especially clear in a woman may not be found.
Although the lung cancer risk with asbestos is strengthened by smoking, it is thought that the risk of mesothelioma is not strengthened.

Benign mesothelioma can expect recovery by the surgery treatment.