ihardwarerenderer.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  *<
00003     FILE: IHardwareRenderer.h
00004 
00005     DESCRIPTION: Hardware Renderer Extension Interface class
00006 
00007     CREATED BY: Norbert Jeske
00008 
00009     HISTORY:
00010 
00011  *> Copyright (c) 2002, All Rights Reserved.
00012  **********************************************************************/
00013 #pragma once
00014 
00015 #include "ihardwareshader.h"
00016 #include "HWMesh.h"
00017 
00018 // forward declarations
00019 struct D3DXCOLOR;
00020 class IHardwareMesh;
00021 class IHardwareMaterial;
00022 class HardwareMaterial;
00023 class Matrix3;
00024 
00025 #define HARDWARE_RENDERER_INTERFACE_ID Interface_ID(0x7f78405c, 0x43894b27)
00026 
00027 #define HARDWARE_RENDERER_ST_INTERFACE_ID Interface_ID(0x14716452, 0x65f35430)
00028 
00029 #define D3DHWMESHCACHEMANAGER_INTERFACE_ID Interface_ID(0x7f7840ef, 0x11894b11)
00030 
00052 class IHardwareRenderer : public IHardwareShader
00053 {
00054 public:
00055     virtual Interface_ID    GetID() { return HARDWARE_RENDERER_INTERFACE_ID; }
00056 
00057     // Interface Lifetime
00058     virtual LifetimeType    LifetimeControl() { return noRelease; }
00059 
00060     // Device Information
00061     virtual int     GetMaxTexStages() = 0;
00062 
00063     // Active Viewport Windows
00064     virtual int     GetNumActiveWindows() = 0;
00065 
00066     // Screen Update
00067     virtual bool    UpdateScreen(GFX_ESCAPE_FN fn) = 0;
00068 
00069     // Depth Peeling for Transparency
00070     virtual bool    CanDepthPeel() = 0;
00071     virtual void    CreateLayer(int layerNum) = 0;
00072     virtual void    BlendLayers() = 0;
00073 
00074     // Start and End of Drawing a Node
00075     virtual void    StartNode() = 0;
00076     virtual void    EndNode(GFX_ESCAPE_FN fn) = 0;
00077 
00078     // Material Settings
00079     virtual void    SetColor(ColorType t, D3DXCOLOR *pClr) = 0;
00080     virtual void    SetMaterial(HardwareMaterial *pMtl) = 0;
00081 
00082     virtual D3DXCOLOR   *GetDiffuseColor() = 0;
00083 
00084     //return Display All Triangle Edges in DirectX mode for objects that are not selected and in the modifier panel
00085     //if this is the case all edges will be drawn
00086     virtual bool    DisplayAllTriangleEdges() = 0;
00087     virtual void    SetDisplayAllTriangleEdges(bool displayAllEdges) = 0;
00088 
00089     // Cached Mesh Data
00090     virtual bool    CanCacheMeshData() = 0;
00091 
00092     // Draw a 3ds max Mesh
00093     //
00094     //  type = D3DPRIMITIVETYPE type of primitive
00095     //  nPrim = number of primitives
00096     //  pAttr = array of length nPrim indicating which primitives share
00097     //      attributes, e.g. color, material, effect
00098     //  nComp = number of separate vertex data arrays
00099     //  pUse = array of length nComp indicating D3DDECLUSAGE of each data array
00100     //  ppInd = array of nComp arrays each the same length and long enough
00101     //      to handle nPrim, the connectivity data for the IndexBuffer
00102     //  fComp = bit flags for number of float components in each data array,
00103     //      e.g. 0x00 = 4 floats, 0x01 = 1 float, 0x02 = 2 floats, and
00104     //      0x03 = 3 floats, enough space for 16 flags
00105     //  pLen = array of nComp values giving lengths of data arrays
00106     //  ppData = array of nComp float arrays with data, each being 1X, 2X, 3X,
00107     //      or 4X the length specified in pLen depending on the fComp bit flag
00108     //  attr = which attribute set to draw
00109 
00110     virtual void    DrawMesh(DWORD type, DWORD nPrim, DWORD *pAttr,
00111         DWORD nComp, DWORD *pUse, DWORD **ppInd, DWORD fComp, DWORD *pLen,
00112         float **ppData, DWORD attr, GFX_ESCAPE_FN fn) = 0;
00113 
00114     // Build a D3DXMesh from a 3ds max Mesh
00115     //
00116     //  Returns a pointer to a GFX D3DXMesh class that wraps the D3DXMesh
00117     //  object
00118 
00119     virtual DWORD_PTR   BuildMesh(DWORD nFaces, DWORD *pAttr, DWORD nComp,
00120         DWORD *pUse, DWORD **ppInd, DWORD fComp, DWORD *pLen, float **ppData,
00121         GFX_ESCAPE_FN fn) = 0;
00122 
00123     virtual DWORD_PTR   BuildMesh(IHardwareMesh *pHWMesh,
00124         GFX_ESCAPE_FN fn) = 0;
00125 
00126     // Draw a D3DXMesh or part of a D3DXMesh
00127     //
00128     //  pMesh = pointer to a GFX D3DMesh class
00129     //  attr = attribute value to match with primitive attributes
00130 
00131     virtual void    DrawMesh(DWORD_PTR pMesh, DWORD attr,
00132         GFX_ESCAPE_FN fn) = 0;
00133 
00134     // Load a D3DXMesh from a .X file
00135     //
00136     //  Returns a pointer to a GFX D3DXMesh class that wraps the D3DXMesh
00137     //  object
00138 
00139     virtual DWORD_PTR   LoadMesh(LPCTSTR filename) = 0;
00140 
00141     // Save a D3DXMesh to a .X file
00142     //
00143     //  pMesh = pointer to a GFX D3DMesh class
00144 
00145     virtual void    SaveMesh(LPCTSTR filename, DWORD_PTR pMesh) = 0;
00146 
00147     // Free a D3DXMesh
00148     //
00149     //  pMesh = pointer to a GFX D3DMesh class
00150 
00151     virtual void    FreeMesh(DWORD_PTR pMesh) = 0;
00152 
00153     // Build a GFX IndexedBuffer, a VertexBuffer and IndexBuffer pair
00154     //
00155     //  Returns a pointer to a GFX D3DIndexedBuffer class
00156 
00157     virtual DWORD_PTR   BuildIndexedBuffer(DWORD type, DWORD nPrim,
00158         DWORD *pAttr, DWORD nComp, DWORD *pUse, DWORD **ppInd, DWORD fComp,
00159         DWORD *pLen, float **ppData, GFX_ESCAPE_FN fn) = 0;
00160 
00161     // Draw an IndexedBuffer or part of an IndexedBuffer
00162     virtual void    DrawIndexedBuffer(DWORD_PTR pBuffer, DWORD attr,
00163         GFX_ESCAPE_FN fn) = 0;
00164 
00165     // Free an IndexedBuffer
00166     virtual void    FreeIndexedBuffer(DWORD_PTR pBuffer) = 0;
00167 
00168     // Build a D3DTexture from a 3ds max texture
00169     //
00170     //  bmi = 3ds max bitmap texture
00171     //  mipLevels = number of MipMap levels to build
00172     //  usage = type, e.g. Texture, RenderTarget, DepthStencil
00173     //  format = pixel format, e.g. A8R8G8B8
00174     //
00175     //  Returns a pointer to a GFX D3DTexture class
00190     virtual DWORD_PTR   BuildTexture(BITMAPINFO *bmi, UINT mipLevels,
00191         DWORD usage, DWORD format) = 0;
00192 
00193     // Load a D3DTexture from a file, includes CubeMaps
00194     //
00195     //  Returns a pointer to a GFX D3DTexture class
00199     virtual DWORD_PTR   LoadTexture(LPCTSTR filename) = 0;
00200 
00201     // Save a D3DTexture to a file, includes CubeMaps
00202     virtual void    SaveTexture(LPCTSTR filename, DWORD_PTR pTex) = 0;
00203 
00204     // Free a D3DTexture, includes CubeMaps
00205     virtual void    FreeTexture(DWORD_PTR pTex) = 0;
00206 
00207     // Build a D3DCubeMap from a set of D3DTextures
00208     //
00209     //  size = edge size, e.g. width and height
00210     //  mipLevels = number of MipMap levels to build
00211     //  usage = type, e.g. Texture, RenderTarget, DepthStencil
00212     //  format = pixel format, e.g. A8R8G8B8
00213     //  pTex = array of six D3DTextures to use for the faces
00214     //
00215     //  Returns a pointer to a GFX D3DCubeMap class
00216 
00217     virtual DWORD_PTR   BuildCubeMap(UINT size, UINT mipLevels, DWORD usage,
00218         DWORD format, DWORD_PTR *pTex) = 0;
00219 
00220     // Set a face of a D3DCubeMap
00221     //
00222     //  pCubeMap = pointer to a GFX D3DCubeMap class
00223     //  face = face to set, e.g. positive X
00224     //  mipLevel = number of MipMap levels to build
00225     //  pTex = D3DTexture to use for the face
00226 
00227     virtual void    SetCubeMapFace(DWORD_PTR pCubeMap, DWORD face,
00228         UINT mipLevel, DWORD_PTR pTex) = 0;
00229 
00230     // Build a D3DVertexDeclaration
00231     //
00232     //  nComp = number of separate vertex data components
00233     //  pUse = array of length nComp indicating D3DDECLUSAGE of each data array
00234     //  fComp = bit flags for number of float components in each data array,
00235     //      e.g. 0x00 = 4 floats, 0x01 = 1 float, 0x02 = 2 floats, and
00236     //      0x03 = 3 floats, enough space for 16 flags
00237     //
00238     //  Returns a pointer to a GFX D3DVertexDecl class
00239 
00240     virtual DWORD_PTR   BuildVertexDecl(DWORD nComp, DWORD *pUse,
00241         DWORD fComp) = 0;
00242 
00243     // Set a D3DVertexDeclaration
00244     virtual void    SetVertexDecl(DWORD_PTR pVertexDecl) = 0;
00245 
00246     // Free a D3DVertexDeclaration
00247     virtual void    FreeVertexDecl(DWORD_PTR pVertexDecl) = 0;
00248 
00249     // Build a D3DVertexShader
00250     //
00251     //  code = string with Shader instructions
00252     //
00253     //  Returns a pointer to a GFX D3DVertexShader class
00254 
00255     virtual DWORD_PTR   BuildVertexShader(LPCSTR code) = 0;
00256 
00257     // Load a D3DVertexShader from a file
00258     //
00259     //  Returns a pointer to a GFX D3DVertexShader class
00260 
00261     virtual DWORD_PTR   LoadVertexShader(LPCTSTR filename) = 0;
00262 
00263     // Save a D3DVertexShader to a file
00264     virtual void    SaveVertexShader(LPCTSTR filename, DWORD_PTR pVertexShader) = 0;
00265 
00266     // Set a D3DVertexShader
00267     virtual void    SetVertexShader(DWORD_PTR pVertexShader) = 0;
00268 
00269     // Set D3DVertexShader Constants
00270     //
00271     //  nReg is the number of the register where the data loading starts,
00272     //  type is the D3DXPARAMETERTYPE of the parameter, pData is the actual
00273     //  data and nData is the number of four 32 bit sets of data
00274     //
00275     virtual void    SetVertexShaderConstant(DWORD_PTR pVertexShader,
00276         DWORD nReg, DWORD type, void *pData, DWORD nData) = 0;
00277 
00278     // Free a D3DVertexShader
00279     virtual void    FreeVertexShader(DWORD_PTR pVertexShader) = 0;
00280 
00281     // Build a D3DPixelShader
00282     //
00283     //  code = string with Shader instructions
00284     //
00285     //  Returns a pointer to a GFX D3DPixelShader class
00286 
00287     virtual DWORD_PTR   BuildPixelShader(LPCSTR code) = 0;
00288 
00289     // Load a D3DPixelShader
00290     //
00291     //  Returns a pointer to a GFX D3DPixelShader class
00292 
00293     virtual DWORD_PTR   LoadPixelShader(LPCTSTR filename) = 0;
00294 
00295     // Save a D3DPixelShader to a file
00296     virtual void    SavePixelShader(LPCTSTR filename, DWORD_PTR pPixelShader) = 0;
00297 
00298     // Set a D3DPixelShader
00299     virtual void    SetPixelShader(DWORD_PTR pPixelShader) = 0;
00300 
00301     // Set D3DPixelShader Constants
00302     //
00303     //  nReg is the number of the register where the data loading starts,
00304     //  type is the D3DXPARAMETERTYPE of the parameter, pData is the actual
00305     //  data and nData is the number of four 32 bit sets of data
00306     //
00307     virtual void    SetPixelShaderConstant(DWORD_PTR pPixelShader,
00308         DWORD nReg, DWORD type, void *pData, DWORD nData) = 0;
00309 
00310     // Free a D3DPixelShader
00311     virtual void    FreePixelShader(DWORD_PTR pPixelShader) = 0;
00312 
00313     // Build a D3DXEffect
00314     //
00315     //  Returns a pointer to a GFX D3DEffect class
00316 
00317     virtual DWORD_PTR   BuildEffect(LPCSTR code) = 0;
00318 
00319     // Load a D3DXEffect from a file
00320     virtual DWORD_PTR   LoadEffect(LPCTSTR filename) = 0;
00321 
00322     // Save a D3DXEffect to a file
00323     virtual void    SaveEffect(LPCTSTR filename, DWORD_PTR pEffect) = 0;
00324 
00325     // Set D3DXEffect Parameters
00326     //
00327     //  name is the name of the parameter, type is the D3DXPARAMETERTYPE of the
00328     //  parameter, pData is the actual data
00329     //
00330     virtual void    SetEffectParameter(DWORD_PTR pEffect, LPCTSTR name,
00331         DWORD type, void *pData) = 0;
00332 
00333     // Set D3DXEffect Technique
00334     //
00335     //  name is the name of the technique
00336     //
00337     virtual void    SetEffectTechnique(DWORD_PTR pEffect, LPCTSTR name) = 0;
00338 
00339     // Begin a D3DXEffect
00340     virtual void    BeginEffect(DWORD_PTR pEffect) = 0;
00341 
00342     // Set a D3DXEffect Pass
00343     virtual void    SetEffectPass(DWORD_PTR pEffect, DWORD nPass) = 0;
00344 
00345     // End a D3DXEffect
00346     virtual void    EndEffect(DWORD_PTR pEffect) = 0;
00347 
00348     // Free a D3DXEffect
00349     virtual void    FreeEffect(DWORD_PTR pEffect) = 0;
00350 
00351     // Begin D3DXEffect access
00352     //
00353     //  The D3DXEffect associated with the GFX D3DEffect is returned
00354     //
00355     virtual DWORD_PTR   BeginEffectAccess(DWORD_PTR pEffect, GFX_ESCAPE_FN fn) = 0;
00356 
00357     // End D3DXEffect access
00358     virtual void    EndEffectAccess(GFX_ESCAPE_FN fn) = 0;
00359 
00360     // Begin Direct3D Device access
00361     //
00362     //  The Direct3DDevice is returned
00363     //
00364     virtual DWORD_PTR   BeginDeviceAccess(GFX_ESCAPE_FN fn) = 0;
00365 
00366     // End Direct3D Device access
00367     virtual void    EndDeviceAccess(GFX_ESCAPE_FN fn) = 0;
00368 
00370 
00377     virtual bool ObjectDrawnByShader() = 0;
00378 
00380 
00388     virtual void DXCacheUpdateVertexBuffer(DWORD_PTR pMesh, Point3 *vertexList,Point3 *gfxNormalList, Point3 *faceNormalList, BitArray &changedVerts, int count) = 0;
00389 
00390 };
00391 
00392 class IHardwareRendererST : public IHardwareRenderer
00393 {
00394 public:
00395     virtual Interface_ID    GetID() { return HARDWARE_RENDERER_ST_INTERFACE_ID; }
00396 };
00397 
00398 
00412 class ID3DHWMeshCacheManager : public BaseInterface
00413 {
00414 public:
00415 
00416     virtual Interface_ID    GetID() { return D3DHWMESHCACHEMANAGER_INTERFACE_ID; }
00417 
00418     // Interface Lifetime
00419     virtual LifetimeType    LifetimeControl() { return noRelease; }
00420 
00421     //
00423 
00427     virtual void D3DHWMeshCacheManagerReset(BOOL clearBlock = FALSE) = 0;
00428 
00430 
00440     virtual BOOL D3DHWMeshCacheManagerAddHWMesh( INode *node, GFX_MESH::IHWDrawMesh *pMesh, Material *mtl, HardwareMaterial *pHWMat, Point3 wireframeColor, Matrix3 *tmOverRide, DWORD attr, DWORD renderLimit) = 0;
00441 
00443 
00451     virtual void D3DHWMeshCacheManagerSetRenderLimit(DWORD limit) = 0;
00452 
00454 
00459     virtual DWORD D3DHWMeshCacheManagerGetRenderLimit() = 0;
00460 
00462 
00467     virtual void D3DHWMeshCacheManagerRegisterMaterial(HardwareMaterial *mtl, Point3 wireframeColor) = 0;
00468 
00470 
00473 //  virtual void D3DHWMeshCacheManagerDeleteHWMesh(DWORD_PTR pMesh) = 0;
00474     virtual void D3DHWMeshCacheManagerDeleteHWMesh(GFX_MESH::IHWDrawMesh * pMesh) = 0;
00475 
00477 
00480     virtual void D3DHWMeshCacheManagerDisplay(GraphicsWindow *gw) = 0;
00481 
00482     virtual int D3DHWMeshCacheManagerTotalBlocksDrawn() = 0;
00483 };
00484 
00485 
00486