Texture Interface Pointers

[Previous] [Next]

As we've discussed, the IDirect3D7 interface allows you to create and apply textures that are exposed through the IDirectDrawSurface7 interface. You can obtain a pointer to a texture surface interface by creating a DirectDraw Surface object with the DDSCAPS_TEXTURE capability set. After creating the surface, you can use the methods of the surface interface to modify its data. You can also use the IDirect3DDevice7::Load method to load an image into the texture. You should load textures into video memory using this method rather than using blit operations to achieve the best speed for your application.

The IDirect3DDevice7::SetTexture method assigns textures to the set of current textures. This is the declaration for the SetTexture method:

 HRESULT IDirect3DDevice7::SetTexture(     DWORD dwStage,     LPDIRECTDRAWSURFACE7 lpTexture ); 

ParameterDescription
dwStageStage identifier that the texture will be set to; devices can currently have up to eight set textures (valid ranges are 0 to 7)
lpTextureAddress of the IDirectDrawSurface7 interface for the texture you're setting

The IDirect3DDevice7::SetTexture method takes a value from 0 through 7 as its first parameter, indicating which texture stage you're assigning, and it takes the texture interface pointer as its second parameter. For mipmapping, you need to specify the surface pointer for the top level of the mipmap. This is the code for setting the main texture stage to a particular texture:

 // Set the texture. m_pd3dDevice->SetTexture(0, m_ptexTexture); 

This code assigns the second texture stage to a particular texture (for operations such as texture blending):

 // // Set the second texture. m_pd3dDevice->SetTexture(1, m_pd3dTexture); 



Inside Direct3D
Inside Direct3D (Dv-Mps Inside)
ISBN: 0735606137
EAN: 2147483647
Year: 1999
Pages: 131

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net