00001 /********************************************************************** 00002 *< 00003 FILE: IDX9VertexShader.h 00004 00005 DESCRIPTION: DirectX 9 Vertex Shader Interface Definition 00006 00007 CREATED BY: Nikolai Snader and Norbert Jeske 00008 00009 HISTORY: Created 9/22/00 00010 00011 *> Copyright (c) 2000, All Rights Reserved. 00012 **********************************************************************/ 00013 #pragma once 00014 00015 #include "maxheap.h" 00016 #include <d3dx9.h> 00017 #include "IHardwareShader.h" 00018 00019 #define DX9_VERTEX_SHADER_INTERFACE_ID Interface_ID(0x25065eae, 0x433c2537) 00020 00021 struct DX9VSConstant: public MaxHeapOperators 00022 { 00023 float a,b,c,d; 00024 00025 // Access operators 00026 float& operator[](int i) { return (&a)[i]; } 00027 const float& operator[](int i) const { return (&a)[i]; } 00028 }; 00029 00030 class ID3D9GraphicsWindow; 00031 class IDX9PixelShader; 00032 00033 class IDX9VertexShader : virtual public IVertexShader, public BaseInterface 00034 { 00035 public: 00036 virtual Interface_ID GetID() { return DX9_VERTEX_SHADER_INTERFACE_ID; } 00037 00038 // Confirm that the Direct3D Device can handle this VertexShader 00039 virtual HRESULT ConfirmDevice(ID3D9GraphicsWindow *gw) = 0; 00040 00041 // Confirm that an associated PixelShader will work with this VertexShader 00042 virtual HRESULT ConfirmPixelShader(IDX9PixelShader *pps) = 0; 00043 00044 // Can try tristrips for drawing or must geometry using this VertexShader 00045 // be drawn as triangles? This should return 'true' unless additional per 00046 // vertex data is generated by this VertexShader and this data does not map 00047 // to the Mesh vertices in the same way as existing data the Mesh knows 00048 // about such as texture coordinates. 00049 virtual bool CanTryStrips() = 0; 00050 00051 // Number of passes for the effect this VertexShader creates. Note that 00052 // this value will depend on the hardware currently in use. 00053 virtual int GetNumMultiPass() = 0; 00054 00055 // Retrieve the VertexShader handle for the specified pass for use in GFX 00056 virtual LPDIRECT3DVERTEXSHADER9 GetVertexShaderHandle(int numPass) = 0; 00057 00058 // Set the VertexShader for the specified pass. This call will be made at 00059 // least once per object to set the per object data for the VertexShader 00060 // such as the VertexShader constants. 00061 virtual HRESULT SetVertexShader(ID3D9GraphicsWindow *gw, int numPass) = 0; 00062 00063 00064 // Drawing functions. These functions are necessary as something other 00065 // than a simple default body if: 00066 // 00067 // 1. The VertexShader needs to add additional per vertex data unknown to 00068 // the Mesh to the VertexBuffer. 00069 // 00070 // 2. The VertexShader needs to have per vertex data ordered differently 00071 // than the standard position, normal, {color, tex coords ordering}. 00072 // 00073 // 3. The VertexShader is being used to create cached VertexBuffers or 00074 // using higher order surfaces. 00075 // 00076 // In the first two cases, the VertexShader has the option of not only 00077 // locking and filling the VertexBuffer with data, but also of making the 00078 // actual DrawPrimitive call. In the third case, the VertexShader must 00079 // make the DrawPrimitive call. The VertexShader indicates that it has 00080 // done the drawing by returning 'true' in the Draw() functions below. 00081 // 00082 // In the case where the VertexShader does not want to do the drawing but 00083 // does want to fill in a VertexBuffer with data, the VertexShader can 00084 // request the GFX to create a VertexBuffer (and possibly an IndexBuffer) 00085 // of appropriate size. The GetVertexBuffer and GetIndexBuffer calls on 00086 // the ID3D9GraphicsWindow object will do this and return the allocated 00087 // buffers in subsequent calls or reallocate them if necessary. 00088 // 00089 // Please note that if a PixelShader or PixelShaders are in use, these 00090 // Draw() functions may need to set them for the appropriate passes of a 00091 // multipass rendering if the drawing is done in these Draw() functions. 00092 // If the GFX is doing the drawing, then these Draw() functions are only 00093 // being used to fill in the VertexBuffer with data; the GFX will be doing 00094 // the drawing and will be setting the PixelShaders as appropriate. 00095 00096 00097 // Draw 3D Mesh as TriStrips. Fill in the VertexBuffer with data in the 00098 // order desired by the VertexShader. Return 'true' if the Mesh has 00099 // actually been drawn in this call, 'false' if the GFX is required to make 00100 // the DrawPrimitive call. 00101 virtual bool DrawMeshStrips(ID3D9GraphicsWindow *gw, MeshData *data) = 0; 00102 00103 // Draw 3D Mesh as wireframe. Fill in the VertexBuffer with data in the 00104 // order desired by the VertexShader. Return 'true' if the Mesh has 00105 // actually been drawn in this call, 'false' if the GFX is required to make 00106 // the DrawPrimitive call. 00107 virtual bool DrawWireMesh(ID3D9GraphicsWindow *gw, WireMeshData *data) = 0; 00108 00109 00110 // Draw 3D lines. A Mesh is being drawn by having line segments handed 00111 // down one at a time. 00112 00113 // Pass in the Mesh data in preparation for drawing 3D lines. 00114 virtual void StartLines(ID3D9GraphicsWindow *gw, WireMeshData *data) = 0; 00115 00116 // Add the connectivity information for one two point line segment. 00117 virtual void AddLine(ID3D9GraphicsWindow *gw, DWORD *vert, int vis) = 0; 00118 00119 // Draw the line segments accumulated. This should restart the filling of 00120 // a VertexBuffer with the next AddLine call if additional data needs to 00121 // be drawn before EndLines is called. Return 'true' if the Mesh line 00122 // segments have actually been drawn in this call, 'false' if the GFX is 00123 // required to make the DrawPrimitive call. 00124 virtual bool DrawLines(ID3D9GraphicsWindow *gw) = 0; 00125 00126 // Let the Mesh know that all drawing and data access is finished. 00127 virtual void EndLines(ID3D9GraphicsWindow *gw, GFX_ESCAPE_FN fn) = 0; 00128 00129 00130 // Draw 3D triangles. A Mesh is being drawn by having triangles handed 00131 // down one at a time. 00132 00133 // Pass in the Mesh data in preparation for drawing 3D triangles. 00134 virtual void StartTriangles(ID3D9GraphicsWindow *gw, MeshFaceData *data) = 0; 00135 00136 // Add the connectivity information for one triangle. 00137 virtual void AddTriangle(ID3D9GraphicsWindow *gw, DWORD index, int *edgeVis) = 0; 00138 00139 // Draw the triangles accumulated. This should restart the filling of a 00140 // VertexBuffer with the next AddTriangle call if additional data needs to 00141 // be drawn before EndTriangles is called. Return 'true' if the Mesh 00142 // triangles have actually been drawn in this call, 'false' if the GFX is 00143 // required to make the DrawPrimitive call. 00144 virtual bool DrawTriangles(ID3D9GraphicsWindow *gw) = 0; 00145 00146 // Let the Mesh know that all drawing and data access is finished. 00147 virtual void EndTriangles(ID3D9GraphicsWindow *gw, GFX_ESCAPE_FN fn) = 0; 00148 }; 00149