更新:2007 年 11 月
您可以修改现有的为桌面计算机开发的托管 Direct3D 应用程序,使之能够在移动设备上运行。您需要在以下几个方面进行更改:
- 对组件和命名空间的引用。 
- 对 Device 构造函数和其他对象的构造函数的更改。 
- 不受支持的功能的移除。 
- 资源优化。有关如何开发能够有效使用受约束资源的移动 Direct3D 应用程序的信息,请参见管理设备资源。 
| .gif) 说明: | 
|---|
| 托管 Direct3D 移动应用程序需要使用适用于 Pocket PC 和 Smartphone 的 Windows Mobile 5.0 版软件。有关 Windows Mobile 软件和 SDK 的信息,请参见 .NET Compact Framework 的外部资源。 | 
转换桌面 Direct3D 应用程序
- 在 Microsoft Visual Studio 2005 中,使用针对用于 Pocket PC 的 Microsoft Windows Mobile 5.0 版软件或针对用于 Smartphone 的 Microsoft Windows Mobile 5.0 版软件的模板创建智能设备应用程序。 
- 向您的项目添加对 Microsoft.WindowsMobile.DirectX 组件的引用。 
- 根据编程语言,为以下这些命名空间添加 Imports 或 Using 语句: 
- 从桌面应用程序复制代码并根据需要进行修改。 
修改构造函数
- 构造 Device 对象需要在移动应用程序中使用各种不同的参数,并需要进行以下更改: - Hardware 不是受支持的 DeviceType 值。请将其更改为 Default。 
- SoftwareVertexProcessing 不是受支持的 CreateFlags 值。请将其更改为 None。 
 
- 使用该设备支持的内存池。TextureLoader 和 Mesh 两个构造函数检查功能位以确保对象是在现有的内存池中创建的,但所有其他构造函数都不进行此检查。有关哪些功能位能够确保内存池在设备上可用的信息,请参见管理设备资源。 
移除不受支持的功能
- 移除 .NET Compact Framework 中不存在的成员,例如那些只存在于 VertexFormats 枚举的桌面版本中的成员。 
- 移除对 Mesh.Load 方法的调用。托管的 Direct3D Mobile 不包括 .X 文件的加载程序。Direct3D Mobile Meshes Sample(Direct3D Mobile 网格示例)演示如何使用自定义 .md3dm 文件格式加载网格,并包含将 .X 文件转换为 .md3dm 文件之后再加载这些文件的代码。请注意,.md3dm 文件格式不是 .NET Compact Framework 的组件,而只是一个示例,用于演示如何在不支持加载 .X 文件的情况下加载网格。 
- 移除像素和顶点着色器。 
- 确保颜色深度支持。某些移动设备驱动程序可能会因严格的内存限制而无法为屏幕分辨率或文理提供高颜色深度。确保驱动程序支持您的颜色深度要求,或根据需要进行更改。 
- 移除那些引用以下不受支持的桌面 Direct3D 类型的代码: - AllocateHierarchy - AnimationOutput - AnimationOutputFlags - AnimationRootFrame - AnimationSet - AttributeWeights - BandwidthTimings - BasisType - BoneCombination - BoneInfluences - Box - CacheUtilization - CallbackData - CallbackSearchFlags - CannotAttributeSortException - CannotModifyIndexBufferException - Channel - CleanType - ClipPlane - ClipPlanes - ColorOperator - CompressedAnimationSet - CompressionFlags - CompressionQuality - ConflictingRenderStateException - ConflictingTextureFilterException - ConflictingTexturePaletteException - ConstantDescription - ConstantTable - ConstantTableDescription - CubeMapFace - CubeTexture - CubeTextureRequirements - CubeMapFace - CubeTexture - CubeTextureRequirements - DeclarationMethod - DeclarationType - DeclarationTypeCaps - DeclarationUsage - DegenerateItems - DegreeType - DeviceInformation - Direct3DXException - DisplacementMap - DisplacementParameter - DriverCaps - DuplicateNamedFragmentException - Effect - EffectCompiler - EffectDefault - EffectDefaultType - EffectDescription - EffectHandle - EffectInstance - EffectPool - EffectStateManager - EventDescription - EventType - ExtendedMaterial - Fill2DTextureCallback - Fill3DTextureCallback - FormatList - FragmentDescription - FragmentLinker - Frame - FunctionDescription - FX - GammaRamp - GlyphMetricsFloat - GpuSimulatorOption - HandleAnimationCallback - ImageFileFormat - ImageInformation - Include - IncludeType - InterfaceGuid - InterfaceTimings - IntersectInformation - InvalidDataException - InvalidMeshException - IssueFlags - KeyCallback - KeyFramedAnimationSet - KeyQuaternion - KeyVector3 - Line - LinePattern - LoadedMeshHasNoDataException - LoadUserData - LockedBox - Macro - MeshContainer - MeshData - MyD3DXAllocateHierarchy - MyD3DXAnimationCallback - MyD3DXFrame - MyD3DXIncludeClass - MyD3DXLoadUserData - MyD3DXMeshContainer - MyD3DXSaveUserData - NormalMap - OutOfVideoMemoryException - ParameterClass - ParameterDescription - ParameterFlags - ParameterType - PassDescription - PatchEdge - PatchInformation - PatchMesh - PatchType - PipelineTimings - PixelShader - PixelShaderCaps - PlaybackType - Present - PropertyDescription - PrtBuffer - PrtCompressedBuffer - PrtEngine - PrtEngineCallback - PrtSplitMeshClusterData - PrtSplitMeshVertexData - Query - QueryType - RasterStatus - RectanglePatchInformation - RegisterSet - RenderStates - RenderTargetsMax - RenderToEnvironmentDescription - RenderToEnvironmentMap - RenderToSurface - RenderToSurfaceDescription - ResourceManager - ResourceStats - SamplerStageStates - SamplerStateManager - SamplerStateManagerCollection - SaveUserData - ScaleRotateTranslate - Semantic - ShaderConstantInformation - ShaderConstantTable - ShaderDebugInformation - ShaderFileInformation - ShaderFlags - ShaderInstructionInformation - ShaderLoader - ShaderStructMemberInformation - ShaderTypeInformation - ShaderVariableInformation - ShaderWriteInformation - SimplificationMesh - SkinInformation - SkinMesh - SkinningNotSupportedException - SphericalHarmonicMaterial - SphericalHarmonics - StageTimings - StateBlock - StateBlockType - SurfaceLoader - TextureGutterHelper - TextureShader - TextureStageStates - TooManyInfluencesException - TooManyOperationsException - TrackDescription - TransitionType - TrianglePatchInformation - UnsupportedAlphaArgumentException - UnsupportedAlphaOperationException - UnsupportedColorArgumentException - UnsupportedColorOperationException - UnsupportedFactorValueException - UnsupportedTextureFilterException - VertexCache - VertexDeclaration - VertexElement - VertexFormatCaps - VertexShader - VertexShaderCaps - VertexStats - Volume - VolumeDescription - VolumeLoader - VolumeTexture - VolumeTextureRequirements - WasStillDrawingException - WeldEpsilons - WeldEpsilonsFlags - Wrap - WrongTextureFormatException - XFile - XFileData - XFileErrorCodes - XFileFormat - XFileGuid - XFileManager - XFileSaveData