How does XNA framework 4.0 cross platforms

来源:互联网 发布:龙发半包价格 知乎 编辑:程序博客网 时间:2024/06/05 18:35

XNA Framework is an intermediate platform between applications and operation systems. It targets on helping developers to migrate their applications across multiple operation systems.  XNA Framework 4.0 is dependent on the native implementation of .Net Framework 4.0 on Windows or .Net Compact Framework 4.0 for Xbox. It can be deployed on Windows Phone 7, Xbox 360, and Windows OS (includes XP, Vista, & Win7). To make the clearance of how it archives that, we can first go to look at the deployment of its binaries.

In here, I installed a XNA Game Studio 4.0 on Win7 AMD64 ENU platform with Visual Studio 2010 Ultimate preinstalled. (You can download XNA Game Studio 4.0 for free at http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9ac86eca-206f-4274-97f2-ef6c8b1f478f)  

After the installation, we can see a folder “Microsoft XNA” was created in “Program Files” folder. Open this folder and let’s focus on the location: C:/Program Files (x86)/Microsoft XNA/XNA Game Studio/v4.0/References (take the path on my machine for example). You would see two subfolders in here: “Windows” and “Xbox360”. If we compare the contents of these two folders you may see they contain quite similar groups of binaries. See table1.

Table1

../Windows/x86/

../Xbox360/

Microsoft.Xna.Framework.dll

Microsoft.Xna.Framework.Avatar.dll

Microsoft.Xna.Framework.***.dll

 

Microsoft.Xna.Framework.Content.Pipeline.dll

Microsoft.Xna.Framework.Content.Pipeline.***.dll

N/A

N/A

N/A

Microsoft.Xna.Framework.dll

Microsoft.Xna.Framework.Avatar.dll

Microsoft.Xna.Framework.***.dll

 

N/A

N/A

mscorlib.dll

System.dll

System.***.dll

 

We can see the Windows folder contains a series of “Microsoft.Xna.Framework.Content.Pipeline.dll” related binaries which was not included in Xbox360 folder. Similarly, Xbox360 folder contains some of “system.dll” related binaries (these binaries are different from those of which have the same name but located in .net framework folders). Additionally, if you compare the same named binaries in above two columns, you may find they are actually different. Now, you may start to think XNA Framework 4.0 might be trying to provide a uniform named API system. Thus, developers just have to change the referred binaries of the project for platform migration. Let’s try to find out some evidences for our guess.

 Since we have installed XNA Game Studio 4.0, Visual Studio 2010 now has six brand new project templates under the type of “Visual C#”->”XNA Game Studio 4.0”.(Pic1) Let’s select “Windows Game (4.0)” to create a windows game solution.

Pic1

http://hi.csdn.net/attachment/201101/11/4333508_12947497277y7e.jpg

After the creation you can see the solution has two projects in Solution Explorer. (Pic2)

Pic2

http://hi.csdn.net/attachment/201101/11/4333508_12947500047Cz9.jpg

The first project is the main project named “WindowsGame1”. It has a folder named “Content Reference”. The only element of the “Content Reference” is the referring of the second project “WindowsGame1Content”. Regardless why we got these two projects, let’s take a look at the references first.Table2 shows the preset references for both solutions create by template types “Windows Game (4.0) and “Xbox 360 Game (4.0)”.

·        Binaries highlighted in red refer to .net framework folder. ( C:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/.NETFramework/v4.0/Profile/Client)

·        Binaries highlighted in green refer to the “Windows” subfolder under the XNA Framework’s references folder. (C:/Program Files (x86)/Microsoft XNA/XNA Game Studio/v4.0/References/Windows/x86)

·        Binaries highlighted in yellow refer to the “Xbox360” subfolder under the XNA Framework’s references folder. (C:/Program Files (x86)/Microsoft XNA/XNA Game Studio/v4.0/References/Xbox360)

Table2

Platform

Windows

XBox

Game references

mscorlib

System

System.Core

System.Net

System.Xml

System.Xml.Linq

 

Microsoft.Xna.Framework.dll

Microsoft.Xna.Framework.Avatar.dll

Microsoft.Xna.Framework.Game.dll

Microsoft.Xna.Framework.GamerServices.dll

Microsoft.Xna.Framework.Graphics.dll

Microsoft.Xna.Framework.Input.Touch.dll

Microsoft.Xna.Framework.Net.dll

Microsoft.Xna.Framework.Storage.dll

Microsoft.Xna.Framework.Video.dll

Microsoft.Xna.Framework.Xact.dll

mscorlib

System

System.Core

System.Net

System.Xml

System.Xml.Linq

 

Microsoft.Xna.Framework.dll

Microsoft.Xna.Framework.Avatar.dll

Microsoft.Xna.Framework.Game.dll

Microsoft.Xna.Framework.GamerServices.dll

Microsoft.Xna.Framework.Graphics.dll

Microsoft.Xna.Framework.Input.Touch.dll

Microsoft.Xna.Framework.Net.dll

Microsoft.Xna.Framework.Storage.dll

Microsoft.Xna.Framework.Video.dll

Microsoft.Xna.Framework.Xact.dll

 

GameContent references

Microsoft.Xna.Framework.Content.Pipeline.dll

Microsoft.Xna.Framework.Content.Pipeline.AudioImporters.dll

Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll

Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll

Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll

Microsoft.Xna.Framework.Content.Pipeline.VideoImporters.dll

Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll

Microsoft.Xna.Framework.Content.Pipeline.dll

Microsoft.Xna.Framework.Content.Pipeline.AudioImporters.dll

Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll

Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll

Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll

Microsoft.Xna.Framework.Content.Pipeline.VideoImporters.dll

Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll

 

If we go through the content of the above paths highlighted in green and yellow, we can see that all binaries under their corresponding paths are referred in the project by default, except “Microsoft.Xna.Framework.Input.Touch.dll” and “Microsoft.Xna.Framework.Content.Pipeline.dll”. We would try to find the reason of this exception in the future. Now, let’s focus on the general situation.

 

One finding from the table is references of the content projects are the same whatever you are in windows or Xbox game project. The other finding is the main projects of windows game and Xbox game are using their own binaries. While windows game project can directly use system assemblies provided by .Net Framework, Xbox game has to provide system assemblies by itself.

 

Things become clear now. We don’t have a unified framework act as .Net Framework does to allow an application running on any OS once it has .Net Framework been installed. But, we might be able to code the application once and build multiple applications for multiple platforms with just refer to different series of binaries without much code changes in the project. To approve our second guessing, we should go into the coding and try to build a project to make the verification, which would be discussed in the next time.