home *** CD-ROM | disk | FTP | other *** search
/ Beginning Direct3D Game Programming / Direct3D.iso / directx / dxf / include / d3dx8effect.h < prev    next >
C/C++ Source or Header  |  2000-09-22  |  7KB  |  237 lines

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. //  Copyright (C) 1999 Microsoft Corporation.  All Rights Reserved.
  4. //
  5. //  File:       d3dx8effect.h
  6. //  Content:    D3DX effect types and functions
  7. //
  8. ///////////////////////////////////////////////////////////////////////////
  9.  
  10. #include "d3dx8.h"
  11.  
  12. #ifndef __D3DX8EFFECT_H__
  13. #define __D3DX8EFFECT_H__
  14.  
  15.  
  16. typedef enum _D3DXPARAMETERTYPE
  17. {
  18.     D3DXPT_DWORD        = 0,
  19.     D3DXPT_FLOAT        = 1,
  20.     D3DXPT_VECTOR       = 2,
  21.     D3DXPT_MATRIX       = 3,
  22.     D3DXPT_TEXTURE      = 4,
  23.     D3DXPT_VERTEXSHADER = 5,
  24.     D3DXPT_PIXELSHADER  = 6,
  25.     D3DXPT_CONSTANT     = 7,
  26.     D3DXPT_FORCE_DWORD  = 0x7fffffff /* force 32-bit size enum */
  27.  
  28. } D3DXPARAMETERTYPE;
  29.  
  30.  
  31. typedef struct _D3DXEFFECT_DESC
  32. {
  33.     UINT Parameters;
  34.     UINT Techniques;
  35.     DWORD Usage;
  36.  
  37. } D3DXEFFECT_DESC;
  38.  
  39.  
  40. typedef struct _D3DXPARAMETER_DESC
  41. {
  42.     DWORD Name;
  43.     D3DXPARAMETERTYPE Type;
  44.  
  45. } D3DXPARAMETER_DESC;
  46.  
  47.  
  48. typedef struct _D3DXTECHNIQUE_DESC
  49. {
  50.     DWORD Name;
  51.     UINT Passes;
  52.  
  53. } D3DXTECHNIQUE_DESC;
  54.  
  55.  
  56. typedef struct _D3DXPASS_DESC
  57. {
  58.     DWORD Name;
  59.  
  60. } D3DXPASS_DESC;
  61.  
  62.  
  63. typedef struct ID3DXEffect *LPD3DXEFFECT;
  64. typedef struct ID3DXTechnique *LPD3DXTECHNIQUE;
  65.  
  66.  
  67.  
  68.  
  69. //////////////////////////////////////////////////////////////////////////////
  70. // ID3DXTechnique ////////////////////////////////////////////////////////////
  71. //////////////////////////////////////////////////////////////////////////////
  72.  
  73. // {A00F378D-AF79-4917-907E-4D635EE63844}
  74. DEFINE_GUID( IID_ID3DXTechnique, 
  75. 0xa00f378d, 0xaf79, 0x4917, 0x90, 0x7e, 0x4d, 0x63, 0x5e, 0xe6, 0x38, 0x44);
  76.  
  77.  
  78. DECLARE_INTERFACE_(ID3DXTechnique, IUnknown)
  79. {
  80.     // IUnknown
  81.     STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  82.     STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  83.     STDMETHOD_(ULONG, Release)(THIS) PURE;
  84.  
  85.     // ID3DXTechnique
  86.     STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE;
  87.     STDMETHOD(GetDesc)(THIS_ D3DXTECHNIQUE_DESC* pDesc) PURE;
  88.     STDMETHOD(GetPassDesc)(THIS_ UINT Index, D3DXPASS_DESC* pDesc) PURE;
  89.  
  90.     STDMETHOD_(BOOL, IsParameterUsed)(THIS_ DWORD dwName) PURE;
  91.  
  92.     STDMETHOD(Validate)(THIS) PURE;
  93.     STDMETHOD(Begin)(THIS_ UINT *pPasses) PURE;
  94.     STDMETHOD(Pass)(THIS_ UINT Index) PURE;
  95.     STDMETHOD(End)(THIS) PURE;
  96. };
  97.  
  98.  
  99. //////////////////////////////////////////////////////////////////////////////
  100. // ID3DXEffect ///////////////////////////////////////////////////////////////
  101. //////////////////////////////////////////////////////////////////////////////
  102.  
  103.  
  104. // {281BBDD4-AEDF-4907-8650-E79CDFD45165}
  105. DEFINE_GUID( IID_ID3DXEffect, 
  106. 0x281bbdd4, 0xaedf, 0x4907, 0x86, 0x50, 0xe7, 0x9c, 0xdf, 0xd4, 0x51, 0x65);
  107.  
  108.  
  109. DECLARE_INTERFACE_(ID3DXEffect, IUnknown)
  110. {
  111.     // IUnknown
  112.     STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  113.     STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  114.     STDMETHOD_(ULONG, Release)(THIS) PURE;
  115.  
  116.     // ID3DXEffect
  117.     STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE;
  118.     STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE;
  119.  
  120.     STDMETHOD(GetParameterDesc)(THIS_ UINT Index, D3DXPARAMETER_DESC* pDesc) PURE;
  121.     STDMETHOD(GetTechniqueDesc)(THIS_ UINT Index, D3DXTECHNIQUE_DESC* pDesc) PURE;
  122.  
  123.     STDMETHOD(SetDword)(THIS_ DWORD Name, DWORD dw) PURE;
  124.     STDMETHOD(GetDword)(THIS_ DWORD Name, DWORD* pdw) PURE; 
  125.     STDMETHOD(SetFloat)(THIS_ DWORD Name, FLOAT f) PURE;
  126.     STDMETHOD(GetFloat)(THIS_ DWORD Name, FLOAT* pf) PURE;
  127.     STDMETHOD(SetVector)(THIS_ DWORD Name, D3DXVECTOR4* pVector) PURE;
  128.     STDMETHOD(GetVector)(THIS_ DWORD Name, D3DXVECTOR4* pVector) PURE;
  129.     STDMETHOD(SetMatrix)(THIS_ DWORD Name, D3DXMATRIX* pMatrix) PURE;
  130.     STDMETHOD(GetMatrix)(THIS_ DWORD Name, D3DXMATRIX* pMatrix) PURE;
  131.     STDMETHOD(SetTexture)(THIS_ DWORD Name, LPDIRECT3DBASETEXTURE8 pTexture) PURE;
  132.     STDMETHOD(GetTexture)(THIS_ DWORD Name, LPDIRECT3DBASETEXTURE8 *ppTexture) PURE;
  133.     STDMETHOD(SetVertexShader)(THIS_ DWORD Name, DWORD Handle) PURE;
  134.     STDMETHOD(GetVertexShader)(THIS_ DWORD Name, DWORD* pHandle) PURE;
  135.     STDMETHOD(SetPixelShader)(THIS_ DWORD Name, DWORD Handle) PURE;
  136.     STDMETHOD(GetPixelShader)(THIS_ DWORD Name, DWORD* pHandle) PURE;
  137.  
  138.     STDMETHOD(GetTechnique)(THIS_ UINT Index, LPD3DXTECHNIQUE* ppTechnique) PURE;
  139.     STDMETHOD(CloneEffect)(THIS_ LPDIRECT3DDEVICE8 pDevice, DWORD Usage, LPD3DXEFFECT* ppEffect) PURE;
  140. };
  141.  
  142.  
  143.  
  144. //////////////////////////////////////////////////////////////////////////////
  145. // APIs //////////////////////////////////////////////////////////////////////
  146. //////////////////////////////////////////////////////////////////////////////
  147.  
  148.  
  149. #ifdef __cplusplus
  150. extern "C" {
  151. #endif //__cplusplus
  152.  
  153.  
  154. //----------------------------------------------------------------------------
  155. // D3DXCompileEffect:
  156. // ------------------
  157. // Compiles an ascii effect description into a binary form usable by
  158. // D3DXCreateEffect.
  159. //
  160. // Parameters:
  161. //  pSrcFile
  162. //      Name of the file containing the ascii effect description
  163. //  pSrcData
  164. //      Pointer to ascii effect description
  165. //  SrcDataSize
  166. //      Size of the effect description in bytes
  167. //  ppCompiledEffect
  168. //      Returns a buffer containing compiled effect.
  169. //  ppCompilationErrors
  170. //      Returns a buffer containing any error messages which occurred during
  171. //      compile.  Or NULL if you do not care about the error messages.
  172. //
  173. //----------------------------------------------------------------------------
  174.  
  175. HRESULT WINAPI
  176.     D3DXCompileEffectFromFileA(
  177.         LPCSTR            pSrcFile,
  178.         LPD3DXBUFFER*     ppCompiledEffect,
  179.         LPD3DXBUFFER*     ppCompilationErrors);
  180.  
  181. HRESULT WINAPI
  182.     D3DXCompileEffectFromFileW(
  183.         LPCWSTR           pSrcFile,
  184.         LPD3DXBUFFER*     ppCompiledEffect,
  185.         LPD3DXBUFFER*     ppCompilationErrors);
  186.  
  187. #ifdef UNICODE
  188. #define D3DXCompileEffectFromFile D3DXCompileEffectFromFileW
  189. #else
  190. #define D3DXCompileEffectFromFile D3DXCompileEffectFromFileA
  191. #endif
  192.  
  193.  
  194. HRESULT WINAPI
  195.     D3DXCompileEffect(
  196.         LPCVOID           pSrcData,
  197.         UINT              SrcDataSize,
  198.         LPD3DXBUFFER*     ppCompiledEffect,
  199.         LPD3DXBUFFER*     ppCompilationErrors);
  200.  
  201.  
  202.  
  203. //----------------------------------------------------------------------------
  204. // D3DXCreateEffect:
  205. // -----------------
  206. // Creates an effect object, given compiled binary effect data
  207. //
  208. // Parameters:
  209. //  pDevice
  210. //      Pointer to the device to be used.
  211. //  pCompiledEffect
  212. //      Pointer to compiled effect data
  213. //  CompiledEffectSize
  214. //      Size of compiled effect data in bytes
  215. //  Usage
  216. //      Allows the specification of D3DUSAGE_SOFTWAREPROCESSING 
  217. //  ppEffect
  218. //      Returns the created effect object
  219. //----------------------------------------------------------------------------
  220.  
  221.  
  222. HRESULT WINAPI
  223.     D3DXCreateEffect(
  224.         LPDIRECT3DDEVICE8 pDevice,
  225.         LPCVOID           pCompiledEffect,
  226.         UINT              CompiledEffectSize,
  227.         DWORD             Usage,
  228.         LPD3DXEFFECT*     ppEffect);
  229.  
  230.  
  231.  
  232. #ifdef __cplusplus
  233. }
  234. #endif //__cplusplus
  235.  
  236. #endif //__D3DX8EFFECT_H__
  237.