XNA beta code migration
these are some quick and dirty notes on migrating XNA GSE beta code to GSE V 1.0.
when you are migrating, refer to the XNA GSE documentation (in the Programs folder for GSE). the migration information is under Getting Started with XNA Game Studio Express -> Migrating from Beta 1 to Beta 2 (see below). this information also applies to the release version.
-------------------
GameTime
-------------------
double dblMS = (double)this.GameTime.Milliseconds;
becomes:
GameTime gameTime = new GameTime();
double dblMS = (double)gameTime.ElapsedGameTime.Milliseconds;
-------------------
loading Texture2D
-------------------
mTex2DSprite = Texture2D.FromFile(this.gfx.GraphicsDevice, @"..\..\light.dds");
becomes:
mTex2DSprite = content.Load(@"..\..\light") as Texture2D;
-------------------
VertexPositionColorTexture
-------------------
VertexPositionColorTexture parameters are in a different order
mVertSprite[0] = new VertexPositionColorTexture(pos, uv, Color.White);
becomes:
mVertSprite[0] = new VertexPositionColorTexture(pos, Color.White, uv);
-------------------
DrawUserPrimitives
-------------------
gfx.GraphicsDevice.DrawUserPrimitives
(PrimitiveType.TriangleStrip, // triangle strips
2, // two primitive objects
mVertSprite); // use sprite vertex
becomes:
gfx.GraphicsDevice.DrawUserPrimitives
(PrimitiveType.TriangleStrip, // triangle strips
mVertSprite, // use sprite vertex
0, // vertex offset
2); // two primitive objects
-------------------
EffectStateOptions
-------------------
EffectStateOptions is gone
mfxTex.Begin(EffectStateOptions.Default);
becomes:
mfxTex.Begin();
-------------------
from the documentation:
Migrating a Beta 1 project to Beta 2
"Create a new project by selecting New Project... from the File menu. Select Windows Game, name your new project, and click OK.
Add classes from your old project to your new project by selecting Add Existing Item... from the Project menu. Navigate to your Beta 1 project, select the class or classes to import, and click OK.
Add resources from your old project to your new project also by selecting Add Existing Item... and choosing Content Pipeline Files from the Files of type: drop-down box. You can select models, textures, effects and sounds to add to your project. See "Importing a resource into the Content Pipeline" below for more information.
Migrate code from your old project's Game1 class to your new project's Game1 class, including your Update and Draw methods. Use LoadGraphicsContent to load automatic and manual resources (note: "automatic" was called "managed" in Beta 1).
The Game Designer from Beta 1 does not exist in Beta 2. Use the Game constructor to set properties on the GraphicsDeviceManager (formerly GraphicsComponent).
Some code changes will be required before your Beta 1 code will compile properly in Beta 2. See "Framework Changes" below for a list of some of those changes. "
other resources:
Migrating an XNA Application from Beta 1 to Beta 2
when you are migrating, refer to the XNA GSE documentation (in the Programs folder for GSE). the migration information is under Getting Started with XNA Game Studio Express -> Migrating from Beta 1 to Beta 2 (see below). this information also applies to the release version.
-------------------
GameTime
-------------------
double dblMS = (double)this.GameTime.Milliseconds;
becomes:
GameTime gameTime = new GameTime();
double dblMS = (double)gameTime.ElapsedGameTime.Milliseconds;
-------------------
loading Texture2D
-------------------
mTex2DSprite = Texture2D.FromFile(this.gfx.GraphicsDevice, @"..\..\light.dds");
becomes:
mTex2DSprite = content.Load
-------------------
VertexPositionColorTexture
-------------------
mVertSprite[0] = new VertexPositionColorTexture(pos, uv, Color.White);
becomes:
mVertSprite[0] = new VertexPositionColorTexture(pos, Color.White, uv);
DrawUserPrimitives
-------------------
(PrimitiveType.TriangleStrip, // triangle strips
2, // two primitive objects
mVertSprite); // use sprite vertex
becomes:
gfx.GraphicsDevice.DrawUserPrimitives
(PrimitiveType.TriangleStrip, // triangle strips
mVertSprite, // use sprite vertex
0, // vertex offset
2); // two primitive objects
EffectStateOptions
-------------------
mfxTex.Begin(EffectStateOptions.Default);
becomes:
mfxTex.Begin();
from the documentation:
Migrating a Beta 1 project to Beta 2
"Create a new project by selecting New Project... from the File menu. Select Windows Game, name your new project, and click OK.
Add classes from your old project to your new project by selecting Add Existing Item... from the Project menu. Navigate to your Beta 1 project, select the class or classes to import, and click OK.
Add resources from your old project to your new project also by selecting Add Existing Item... and choosing Content Pipeline Files from the Files of type: drop-down box. You can select models, textures, effects and sounds to add to your project. See "Importing a resource into the Content Pipeline" below for more information.
Migrate code from your old project's Game1 class to your new project's Game1 class, including your Update and Draw methods. Use LoadGraphicsContent to load automatic and manual resources (note: "automatic" was called "managed" in Beta 1).
The Game Designer from Beta 1 does not exist in Beta 2. Use the Game constructor to set properties on the GraphicsDeviceManager (formerly GraphicsComponent).
Some code changes will be required before your Beta 1 code will compile properly in Beta 2. See "Framework Changes" below for a list of some of those changes. "
other resources:
Migrating an XNA Application from Beta 1 to Beta 2