Platform SDK: DirectX

Step 1.4: Create a New Surface for the Texture

[C++]

This section pertains only to application development in Visual Basic. See Direct3D Immediate Mode C/C++ Tutorials.

[Visual Basic]

Before creating the texture surface object, you should turn on texture management for the device with the DDSCAPS2_TEXTUREMANAGE flag:

    ddsd.ddsCaps.lCaps = DDSCAPS_TEXTURE
    ddsd.ddsCaps.lCaps2 = DDSCAPS2_TEXTUREMANAGE
    ddsd.lTextureStage = 0

Also, by setting the control flag DDSCAPS_TEXTURE, you inform the system that the surface describes a texture surface.

For more information on texture management, see Automatic Texture Management.

Now that automatic texture management has been enabled, and you have set the DDSCAPS_TEXTURE flag, you can create a new surface for the texture and return it:

    Set ddsTexture = g_dd.CreateSurfaceFromFile(sFile, ddsd)
    
    ' Return the newly created texture.
    Set CreateTextureSurface = ddsTexture

For more information on texture surfaces, see Texture Surface Objects.

Since you have created a new surface for your texture, you can use that texture during rendering of the primitives. This step is done in Step 2: Render a Textured Primitive.