DirectX SDK |
The information in this section pertains only to applications written in C and C++. See Direct3D Immediate Mode Visual Basic Tutorials.
Before creating the texture surface object, you should turn on texture management for the device. Note that you are using the texture manage attribute, so that Direct3D will take care of the complicated details of texture management.
You can turn on texture management for hardware devices with the following code fragment:
if( ddDesc.deviceGUID == IID_IDirect3DHALDevice ) ddsd.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; else if( ddDesc.deviceGUID == IID_IDirect3DTnLHalDevice ) ddsd.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; else ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
For more information on texture management, see Automatic Texture Management.
Now, use ddDesc (a D3DDEVICEDESC7 structure containing a description of the rendering device) to check device capabilities. You should adjust the width and the height of the surface description, if the driver requires it:
if( ddDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2 ) { for( ddsd.dwWidth=1; dwWidth>ddsd.dwWidth; ddsd.dwWidth<<=1 ); for( ddsd.dwHeight=1; dwHeight>ddsd.dwHeight; ddsd.dwHeight<<=1 ); } if( ddDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY ) { if( ddsd.dwWidth > ddsd.dwHeight ) ddsd.dwHeight = ddsd.dwWidth; else ddsd.dwWidth = ddsd.dwHeight; }
Now that you have enabled texture management and ensured that the surface description is compatible with the driver, you can enumerate the texture formats. This process is defined in Step 1.4: Enumerate the Texture Formats.