Textures under the IDirect3D3 interface are DirectDraw surfaces, just as textures are when programming with texture handles. Therefore, the first step in obtaining a texture interface pointer is to create a DirectDraw surface with the DDSCAPS_TEXTURE capability set. See Creating Surfaces , DDSCAPS, and DDSCAPS2.
Once the surface is created, your application can retrieve a pointer to its texture interface. To do so, simply query the surface for its IDirect3DTexture2 interface. (If you created the texture with the DDSCAPS_ALLOCONLOAD flag, your application must also load the texture by invoking the IDirect3DTexture2::Load method before you can place any images in the texture.)
The following code fragment illustrates the process of creating a texture from an existing DirectDrawSurface object's interface. It also demonstrates how to load a texture.
// This code fragment assumes that lpDDS is a valid pointer to
// a DirectDraw surface that was created with the DDSCAPS_TEXTURE
// surface capability, and that lpD3D3 is a valid pointer to
// an IDirect3D3 interface.
LPDIRECT3DTEXTURE2 lpD3DTexture2;
// Get the texture interface.
lpDDS->QueryInterface(IID_IDirect3DTexture2, (void**)&lpD3DTexture2);
// Load the texture.
// (This only applies to textures that were
// created with the DDSCAPS_ALLOCONLOAD flag.
lpD3DTexture2->Load(lpD3DTexture2);
Note Loading a texture with the IDirect3DTexture2::Load method allocates the memory for the texture. Once this is done, a bitmap may be loaded from a resource or a file onto the surface associated with the texture by using DirectDraw blitting methods. (In the event that blitting isn't supported, you can access the surface memory directly by using the DirectDraw IDirectDrawSurface4::Lock and IDirectDrawSurface4::Unlock methods.)