Applications use the methods of the IDirect3DRMTexture interface to work with textures, which are rectangular arrays of pixels. This section is a reference to the methods of this interface. For a conceptual overview, see IDirect3DRMTexture and IDirect3DRMTexture2 Interfaces.
To avoid unnecessary delays when creating textures, hold onto textures you want to use again, instead of creating them each time they're needed. For optimal performance, use a texture surface format that is supported by the device you are using. This will avoid a costly format conversion when the texture is created and any time it changes.
See the remarks in IDirect3DRM::LoadTexture for an example showing how to keep a reference to textures loaded in a texture callback through IDirect3DRM::LoadTexture.
The methods of the IDirect3DRMTexture interface can be organized into the following groups:
| Color | GetColors |
| SetColors | |
| Decals | GetDecalOrigin |
| GetDecalScale | |
| GetDecalSize | |
| GetDecalTransparency | |
| GetDecalTransparentColor | |
| SetDecalOrigin | |
| SetDecalScale | |
| SetDecalSize | |
| SetDecalTransparency | |
| SetDecalTransparentColor | |
| Images | GetImage |
| Initialization | InitFromFile |
| InitFromResource | |
| InitFromSurface | |
| Renderer notification | Changed |
| Shading | GetShades |
| SetShades |
The IDirect3DRMTexture interface, like all Component Object Model (COM) interfaces, inherits the IUnknown interface methods. The IUnknown interface supports the following three methods:
| AddRef |
| QueryInterface |
| Release |
In addition, the IDirect3DRMTexture interface inherits the following methods from the IDirect3DRMObject interface:
| AddDestroyCallback |
| Clone |
| DeleteDestroyCallback |
| GetAppData |
| GetClassName |
| GetName |
| SetAppData |
| SetName |
The Direct3DRMTexture object is obtained by using the IDirect3DRM::CreateTexture method.
Informs the renderer that the application has changed the pixels or the palette of a texture.
HRESULT Changed(
BOOL bPixels,
BOOL bPalette
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible errors, see Direct3D Retained Mode Return Values.
Retrieves the maximum number of colors used for rendering a texture.
DWORD GetColors( );
Returns the number of colors.
This method returns the number of colors that the texture has been quantized to, not the number of colors in the image from which the texture was created. Consequently, the number of colors that are returned usually matches the colors that were set by using the IDirect3DRM::SetDefaultTextureColors methodunless you used the IDirect3DRMTexture::SetColors method explicitly to change the colors for the texture.
Retrieves the current origin of the decal.
HRESULT GetDecalOrigin(
LONG * lplX,
LONG * lplY
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible errors, see Direct3D Retained Mode Return Values.
IDirect3DRMTexture::SetDecalOrigin
Retrieves the scaling property of the given decal.
DWORD GetDecalScale( );
Returns the scaling property if successful, or -1 otherwise.
IDirect3DRMTexture::SetDecalScale
Retrieves the size of the decal.
HRESULT GetDecalSize(
D3DVALUE *lprvWidth,
D3DVALUE *lprvHeight
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible errors, see Direct3D Retained Mode Return Values.
IDirect3DRMTexture::SetDecalSize
Retrieves the transparency property of the decal.
BOOL GetDecalTransparency( );
Returns TRUE if the decal has a transparent color, FALSE otherwise.
IDirect3DRMTexture::SetDecalTransparency
Retrieves the transparent color of the decal.
D3DCOLOR GetDecalTransparentColor( );
Returns the value of the transparent color.
IDirect3DRMTexture::SetDecalTransparentColor
Retrieves an address of the image that the texture was created with. Returns a NULL pointer if the current texture was created with a DirectDraw surface.
D3DRMIMAGE * GetImage( );
Returns the address of the D3DRMIMAGE structure that the current texture was created with.
Retrieves the number of shades used for each color in the texture when rendering.
DWORD GetShades( );
Returns the number of shades.
Initializes a texture by using the information in a given file.
HRESULT InitFromFile(
const char *filename
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible errors, see Direct3D Retained Mode Return Values.
You must have created the texture to be initialized using the IDirect3DRM::CreateObject method.
IDirect3DRMTexture::InitFromResource, IDirect3DRMTexture::InitFromSurface
Initializes a Direct3DRMTexture object from a specified resource.
HRESULT InitFromResource(
HRSRC rs
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible errors, see Direct3D Retained Mode Return Values.
IDirect3DRMTexture::InitFromFile, IDirect3DRMTexture::InitFromSurface
Initializes a texture by using the data from a given DirectDraw surface.
HRESULT InitFromSurface(
LPDIRECTDRAWSURFACE lpDDS
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible errors, see Direct3D Retained Mode Return Values.
IDirect3DRMTexture::InitFromFile, IDirect3DRMTexture::InitFromResource
Sets the maximum number of colors used for rendering a texture. This method is required only in the ramp color model.
HRESULT SetColors(
DWORD ulColors
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible errors, see Direct3D Retained Mode Return Values.
Sets the origin of the decal as an offset from the top left of the decal.
HRESULT SetDecalOrigin(
LONG lX,
LONG lY
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible errors, see Direct3D Retained Mode Return Values.
The decal's origin is mapped to its frame's position when rendering. For example, the origin of a decal of a cross would be set to the middle of the decal, and the origin of an arrow pointing down would be set to midway along the bottom edge.
This method is also used to add a decal origin key to a Direct3DRMTextureInterpolator object.
IDirect3DRMTexture::GetDecalOrigin
Sets the scaling property for a decal.
HRESULT SetDecalScale(
DWORD dwScale
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible errors, see Direct3D Retained Mode Return Values.
IDirect3DRMTexture::GetDecalScale
Sets the size of the decal to be used if the decal is being scaled according to its depth in the scene.
HRESULT SetDecalSize(
D3DVALUE rvWidth,
D3DVALUE rvHeight
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible errors, see Direct3D Retained Mode Return Values.
This method is also used to add a decal size key to a Direct3DRMTextureInterpolator object.
IDirect3DRMTexture::GetDecalSize
Sets the transparency property of the decal.
HRESULT SetDecalTransparency(
BOOL bTransp
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible errors, see Direct3D Retained Mode Return Values.
IDirect3DRMTexture::GetDecalTransparency
Sets the transparent color for a decal.
HRESULT SetDecalTransparentColor(
D3DCOLOR rcTransp
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible errors, see Direct3D Retained Mode Return Values.
This method is also used to add a decal transparent color key to a Direct3DRMTextureInterpolator object.
IDirect3DRMTexture::GetDecalTransparentColor
Sets the maximum number of shades to use for each color of the texture when rendering. This method is required only in the ramp color model.
HRESULT SetShades(
DWORD ulShades
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible errors, see Direct3D Retained Mode Return Values.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.