3ds Max C++ API Reference
TextureHandle Class Reference

This is texture class to support texture for material, such as TextureMaterialHandle. More...

#include <TextureHandle.h>

+ Inheritance diagram for TextureHandle:

Public Member Functions

GraphicsDriverAPI TextureHandle ()
 
GraphicsDriverAPI TextureHandle (const TextureHandle &from)
 
GraphicsDriverAPI TextureHandleoperator= (const TextureHandle &from)
 
virtual GraphicsDriverAPI ~TextureHandle ()
 
GraphicsDriverAPI bool Initialize (size_t width, size_t height, TargetFormat format)
 Initialize the instance of a 2D texture. More...
 
GraphicsDriverAPI bool Initialize (TextureType type, size_t width, size_t height, size_t depth, size_t slice, size_t mipmaplevels, TargetFormat format, ResourceUsage usage)
 Initialize the instance of specified type texture. More...
 
GraphicsDriverAPI bool Initialize (const MSTR &filename)
 Initialize the instance of texture from file. More...
 
GraphicsDriverAPI bool WriteOnlyLockRectangle (UINT subTargetIndex, LockedRect &lockedRect, CONST RECT *pRectangle)
 locking the Texture Target makes the target writable. More...
 
GraphicsDriverAPI bool WriteOnlyUnlockRectangle ()
 Unlocks a rectangle on a texture resource. More...
 
GraphicsDriverAPI size_t GetSubTargetCount ()
 Get number of sub-targets. More...
 
GraphicsDriverAPI TargetHandle GetSubTarget (size_t subIndex)
 Get sub target of the texture. More...
 
GraphicsDriverAPI void SetSize (size_t width, size_t height, size_t depth)
 Set the size of the texture. More...
 
GraphicsDriverAPI void SetAutoGenerateMipMaps (bool value)
 Set whether require auto-generate mipmaps. More...
 
GraphicsDriverAPI bool GetAutoGenerateMipMaps () const
 Get whether auto-generate mipmaps. More...
 
- Public Member Functions inherited from BaseRasterHandle
GraphicsDriverAPI BaseRasterHandle ()
 
GraphicsDriverAPI BaseRasterHandle (const BaseRasterHandle &from)
 
GraphicsDriverAPI BaseRasterHandleoperator= (const BaseRasterHandle &from)
 
virtual GraphicsDriverAPI ~BaseRasterHandle ()
 
GraphicsDriverAPI size_t GetWidth () const
 Returns the width of raster resource. More...
 
GraphicsDriverAPI size_t GetHeight () const
 Returns the height of raster resource. More...
 
GraphicsDriverAPI void SetSize (size_t width, size_t height)
 Set the size of the raster handle. More...
 
GraphicsDriverAPI void SetFormat (TargetFormat format)
 Set the format of the raster handle. More...
 
GraphicsDriverAPI TargetFormat GetFormat () const
 Get the format of the raster handle. More...
 
GraphicsDriverAPI voidMap (MaxSDK::Graphics::AccessType accessType, size_t &rowPitch, size_t &slicePitch)
 Locks the entire raster handle and access the raster data. More...
 
GraphicsDriverAPI void UnMap ()
 Unlocks the entire raster handle. More...
 
GraphicsDriverAPI void CopyFrom (const BaseRasterHandle &sourceRasterHandle)
 Copy from another raster handle. More...
 
- Public Member Functions inherited from SmartHandle
virtual GraphicsDriverAPI ~SmartHandle ()
 destructor More...
 
GraphicsDriverAPI bool IsValid () const
 Check if this handle is valid. More...
 
GraphicsDriverAPI void Release ()
 Release the underlying graphics objects. More...
 
GraphicsDriverAPI Identifier GetObjectID () const
 Get the underlying graphics object id. More...
 
GraphicsDriverAPI void SetPointer (IRefObject *pObject)
 
GraphicsDriverAPI IRefObjectGetPointer () const
 Get the underlying graphics object pointer. More...
 
bool operator== (const SmartHandle &rhs) const
 
bool operator!= (const SmartHandle &rhs) const
 
bool operator< (const SmartHandle &rhs) const
 
bool operator<= (const SmartHandle &rhs) const
 
bool operator> (const SmartHandle &rhs) const
 
bool operator>= (const SmartHandle &rhs) const
 
GraphicsDriverAPI SmartHandle (const SmartHandle &)
 
GraphicsDriverAPI SmartHandleoperator= (const SmartHandle &)
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseRasterHandle
static GraphicsDriverAPI Class_ID ClassID ()
 
- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 
- Protected Member Functions inherited from SmartHandle
GraphicsDriverAPI SmartHandle ()
 
- Protected Attributes inherited from SmartHandle
IRefObjectmpObject
 

Detailed Description

This is texture class to support texture for material, such as TextureMaterialHandle.

How to use:

TextureHandle hTexture;
hTexture.Initialize(100, 100, TargetFormatA8R8G8B8);
LockedRect lockedRect;
hTexture.WriteOnlyLockRectangle(0, lockedRect, NULL);
if (NULL != lockedRect.pBits )
{
memset(lockedRect.pBits, 0xff, lockedRect.pitch * 100); // fill data to locked address
}
hTexture.WriteOnlyUnlockRectangle();
TextureMaterialHandle hMaterial;
hMaterial.Initialize();
hMaterial.SetTexture(hTexture);
#define NULL
Definition: autoptr.h:18
GraphicsDriverAPI TextureHandle()
@ TargetFormatA8R8G8B8
8 bit int for each of RGB and A, with byte ordering ARGB
Definition: RenderEnums.h:523

Constructor & Destructor Documentation

◆ TextureHandle() [1/2]

◆ TextureHandle() [2/2]

◆ ~TextureHandle()

virtual GraphicsDriverAPI ~TextureHandle ( )
virtual

Member Function Documentation

◆ operator=()

GraphicsDriverAPI TextureHandle& operator= ( const TextureHandle from)

◆ Initialize() [1/3]

GraphicsDriverAPI bool Initialize ( size_t  width,
size_t  height,
TargetFormat  format 
)
virtual

Initialize the instance of a 2D texture.

A TextureHandle should be initialized before it's used

Parameters
[in]widththe width of texture.
[in]heightthe height of texture.
[in]formatmember of the TargetFormat enumerated type, describing the pixel format of the texture.
Returns
true if successfully initialized, false otherwise.

Reimplemented from BaseRasterHandle.

◆ Initialize() [2/3]

GraphicsDriverAPI bool Initialize ( TextureType  type,
size_t  width,
size_t  height,
size_t  depth,
size_t  slice,
size_t  mipmaplevels,
TargetFormat  format,
ResourceUsage  usage 
)

Initialize the instance of specified type texture.

A TextureHandle should be initialized before it's used

Parameters
[in]typetype of the texture
[in]widththe width of texture.
[in]heightthe height of texture.
[in]depththe depth of texture. Used for volume texture.
[in]slicenumber of sub textures. Used for texture array in DX11. For single texture, specify "1". DX9 ignores this parameter.
[in]mipmaplevelslevel number of texture. If this value is zero, a complete mipmap chain is created.
[in]formatmember of the TargetFormat enumerated type, describing the pixel format of the texture.
[in]usageresource usage of the texture
Returns
true if successfully initialized, false otherwise.

◆ Initialize() [3/3]

GraphicsDriverAPI bool Initialize ( const MSTR filename)

Initialize the instance of texture from file.

A TextureHandle should be initialized before it's used.

Parameters
[in]filenamefilename of the texture. Supported format: .bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, and .tga.
Returns
true if successfully initialized, false otherwise.

◆ WriteOnlyLockRectangle()

GraphicsDriverAPI bool WriteOnlyLockRectangle ( UINT  subTargetIndex,
LockedRect lockedRect,
CONST RECT *  pRectangle 
)

locking the Texture Target makes the target writable.

When a developer has finished writing to the target they should always call WriteOnlyUnlockRectangle.

Parameters
[in]subTargetIndexit specifies the index of sub-target in the cube texture to lock. For non-cube texture, use 0.
[out]lockedRectstore the returned locked rectangle information.
[in]pRectanglepointer to a rectangle to lock. Specified by a pointer to a RECT structure. Specifying NULL for this parameter expands the dirty region to cover the entire texture.
Returns
true if successful, otherwise false.

◆ WriteOnlyUnlockRectangle()

GraphicsDriverAPI bool WriteOnlyUnlockRectangle ( )

Unlocks a rectangle on a texture resource.

Returns
true if successful, otherwise false.

◆ GetSubTargetCount()

GraphicsDriverAPI size_t GetSubTargetCount ( )

Get number of sub-targets.

Returns
for CubeMap, returns 6. For volume map, returns depth in creation parameter. Otherwise, return 1

◆ GetSubTarget()

GraphicsDriverAPI TargetHandle GetSubTarget ( size_t  subIndex)

Get sub target of the texture.

For standard 1D, 2D, 3D texture, only "0" is valid. For cube texture, valid value is 0-5. For Volume texture, valid value depends on creation parameter.

Parameters
[in]subIndexsub target index
Returns
sub-target handle.

◆ SetSize()

GraphicsDriverAPI void SetSize ( size_t  width,
size_t  height,
size_t  depth 
)

Set the size of the texture.

Parameters
[in]widththe width of the texture
[in]heightthe height of the texture
[in]depththe height of the texture

◆ SetAutoGenerateMipMaps()

GraphicsDriverAPI void SetAutoGenerateMipMaps ( bool  value)

Set whether require auto-generate mipmaps.

Default value is true.

Parameters
[in]valuetrue to enable auto-generate mipmap. false to disable

◆ GetAutoGenerateMipMaps()

GraphicsDriverAPI bool GetAutoGenerateMipMaps ( ) const

Get whether auto-generate mipmaps.

Returns
true means system will handle mipmap generation.