Public Member Functions

IHardwareRenderer Class Reference

Search for all occurrences

Detailed Description

Description:
This class is only available in release 5 or later.

This interface provides access to the DirectX interfaces on the drawing thread of max. This allows creation and loading of various DirectX objects such as Textures. This class has many interfaces not currently implemented, although they will compile and link correctly. This is due to support for DirectX 9, meaning that when a compatible driver is released these methods will be implemented. The documentation for this class only deals with methods that developers can and would normally use.

The basic idea of this class is to provide the developer with access to the DirectX device without actually giving the developer total control, and thus possibility to de-stable the 3ds Max Viewports.

A pointer to this class can be obtained with the following code snippet: -

ViewExp *pview = GetCOREInterface()->GetActiveViewport();

GraphicsWindow *gw = pview->getGW();

IHardwareRenderer * phr = (IHardwareRenderer )gw->GetInterface(HARDWARE_RENDERER_INTERFACE_ID);

For an example usage of this class see MAXSDK/SAMPLES/HardwareShaders/LightMap/Lightmap.cpp

#include <ihardwarerenderer.h>

Inheritance diagram for IHardwareRenderer:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual Interface_ID  GetID ()
virtual LifetimeType  LifetimeControl ()
virtual int  GetMaxTexStages ()=0
virtual int  GetNumActiveWindows ()=0
virtual bool  UpdateScreen (GFX_ESCAPE_FN fn)=0
virtual bool  CanDepthPeel ()=0
virtual void  CreateLayer (int layerNum)=0
virtual void  BlendLayers ()=0
virtual void  StartNode ()=0
virtual void  EndNode (GFX_ESCAPE_FN fn)=0
virtual void  SetColor (ColorType t, D3DXCOLOR *pClr)=0
virtual void  SetMaterial (HardwareMaterial *pMtl)=0
virtual D3DXCOLOR *  GetDiffuseColor ()=0
virtual bool  DisplayAllTriangleEdges ()=0
virtual void  SetDisplayAllTriangleEdges (bool displayAllEdges)=0
virtual bool  CanCacheMeshData ()=0
virtual void  DrawMesh (DWORD type, DWORD nPrim, DWORD *pAttr, DWORD nComp, DWORD *pUse, DWORD **ppInd, DWORD fComp, DWORD *pLen, float **ppData, DWORD attr, GFX_ESCAPE_FN fn)=0
virtual DWORD_PTR  BuildMesh (DWORD nFaces, DWORD *pAttr, DWORD nComp, DWORD *pUse, DWORD **ppInd, DWORD fComp, DWORD *pLen, float **ppData, GFX_ESCAPE_FN fn)=0
virtual DWORD_PTR  BuildMesh (IHardwareMesh *pHWMesh, GFX_ESCAPE_FN fn)=0
virtual void  DrawMesh (DWORD_PTR pMesh, DWORD attr, GFX_ESCAPE_FN fn)=0
virtual DWORD_PTR  LoadMesh (LPCTSTR filename)=0
virtual void  SaveMesh (LPCTSTR filename, DWORD_PTR pMesh)=0
virtual void  FreeMesh (DWORD_PTR pMesh)=0
virtual DWORD_PTR  BuildIndexedBuffer (DWORD type, DWORD nPrim, DWORD *pAttr, DWORD nComp, DWORD *pUse, DWORD **ppInd, DWORD fComp, DWORD *pLen, float **ppData, GFX_ESCAPE_FN fn)=0
virtual void  DrawIndexedBuffer (DWORD_PTR pBuffer, DWORD attr, GFX_ESCAPE_FN fn)=0
virtual void  FreeIndexedBuffer (DWORD_PTR pBuffer)=0
virtual DWORD_PTR  BuildTexture (BITMAPINFO *bmi, UINT mipLevels, DWORD usage, DWORD format)=0
virtual DWORD_PTR  LoadTexture (LPCTSTR filename)=0
virtual void  SaveTexture (LPCTSTR filename, DWORD_PTR pTex)=0
virtual void  FreeTexture (DWORD_PTR pTex)=0
virtual DWORD_PTR  BuildCubeMap (UINT size, UINT mipLevels, DWORD usage, DWORD format, DWORD_PTR *pTex)=0
virtual void  SetCubeMapFace (DWORD_PTR pCubeMap, DWORD face, UINT mipLevel, DWORD_PTR pTex)=0
virtual DWORD_PTR  BuildVertexDecl (DWORD nComp, DWORD *pUse, DWORD fComp)=0
virtual void  SetVertexDecl (DWORD_PTR pVertexDecl)=0
virtual void  FreeVertexDecl (DWORD_PTR pVertexDecl)=0
virtual DWORD_PTR  BuildVertexShader (LPCSTR code)=0
virtual DWORD_PTR  LoadVertexShader (LPCTSTR filename)=0
virtual void  SaveVertexShader (LPCTSTR filename, DWORD_PTR pVertexShader)=0
virtual void  SetVertexShader (DWORD_PTR pVertexShader)=0
virtual void  SetVertexShaderConstant (DWORD_PTR pVertexShader, DWORD nReg, DWORD type, void *pData, DWORD nData)=0
virtual void  FreeVertexShader (DWORD_PTR pVertexShader)=0
virtual DWORD_PTR  BuildPixelShader (LPCSTR code)=0
virtual DWORD_PTR  LoadPixelShader (LPCTSTR filename)=0
virtual void  SavePixelShader (LPCTSTR filename, DWORD_PTR pPixelShader)=0
virtual void  SetPixelShader (DWORD_PTR pPixelShader)=0
virtual void  SetPixelShaderConstant (DWORD_PTR pPixelShader, DWORD nReg, DWORD type, void *pData, DWORD nData)=0
virtual void  FreePixelShader (DWORD_PTR pPixelShader)=0
virtual DWORD_PTR  BuildEffect (LPCSTR code)=0
virtual DWORD_PTR  LoadEffect (LPCTSTR filename)=0
virtual void  SaveEffect (LPCTSTR filename, DWORD_PTR pEffect)=0
virtual void  SetEffectParameter (DWORD_PTR pEffect, LPCTSTR name, DWORD type, void *pData)=0
virtual void  SetEffectTechnique (DWORD_PTR pEffect, LPCTSTR name)=0
virtual void  BeginEffect (DWORD_PTR pEffect)=0
virtual void  SetEffectPass (DWORD_PTR pEffect, DWORD nPass)=0
virtual void  EndEffect (DWORD_PTR pEffect)=0
virtual void  FreeEffect (DWORD_PTR pEffect)=0
virtual DWORD_PTR  BeginEffectAccess (DWORD_PTR pEffect, GFX_ESCAPE_FN fn)=0
virtual void  EndEffectAccess (GFX_ESCAPE_FN fn)=0
virtual DWORD_PTR  BeginDeviceAccess (GFX_ESCAPE_FN fn)=0
virtual void  EndDeviceAccess (GFX_ESCAPE_FN fn)=0
virtual bool  ObjectDrawnByShader ()=0
  This tells the mesh / mnmesh classes whether a shader has performed the drawing already so it can simply ignore the draw call.
virtual void  DXCacheUpdateVertexBuffer (DWORD_PTR pMesh, Point3 *vertexList, Point3 *gfxNormalList, Point3 *faceNormalList, BitArray &changedVerts, int count)=0
  This method lets you update the vertex positions of the DirectX mesh cache.

Member Function Documentation

virtual Interface_ID GetID ( ) [inline, virtual]
Remarks:
This method returns the unique interface ID.

Reimplemented from IHardwareShader.

Reimplemented in IHardwareRendererST.

{ return HARDWARE_RENDERER_INTERFACE_ID; }
virtual LifetimeType LifetimeControl ( ) [inline, virtual]
Remarks:
This method allows inquiries into the actual lifetime policy of a client and provide a server-controlled delete notify callback.
Returns:
One of the following LifetimeTypes:

noRelease

Do not call release, use interface as long as you like.

immediateRelease

The interface is only good for one calls. The release is implied so a call to release is not required.

wantsRelease

The clients are controlling the lifetime, so the interface needs a Release() when the client has finished. This is the default.

serverControlled

The server controls the lifetime and will use the InterfaceNotifyCallback to inform the code when it is gone.
Default Implementation:
{ return noRelease; }

Reimplemented from IHardwareShader.

{ return noRelease; }
virtual int GetMaxTexStages ( ) [pure virtual]
virtual int GetNumActiveWindows ( ) [pure virtual]
virtual bool UpdateScreen ( GFX_ESCAPE_FN  fn ) [pure virtual]
virtual bool CanDepthPeel ( ) [pure virtual]
virtual void CreateLayer ( int  layerNum ) [pure virtual]
virtual void BlendLayers ( ) [pure virtual]
virtual void StartNode ( ) [pure virtual]
virtual void EndNode ( GFX_ESCAPE_FN  fn ) [pure virtual]
virtual void SetColor ( ColorType  t,
D3DXCOLOR *  pClr 
) [pure virtual]
virtual void SetMaterial ( HardwareMaterial *  pMtl ) [pure virtual]
virtual D3DXCOLOR* GetDiffuseColor ( ) [pure virtual]
virtual bool DisplayAllTriangleEdges ( ) [pure virtual]
virtual void SetDisplayAllTriangleEdges ( bool  displayAllEdges ) [pure virtual]
virtual bool CanCacheMeshData ( ) [pure virtual]
virtual void DrawMesh ( DWORD  type,
DWORD  nPrim,
DWORD *  pAttr,
DWORD  nComp,
DWORD *  pUse,
DWORD **  ppInd,
DWORD  fComp,
DWORD *  pLen,
float **  ppData,
DWORD  attr,
GFX_ESCAPE_FN  fn 
) [pure virtual]
virtual DWORD_PTR BuildMesh ( DWORD  nFaces,
DWORD *  pAttr,
DWORD  nComp,
DWORD *  pUse,
DWORD **  ppInd,
DWORD  fComp,
DWORD *  pLen,
float **  ppData,
GFX_ESCAPE_FN  fn 
) [pure virtual]
virtual DWORD_PTR BuildMesh ( IHardwareMesh pHWMesh,
GFX_ESCAPE_FN  fn 
) [pure virtual]
virtual void DrawMesh ( DWORD_PTR  pMesh,
DWORD  attr,
GFX_ESCAPE_FN  fn 
) [pure virtual]
virtual DWORD_PTR LoadMesh ( LPCTSTR  filename ) [pure virtual]
virtual void SaveMesh ( LPCTSTR  filename,
DWORD_PTR  pMesh 
) [pure virtual]
virtual void FreeMesh ( DWORD_PTR  pMesh ) [pure virtual]
virtual DWORD_PTR BuildIndexedBuffer ( DWORD  type,
DWORD  nPrim,
DWORD *  pAttr,
DWORD  nComp,
DWORD *  pUse,
DWORD **  ppInd,
DWORD  fComp,
DWORD *  pLen,
float **  ppData,
GFX_ESCAPE_FN  fn 
) [pure virtual]
virtual void DrawIndexedBuffer ( DWORD_PTR  pBuffer,
DWORD  attr,
GFX_ESCAPE_FN  fn 
) [pure virtual]
virtual void FreeIndexedBuffer ( DWORD_PTR  pBuffer ) [pure virtual]
virtual DWORD_PTR BuildTexture ( BITMAPINFO *  bmi,
UINT  mipLevels,
DWORD  usage,
DWORD  format 
) [pure virtual]
Remarks:
This will create a DX texture stored in local storage. The pointer returned can be used in IHardwareMaterial::SetTexture method. An example of using this method can be seen in the Lightmap sample.

Parameters:
BITMAPINFO *bmi

A pointer to the bitmap from which the texture will be created

UINT miplevels

The number of miplevels to create

DWORD usage

The usage falg is the same as for D3DXCreateTexture - see the DirectX documentation for more information

DWORD format

The pixel format for the texture
virtual DWORD_PTR LoadTexture ( LPCTSTR  filename ) [pure virtual]
Remarks:
This simple loads a texture from the supplied filename using the default options for D3DXCreateTextureFromFile. Please refer to the DirectX documentation for further information.
virtual void SaveTexture ( LPCTSTR  filename,
DWORD_PTR  pTex 
) [pure virtual]
virtual void FreeTexture ( DWORD_PTR  pTex ) [pure virtual]
virtual DWORD_PTR BuildCubeMap ( UINT  size,
UINT  mipLevels,
DWORD  usage,
DWORD  format,
DWORD_PTR *  pTex 
) [pure virtual]
virtual void SetCubeMapFace ( DWORD_PTR  pCubeMap,
DWORD  face,
UINT  mipLevel,
DWORD_PTR  pTex 
) [pure virtual]
virtual DWORD_PTR BuildVertexDecl ( DWORD  nComp,
DWORD *  pUse,
DWORD  fComp 
) [pure virtual]
virtual void SetVertexDecl ( DWORD_PTR  pVertexDecl ) [pure virtual]
virtual void FreeVertexDecl ( DWORD_PTR  pVertexDecl ) [pure virtual]
virtual DWORD_PTR BuildVertexShader ( LPCSTR  code ) [pure virtual]
virtual DWORD_PTR LoadVertexShader ( LPCTSTR  filename ) [pure virtual]
virtual void SaveVertexShader ( LPCTSTR  filename,
DWORD_PTR  pVertexShader 
) [pure virtual]
virtual void SetVertexShader ( DWORD_PTR  pVertexShader ) [pure virtual]
virtual void SetVertexShaderConstant ( DWORD_PTR  pVertexShader,
DWORD  nReg,
DWORD  type,
void *  pData,
DWORD  nData 
) [pure virtual]
virtual void FreeVertexShader ( DWORD_PTR  pVertexShader ) [pure virtual]
virtual DWORD_PTR BuildPixelShader ( LPCSTR  code ) [pure virtual]
virtual DWORD_PTR LoadPixelShader ( LPCTSTR  filename ) [pure virtual]
virtual void SavePixelShader ( LPCTSTR  filename,
DWORD_PTR  pPixelShader 
) [pure virtual]
virtual void SetPixelShader ( DWORD_PTR  pPixelShader ) [pure virtual]
virtual void SetPixelShaderConstant ( DWORD_PTR  pPixelShader,
DWORD  nReg,
DWORD  type,
void *  pData,
DWORD  nData 
) [pure virtual]
virtual void FreePixelShader ( DWORD_PTR  pPixelShader ) [pure virtual]
virtual DWORD_PTR BuildEffect ( LPCSTR  code ) [pure virtual]
virtual DWORD_PTR LoadEffect ( LPCTSTR  filename ) [pure virtual]
virtual void SaveEffect ( LPCTSTR  filename,
DWORD_PTR  pEffect 
) [pure virtual]
virtual void SetEffectParameter ( DWORD_PTR  pEffect,
LPCTSTR  name,
DWORD  type,
void *  pData 
) [pure virtual]
virtual void SetEffectTechnique ( DWORD_PTR  pEffect,
LPCTSTR  name 
) [pure virtual]
virtual void BeginEffect ( DWORD_PTR  pEffect ) [pure virtual]
virtual void SetEffectPass ( DWORD_PTR  pEffect,
DWORD  nPass 
) [pure virtual]
virtual void EndEffect ( DWORD_PTR  pEffect ) [pure virtual]
virtual void FreeEffect ( DWORD_PTR  pEffect ) [pure virtual]
virtual DWORD_PTR BeginEffectAccess ( DWORD_PTR  pEffect,
GFX_ESCAPE_FN  fn 
) [pure virtual]
virtual void EndEffectAccess ( GFX_ESCAPE_FN  fn ) [pure virtual]
virtual DWORD_PTR BeginDeviceAccess ( GFX_ESCAPE_FN  fn ) [pure virtual]
virtual void EndDeviceAccess ( GFX_ESCAPE_FN  fn ) [pure virtual]
virtual bool ObjectDrawnByShader ( ) [pure virtual]

This tells the mesh / mnmesh classes whether a shader has performed the drawing already so it can simply ignore the draw call.

When a shader draws an object, in certain situations 3ds max will also try to draw the object. This can produce a "double draw" situation. This method used to query if the object has been drawn by the shader already. If it has you can simply ignore your drawing code. However if you draw any support objects or subobject data, these can still be drawn, you simply want to avoid drawing the actual triangles of the object.

Returns:
true if the object has already been drawn, false if not.
virtual void DXCacheUpdateVertexBuffer ( DWORD_PTR  pMesh,
Point3 vertexList,
Point3 gfxNormalList,
Point3 faceNormalList,
BitArray changedVerts,
int  count 
) [pure virtual]

This method lets you update the vertex positions of the DirectX mesh cache.

This allow you to keep the directx mesh cache around without having to delete it on geometric changes.

Parameters:
[in] pMesh this is the handle of the directx mesh
[in] vertexList this is a pointer to an array containing the new vertex positions
[in] gfxNormalList this is a pointer to an array containing the new vertex normals. This is the gfxnormals ie teh flattened list of the render normals
[in] faceNormalList this is a pointer to an array containing the new face normals. This is to handle face with no smoothing group which default to the face normal instead of the render normals
[in] changedVerts this is a bitarray that marks all the vertices that have changed. This lets us know which sectors of the mesh we don;t have to change thus making the operation faster
[in] count this is the number of vertices in the vertexList

IHardwareRenderer IHardwareRenderer IHardwareRenderer IHardwareRenderer IHardwareRenderer IHardwareRenderer IHardwareRenderer IHardwareRenderer IHardwareRenderer IHardwareRenderer
IHardwareRenderer IHardwareRenderer IHardwareRenderer IHardwareRenderer IHardwareRenderer IHardwareRenderer IHardwareRenderer IHardwareRenderer IHardwareRenderer IHardwareRenderer