MTextureManager Class Reference

This reference page is linked to from the following overview topics: Extension for Autodesk Maya 2013, 2.4 Textures and Texture Manager, 3.2 The Renderer, 3.5 Draw Overrides.



Detailed Description

Class which manages texture.

Examples:

hwPhongShader.cpp.

#include <MTextureManager.h>

List of all members.

Public Member Functions

MStatus addImagePath (const MString &path)
 This method adds an additional search path for looking up images on disk.
MStatus imagePaths (MStringArray &paths) const
 The current set of image search paths can be retrieved using this method.
MTextureacquireTexture (const MString &filePath, int mipmapLevels=0)
 Ask the renderer to acquire a hardware texture.
MTextureacquireTexture (const MString &textureName, const MPlug &plug, int width, int height, bool generateMipMaps=true)
 Ask the renderer to acquire a hardware texture.
MTextureacquireTexture (const MString &textureName, const MHWRender::MTextureDescription &textureDesc, const void *pixelData, bool generateMipMaps=true)
 Ask the renderer to acquire a hardware texture by providing a texture description and a block of system memory data which matches the texture description.
void releaseTexture (MTexture *texture) const
 Deletes the MTexture and releases the reference to the underlying texture which is held by the MTexture object.
MStatus saveTexture (MTexture *texture, const MString &filePath)
 Ask the renderer to save a hardware texture to disk.

Static Public Member Functions

static const char * className ()
 Returns the name of this class.

Member Function Documentation

MStatus addImagePath ( const MString path)

This method adds an additional search path for looking up images on disk.

Parameters:
[in]pathImage search path.
Returns:
Status code
Status Codes:
MStatus imagePaths ( MStringArray paths) const

The current set of image search paths can be retrieved using this method.

Parameters:
[out]pathsA string array to be filled in with image path strings. Each array element will contain one image path string.
Returns:
Status code
Status Codes:
MTexture * acquireTexture ( const MString textureName,
int  mipmapLevels = 0 
)

Ask the renderer to acquire a hardware texture.

The input data is read from an image file.

The renderer will add 1 reference to this texture on creation. If the texture has already been acquired then no new texture will be created, and a new reference will be added. To release the reference, call releaseTexture().

Parameters:
[in]textureNameImage file name
[in]mipmapLevelsMipmap generation levels
  • "mipmapLevels==0" == create and populate all possible levels, using file contents if available
  • "mipmapLevels>1" == create the specified number of levels, using file contents if available
  • "mipmapLevels==1" == no mipmap chain
Returns:
MTexture pointer
Examples:
hwPhongShader.cpp.
MTexture * acquireTexture ( const MString textureName,
const MPlug plug,
int  width,
int  height,
bool  generateMipMaps = true 
)

Ask the renderer to acquire a hardware texture.

The input data is a plug

The renderer will add 1 reference to this texture on creation. If the texture has already been acquired then no new texture will be created, and a new reference will be added. To release the reference, call releaseTexture().

Parameters:
[in]textureNameName of the texture to create
[in]plugPlug which is attached with a texture
[in]widthWidth of the texture
[in]heightHeight of the texture
[in]generateMipMapsGenerate the mipmap levels
Returns:
MTexture pointer
MTexture * acquireTexture ( const MString textureName,
const MHWRender::MTextureDescription textureDesc,
const void *  pixelData,
bool  generateMipMaps = true 
)

Ask the renderer to acquire a hardware texture by providing a texture description and a block of system memory data which matches the texture description.

The renderer will add 1 reference to this texture on creation. If the texture has already been acquired then no new texture will be created, and a new reference will be added. To release the reference, call releaseTexture().

The creation of a new texture involves copying the block of system memory data to a hardware texture. The caller is free to deallocate the system memory as the renderer itself does not keep any references to it.

Parameters:
[in]textureNameName of the texture to create
[in]textureDescDescription of the texture
[in]pixelDataBlock of system memory data which matches the texture description
[in]generateMipMapsGenerate the mipmap levels
Returns:
MTexture pointer
void releaseTexture ( MTexture texture) const

Deletes the MTexture and releases the reference to the underlying texture which is held by the MTexture object.

After calling this method it is an error to try to use the MTexture and attempting to do so will result in instability. The underlying texture might not be deleted immediately if it is in use by the renderer.

Parameters:
[in]textureThe texture to release
Examples:
hwPhongShader.cpp.
MStatus saveTexture ( MTexture texture,
const MString filePath 
)

Ask the renderer to save a hardware texture to disk.

Parameters:
[in]textureMTexture pointer
[in]filePathImage file name
Returns:
Status code
Status Codes:
const char * className ( ) [static]

Returns the name of this class.

Returns:
Name of this class.

MTextureManager MTextureManager MTextureManager MTextureManager MTextureManager MTextureManager MTextureManager MTextureManager MTextureManager MTextureManager
MTextureManager MTextureManager MTextureManager MTextureManager MTextureManager MTextureManager MTextureManager MTextureManager MTextureManager MTextureManager