xna 3.1 to xna 4.0 conversion cheat sheet.(转)
2011-12-21 10:17
113 查看
Nelxon here again providing yet another resource for XNA Game developers. There are a few sites available to help us convert those XNA 3.1 projects to XNA 4.0, but it seems many of us are still have problems migrating successfully and easily. Its a pain to visit multiple sites and pages only to find corrections for 1 to 3 errors and still have hundreds more left.
After losing many hours of production time, I decided it would be more convenient to have a simple cheat sheet - (collection of code snippets XNA 3.1 to XNA 4.0) to help me convert projects faster with less difficulty. So far, this cheat sheet has helped me convert over a dozen XNA 3.1 projects, which removed at least 90% of the errors due to the code breaking changes from XNA 4.0. The remaining errors I could resolve myself or simply ask for help on the forums. 5 errors are better than 50…
I decided to share this cheat sheet because I am constantly reading forums where developers discuss having the same problems converting their projects. I figured maybe other developers would find this useful as well. These code snippets were created from comparing the XNA 3.1 creator’s club educational samples to the newer XNA 4.0 samples. However do not consider this page as a tutorial, it is a list of examples to help you see the difference between XNA 3.1 and XNA 4.0 syntax and provided to help you learn by example.
DON’T FORGET TO BACKUP YOUR WORK FIRST, BEFORE YOU TRY TO CONVERT IT.
Bookmark this page, because it may come in handy if you find a good library written in XNA 3.1. If a developer is having problems converting their projects, please send them to this page, it may help.
List of errors resolved using this cheat sheet:
The name ‘SpriteBlendMode‘ does not exist in the current context The name ‘SaveStateMode‘ does not exist in the current context
‘Microsoft.Xna.Framework.Graphics.GraphicsDevice‘ does not contain a definition for ‘RenderState‘…
‘Microsoft.Xna.Framework.Graphics.Effect‘ does not contain a definition for ‘Begin‘ … ‘Microsoft.Xna.Framework.Graphics.Effect‘ does not contain a definition for ‘End‘.. ‘Microsoft.Xna.Framework.Graphics.Effect‘ does not contain a definition for ‘CommitChanges‘ … ‘Microsoft.Xna.Framework.Graphics.EffectPass‘ does not contain a definition for ‘Begin‘ … ‘Microsoft.Xna.Framework.Graphics.EffectPass‘ does not contain a definition for ‘End‘ …. No overload for method ‘Clone‘ takes 1 arguments
The name ‘ShaderProfile‘ does not exist in the current context ‘Microsoft.Xna.Framework.GameTime‘ does not contain a definition for ‘TotalRealTime‘ … ‘Microsoft.Xna.Framework.Color‘ does not contain a definition for ‘TransparentBlack‘ …
The type or namespace name ‘ResolveTexture2D‘ could not be found … ‘Microsoft.Xna.Framework.Graphics.GraphicsDevice‘ does not contain a definition for ‘ResolveBackBuffer‘… The type or namespace name ‘DepthStencilBuffer‘ could not be found …
‘Microsoft.Xna.Framework.Graphics.RenderTarget2D‘ does not contain a constructor that takes 5 arguments … ‘Microsoft.Xna.Framework.Graphics.RenderTarget2D‘ does not contain a definition for ‘GetTexture‘ …
‘Microsoft.Xna.Framework.Graphics.PresentationParameters‘ does not contain a definition for ‘MultiSampleType‘ … ‘Microsoft.Xna.Framework.Graphics.PresentationParameters‘ does not contain a definition for ‘MultiSampleQuality‘ …
The best overloaded method match for ‘Microsoft.Xna.Framework.Graphics.GraphicsDevice.SetRenderTarget…
‘Microsoft.Xna.Framework.Graphics.GraphicsDevice‘ does not contain a definition for ‘VertexDeclaration‘ ‘Microsoft.Xna.Framework.Graphics.GraphicsDevice‘ does not contain a definition for ‘Vertices‘
‘Microsoft.Xna.Framework.Graphics.VertexPositionTexture‘ does not contain a definition for ‘SizeInBytes‘ ‘Microsoft.Xna.Framework.Graphics.VertexPositionTexture‘ does not contain a definition for ‘VertexElements‘
‘Microsoft.Xna.Framework.Graphics.ModelMesh‘ does not contain a definition for ‘IndexBuffer‘ ‘Microsoft.Xna.Framework.Graphics.ModelMesh‘ does not contain a definition for ‘VertexBuffer‘
‘Microsoft.Xna.Framework.Graphics.ModelMeshPart‘ does not contain a definition for ‘BaseVertex‘ ‘Microsoft.Xna.Framework.Graphics.ModelMeshPart‘ does not contain a definition for ‘StreamOffset‘ ‘Microsoft.Xna.Framework.Graphics.ModelMeshPart‘ does not contain a definition for ‘VertexStride‘
‘Microsoft.Xna.Framework.Storage.StorageContainer‘ does not contain a definition for ‘TitleLocation‘ ‘Microsoft.Xna.Framework.Storage.StorageContainer‘ does not contain a definition for ‘Path‘ ‘Microsoft.Xna.Framework.Storage.StorageDevice‘ does not contain a definition for ‘OpenContainer‘ ‘Microsoft.Xna.Framework.GamerServices.Guide‘ does not contain a definition for ‘BeginShowStorageDeviceSelector‘ ‘Microsoft.Xna.Framework.GamerServices.Guide‘ does not contain a definition for ‘EndShowStorageDeviceSelector‘
syntax error: unexpected token ‘VertexShader‘ syntax error: unexpected token ‘PixelShader‘ error X3539: ps_1_x is no longer supported
Other Issues: XNA model is drawn inside out, looks transparent, missing vertices or just doesn’t look right…
?
?
?
?
?
?
?
?
RenderState
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
Effect and EffectPass, Begin(), End(), CommitChanges(), Clone()
?
?
?
?
?
?
?
?
?
?
?
?
ShaderProfile, TotalRealTime, TransparentBlack
?
?
?
?
?
?
ResolveTexture2D, ResolveBackBuffer, RenderTarget2D, GetTexture, DepthStencilBuffer, PresentationParameters, MultiSampleType, MultiSampleQuality, SetRenderTarget
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
VertexDeclaration, Vertices, VertexElements, SizeInBytes
?
?
?
?
?
?
?
?
?
?
VertexBuffer, StreamOffset, VertexStride, IndexBuffer, BaseVertex
?
?
?
?
Points, PointSpriteEnable, PointSizeMax, PointList
?
?
?
?
?
?
OpenContainer, BeginShowStorageDeviceSelector, EndShowStorageDeviceSelector, Path, TitleLocation, FileStream
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
VertexShader, PixelShader, ps_1_x Inside your shader (*.fx) files…
?
?
?
?
XNA Model drawn inside out, slightly transparent, missing parts or just looks wrong
Add the following code before the XNA Model Draw code
?
Well That’s all for now, I will continue to add more examples as needed. Good luck with your games and Remember Indie Games are the future.
![](http://nelxon.com/wp-includes/images/smilies/icon_smile.gif)
-Nelxon Studio
After losing many hours of production time, I decided it would be more convenient to have a simple cheat sheet - (collection of code snippets XNA 3.1 to XNA 4.0) to help me convert projects faster with less difficulty. So far, this cheat sheet has helped me convert over a dozen XNA 3.1 projects, which removed at least 90% of the errors due to the code breaking changes from XNA 4.0. The remaining errors I could resolve myself or simply ask for help on the forums. 5 errors are better than 50…
I decided to share this cheat sheet because I am constantly reading forums where developers discuss having the same problems converting their projects. I figured maybe other developers would find this useful as well. These code snippets were created from comparing the XNA 3.1 creator’s club educational samples to the newer XNA 4.0 samples. However do not consider this page as a tutorial, it is a list of examples to help you see the difference between XNA 3.1 and XNA 4.0 syntax and provided to help you learn by example.
DON’T FORGET TO BACKUP YOUR WORK FIRST, BEFORE YOU TRY TO CONVERT IT.
Bookmark this page, because it may come in handy if you find a good library written in XNA 3.1. If a developer is having problems converting their projects, please send them to this page, it may help.
List of errors resolved using this cheat sheet:
The name ‘SpriteBlendMode‘ does not exist in the current context The name ‘SaveStateMode‘ does not exist in the current context
‘Microsoft.Xna.Framework.Graphics.GraphicsDevice‘ does not contain a definition for ‘RenderState‘…
‘Microsoft.Xna.Framework.Graphics.Effect‘ does not contain a definition for ‘Begin‘ … ‘Microsoft.Xna.Framework.Graphics.Effect‘ does not contain a definition for ‘End‘.. ‘Microsoft.Xna.Framework.Graphics.Effect‘ does not contain a definition for ‘CommitChanges‘ … ‘Microsoft.Xna.Framework.Graphics.EffectPass‘ does not contain a definition for ‘Begin‘ … ‘Microsoft.Xna.Framework.Graphics.EffectPass‘ does not contain a definition for ‘End‘ …. No overload for method ‘Clone‘ takes 1 arguments
The name ‘ShaderProfile‘ does not exist in the current context ‘Microsoft.Xna.Framework.GameTime‘ does not contain a definition for ‘TotalRealTime‘ … ‘Microsoft.Xna.Framework.Color‘ does not contain a definition for ‘TransparentBlack‘ …
The type or namespace name ‘ResolveTexture2D‘ could not be found … ‘Microsoft.Xna.Framework.Graphics.GraphicsDevice‘ does not contain a definition for ‘ResolveBackBuffer‘… The type or namespace name ‘DepthStencilBuffer‘ could not be found …
‘Microsoft.Xna.Framework.Graphics.RenderTarget2D‘ does not contain a constructor that takes 5 arguments … ‘Microsoft.Xna.Framework.Graphics.RenderTarget2D‘ does not contain a definition for ‘GetTexture‘ …
‘Microsoft.Xna.Framework.Graphics.PresentationParameters‘ does not contain a definition for ‘MultiSampleType‘ … ‘Microsoft.Xna.Framework.Graphics.PresentationParameters‘ does not contain a definition for ‘MultiSampleQuality‘ …
The best overloaded method match for ‘Microsoft.Xna.Framework.Graphics.GraphicsDevice.SetRenderTarget…
‘Microsoft.Xna.Framework.Graphics.GraphicsDevice‘ does not contain a definition for ‘VertexDeclaration‘ ‘Microsoft.Xna.Framework.Graphics.GraphicsDevice‘ does not contain a definition for ‘Vertices‘
‘Microsoft.Xna.Framework.Graphics.VertexPositionTexture‘ does not contain a definition for ‘SizeInBytes‘ ‘Microsoft.Xna.Framework.Graphics.VertexPositionTexture‘ does not contain a definition for ‘VertexElements‘
‘Microsoft.Xna.Framework.Graphics.ModelMesh‘ does not contain a definition for ‘IndexBuffer‘ ‘Microsoft.Xna.Framework.Graphics.ModelMesh‘ does not contain a definition for ‘VertexBuffer‘
‘Microsoft.Xna.Framework.Graphics.ModelMeshPart‘ does not contain a definition for ‘BaseVertex‘ ‘Microsoft.Xna.Framework.Graphics.ModelMeshPart‘ does not contain a definition for ‘StreamOffset‘ ‘Microsoft.Xna.Framework.Graphics.ModelMeshPart‘ does not contain a definition for ‘VertexStride‘
‘Microsoft.Xna.Framework.Storage.StorageContainer‘ does not contain a definition for ‘TitleLocation‘ ‘Microsoft.Xna.Framework.Storage.StorageContainer‘ does not contain a definition for ‘Path‘ ‘Microsoft.Xna.Framework.Storage.StorageDevice‘ does not contain a definition for ‘OpenContainer‘ ‘Microsoft.Xna.Framework.GamerServices.Guide‘ does not contain a definition for ‘BeginShowStorageDeviceSelector‘ ‘Microsoft.Xna.Framework.GamerServices.Guide‘ does not contain a definition for ‘EndShowStorageDeviceSelector‘
syntax error: unexpected token ‘VertexShader‘ syntax error: unexpected token ‘PixelShader‘ error X3539: ps_1_x is no longer supported
Other Issues: XNA model is drawn inside out, looks transparent, missing vertices or just doesn’t look right…
ListofExamplesConvertingXNA3.1toXNA4.0
SpriteBlendMode, SaveStateMode?
?
?
?
?
?
?
?
?
?
Add the following code before the XNA Model Draw code
?
![](http://nelxon.com/wp-includes/images/smilies/icon_smile.gif)
-Nelxon Studio
相关文章推荐
- XNA 3.1 TO XNA 4.0 Conversion Cheat Sheet
- [转]xna 3.1 to xna 4.0
- List of Examples Converting XNA 3.1 to XNA 4.0
- Migrating from HttpClient 3.1 to HttpClient 4.0
- (转贴)Data type conversion sheet : C++ to .NET
- 【Android 4.0】conversion to dalvik format failed with error 1
- 【Android 4.0】conversion to dalvik format failed with error 1
- SysVinit to Systemd Cheatsheet/zh
- SysVinit to Systemd Cheatsheet Linux服务配置
- custom FbxImporter to import multi animations from single FBX file for xna 4.0
- Nmap Cheat Sheet: From Discovery to Exploits – Part 1: Introduction to Nmap
- dashboard 4.0 cannot connect a prompt to spreadsheet in query browser
- Data type conversion sheet : C++ to .NET
- Conversion to Dalvik format failed with error 1
- Big-O Cheat Sheet
- 编译emule 源代码error C2520: conversion from unsigned __int64 to double not implemented 安装VS6SP5+VCPP5解决问题
- Eclipse错误解决办法:Conversion to Dalvik format failed with error 1
- import excel/spreedsheet to testlink
- Server Resin 4.0 at localhost was unable to start within 240 seconds(Port:80)
- andriod中如果引入jar包错误出现Conversion to Dalvik format failed with error 1