How to: Convert Desktop Direct3D ApplicationsĀ
You can modify an existing managed Direct3D application developed for a desktop computer to run on a mobile device. The changes you need to make are in the following areas:
References to components and namespaces.
Changes to the Device constructor and constructors of other objects.
Removal of unsupported functionality.
Resource optimizations. For information about developing mobile Direct3D applications that use constrained resources effectively, see Managing Device Resources.
Note |
---|
Managed Direct3D mobile applications require Windows Mobile version 5.0 software for Pocket PCs and Smartphones. See External Resources for the .NET Compact Framework for information about Windows Mobile software and SDKs. |
To convert a desktop Direct3D application
In Microsoft Visual Studio 2005, create a Smart Device application using a template that targets Microsoft Windows Mobile version 5.0 software for Pocket PC or Windows Mobile version 5.0 software for Smartphone.
Add a reference to the Microsoft.WindowsMobile.DirectX component to your project.
Depending on your programming language, add an Imports or Using statement for these namespaces:
Copy code from your desktop application and modify as required.
To modify the constructors
Constructing the Device object requires different parameters in a mobile application and requires the following changes:
Hardware is not a supported DeviceType value. Change it to Default.
SoftwareVertexProcessing is not a supported CreateFlags value. Change it to None.
Use a memory pool that is supported on the device. The TextureLoader and Mesh constructors check capability bits to ensure that the objects are created in a memory pool that exists, but all other constructors do not. For information about the appropriate capability bits to ensure that a memory pool is usable on the device, see Managing Device Resources.
To remove unsupported functionality
Remove members that do not exist in the .NET Compact Framework, such as members only in the desktop version of the VertexFormats enumeration.
Remove calls to the Mesh.Load methods. Managed Direct3D Mobile does not include a loader for .X files. The Direct3D Mobile Meshes Sample demonstrates how to load meshes using a custom .md3dm file format and contains code that converts .X files to .md3dm files and then loads them. Note that the .md3dm file format is not component of the .NET Compact Framework, but an example of how to load a mesh given that loading .X files is not supported.
Remove pixel and vertex shaders.
Ensure color depth support. Some mobile device drivers may not offer high color depths for screen resolution or textures because of tight memory restrictions. Ensure that drivers support your color depth requirements or make changes as necessary.
Remove code that refers to the following unsupported desktop Direct3D types:
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