HOW TO:轉換桌面 Direct3D 應用程式

更新:2007 年 11 月

您可以將針對桌上型電腦開發的現有 Managed Direct3D 應用程式修改為可以在行動裝置上執行。您需要在下列區域中進行變更:

  • 元件和命名空間的參考

  • Device 建構函式和其他物件之建構函式的變更

  • 移除不支援函式

  • 資源最佳化。如需有效率使用受限資源開發行動 Direct3D 應用程式的資訊,請參閱管理裝置資源

注意事項:

Managed Direct3D Mobile 應用程式需要適用於 Pocket PC 和 Smartphone 的 Windows Mobile 5.0 版軟體。如需 Windows Mobile 軟體和 SDK 的詳細資訊,請參閱 .NET Compact Framework 的外部資源

若要轉換桌面 Direct3D 應用程式

  1. 在 Microsoft Visual Studio 2005 中,使用以 Microsoft Windows Mobile for Pocket PC 5.0 版軟體,或是 Windows Mobile for Smartphone 5.0 版軟體為目標的範本,建立智慧型裝置應用程式。

  2. 對您的專案加入 Microsoft.WindowsMobile.DirectX 元件的參考。

  3. 根據您的程式語言,將這些命名空間加入 Imports 或 Using 陳述式:

  4. 從您的桌面應用程式複製程式碼,並視需要進行修改。

若要修改建構函式

  1. 建構 Device 物件需要在行動應用程式中具有不同參數,並需要下列變更:

    • Hardware 不是支援的 DeviceType 值。請將此值變更為 Default

    • SoftwareVertexProcessing 不是支援的 CreateFlags 值。請將此值變更為 None

  2. 使用裝置所支援的記憶體集區。TextureLoaderMesh 建構函式會檢查功能位元,以確認物件在已有的記憶體集區中建立,不過其他所有建構函式都不會這樣做。如需運用功能位元來確認能在裝置上使用記憶體集區的資訊,請參閱管理裝置資源

若要移除不支援的功能

  1. 移除不存在於 .NET Compact Framework 的成員,例如只在 VertexFormats 列舉型別桌面板本中的成員。

  2. 移除 Mesh.Load 方法的呼叫。Managed Direct3D Mobile 不包含 .X 檔案的載入器。Direct3D Mobile 範例示範如何使用自訂的 .md3dm 檔案格式載入網狀結構,範例中還包含可將 .X 檔案轉換為 .md3dm 檔案然後再載入這些檔案的程式碼。請注意,.md3dm 檔案格式不是 .NET Compact Framework 的元件;它只是在不支援載入 .X 檔案時的情況下,應該如何載入網狀結構的範例。

  3. 移除像素和頂點著色器。

  4. 確認色彩深度支援。由於嚴格的記憶體限制,部分行動裝置驅動程式可能不會對螢幕解析度或紋理提供高彩深度。請確認驅動程式支援您的色彩深度需求,或是視需要進行變更。

  5. 移除參考下列不支援桌面 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

請參閱

其他資源

.NET Compact Framework 中的 Mobile Direct3D 程式設計