代码改变世界

Windows Phone 7 XNA开发之关于图形的配置

2012-03-29 11:29  张剑  阅读(514)  评论(0编辑  收藏  举报

 相对于以前的XNA开发,在Windows Phone 7的XNA项目中关于图形的开发有了一些新的变化需要我们关注,否则会出现一些不必要的麻烦。

我们知道XNA游戏开发可以针对不同的平台进行,比如说Windows Phone 7或Xbox360之类的不同硬件,程现的图形效果有着较大的差距,所以在4.0中就有了profile(配置)。

配置有两种方式:ReachHiDef,其中HiDef是针对高端硬件的,比如Xbox360之类的硬件,而Reach则是针对底端硬件,如:Windows Phone 7手机XNA开发的。在Microsoft Visual Studio 2010创建Windows Phone XNA项目时,默认会设置profileReach方式而且我们无法选择:

而在创建Windows或Xbox360的游戏项目后,在项目属性中,可以看到游戏配置是可以修改的:

有的时候如果在创建一个Windows或xbox360项目后,选用HiDef模式会出现以下错误:

没有找到合适的显卡。

找不到支持XNA Framework HiDef属性的Direct3D设备。
请验证相应的显卡已经安装。
确认桌面没有被锁定,没有其它的应用程序运行在全屏模式下。
不要在远程桌面下或是做为一个系统服务运行。

检查显示属性,确认硬件加速已经被设置为完全。

因为如果你的项目设置了HiDef配置,但是你的计算机或硬件并不支持Shader model3.0(SM3.0技术是DirectX 9.0C级别显卡全面支持的一项特效)与DirectX 10。那么就会出现以上的错误。

关于Reach与HiDef的比较:

 

 

Reach

HiDef

Supported platforms
(支持平台) 
Windows Phone 7 系列, Xbox 360, 和任何安装有DirectX 9 GPU并支持至少shader model 2.0的Windows PC Xbox 360, 和任何安装有DirectX 10 GPU的Windows PC
Shader model 2.0  (但是 Windows Phone 不支持自定义shaders) 3.0+  (Xbox 360 支持自定义shader扩展,例如vfetch, 但不支持Windows)
Max texture size
(最大纹理))
2048 4096
Max cubemap size
(最大多面体) 
512 4096
Max volume texture size
(最大立体纹理) 
不支持 256
Non power of two textures Conditional: cannot use wrap addressing mode, mipmaps, or DXT compression when the size is not a power of two 支持
Non power of two cubemaps 不支持 支持
Non power of two volume textures Volume textures are not supported 支持
Max primitives per draw call 65535 1048575
Index buffer formats
(缓冲索引格式) 
16 bit 16 和 32 bit
Vertex element formats
(Vertex元素格式) 
Color, Byte4, Single, Vector2, Vector3, Vector4, Short2, Short4, NormalizedShort2, NormalizedShort4 All of the Reach formats, plus HalfVector2, HalfVector4
Texture formats
(纹理格式) 
Color, Bgr565, Bgra5551, Bgra4444, NormalizedByte2, NormalizedByte4, Dxt1, Dxt3, Dxt5 All of the Reach formats, plus Alpha8, Rg32, Rgba64, Rgba1010102, Single, Vector2, Vector4, HalfSingle, HalfVector2, HalfVector4. Floating point texture formats do not support filtering.
Vertex texture formats
(Vertex纹理格式) 
Vertex texturing is not supported Single, Vector2, Vector4, HalfSingle, HalfVector2, HalfVector4
Render target formats
(渲染目标格式) 
部分支持 (见下) 部分支持 (见下)
Multiple render targets
(多次渲染目标) 
不支持 Up to 4. Must all have the same bit depth. Supports alpha blending and independent write masks per rendertarget.
Occlusion queries 不支持 支持
Separate alpha blend 不支持 支持
Blend.SourceAlphaSaturation Only for SourceBlend, not DestinationBlend 支持
Max vertex streams 16 16
Max stream stride 255 255

 

表格来源:http://blogs.msdn.com/b/shawnhar/archive/2010/03/12/reach-vs-hidef.aspx