Microsoft DirectX 8.1 (Visual Basic)

D3DX8.CreateTexture

Creates an empty texture, adjusting the calling parameters as needed.

object.CreateTexture( _ 
    Device As Direct3DDevice8, _ 
    Width As Long, _ 
    Height As Long, _ 
    MipLevels As Long, _ 
    Usage As Long, _ 
    PixelFormat As CONST_D3DFORMAT, _ 
    Pool As CONST_D3DPOOL) As Direct3DTexture8

Parts

object
Object expression that resolves to a D3DX8 object.
Device
Direct3DDevice8 object representing the device to be associated with the texture.
Width
Width of the top-level of the texture, in pixels. The pixel dimensions of subsequent levels are the truncated value of half of the previous level's pixel dimension (independently). Each dimension clamps at a size of 1 pixel. Thus, if the division by 2 results in 0 (zero), 1 is taken instead. If this value is set to 0, then a value of 1 is used. D3DX_DEFAULT can also be used, see Remarks.
Height
Height of the top-level of the texture, in pixels. The pixel dimensions of subsequent levels are the truncated value of half of the previous level's pixel dimension (independently). Each dimension clamps at a size of 1 pixel. Thus, if the division by 2 results in 0 (zero), 1 is taken instead. If this value is set to 0, then a value of 1 is used. D3DX_DEFAULT can also be used, see Remarks.
MipLevels
The number of levels in the texture. If this is zero, Microsoft® Direct3D® generates all texture sub-levels down to 1×1 pixels.
Usage
0 or the D3DUSAGE_RENDERTARGET member of the CONST_D3DUSAGEFLAGS enumeration. Specifying D3DUSAGE_RENDERTARGET indicates that the surface is to be used as a render target. The resource can be passed to the NewRenderTarget parameter of the SetRenderTarget method. If D3DUSAGE_RENDERTARGET is specified, the application should check that the device supports this operation by calling Direct3D8.CheckDeviceFormat.
PixelFormat
Member of the CONST_D3DFORMAT enumeration, describing the requested pixel format for the texture. The returned texture might have a format different from that specified by PixelFormat. Applications should check the format of the returned texture.
Pool
Member of the CONST_D3DPOOL enumeration, describing the memory class into which the texture should be placed.

Return Values

Direct3DTexture8 object representing the created texture.

Error Codes

If the method fails, an error is raised and Err.Number can be set to one of the following values.

D3DERR_INVALIDCALL
D3DERR_NOTAVAILABLE
D3DERR_OUTOFVIDEOMEMORY
E_OUTOFMEMORY

For information on trapping errors, see the Microsoft® Visual Basic® Error Handling topic.

Remarks

If the Height and Width parameters are both set to D3DX_DEFAULT, a value of 256 is used for both. If only one of these are set to D3DX_DEFAULT, then the texture will be square with the other dimensional parameter specifying both the height and width.

Internally, D3DX8.CreateTexture uses D3DX8.CheckTextureRequirements to adjust the calling parameters. Therefore, calls to D3DX8.CreateTexture often succeed where calls to Direct3DDevice8.CreateTexture fail.