idx8vertexshader.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  *<
00003     FILE: IDX8VertexShader.h
00004 
00005     DESCRIPTION: DirectX 8 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 DX8_VERTEX_SHADER_INTERFACE_ID Interface_ID(0x476a10d9, 0x7f531d40)
00020 
00021 struct DX8VSConstant: 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 ID3DGraphicsWindow;
00031 class IDX8PixelShader;
00032 
00061 class IDX8VertexShader : virtual public IVertexShader, public BaseInterface
00062 {
00063 public:
00067     virtual Interface_ID GetID() { return DX8_VERTEX_SHADER_INTERFACE_ID; }
00068 
00069     // Confirm that the Direct3D Device can handle this VertexShader
00075     virtual HRESULT ConfirmDevice(ID3DGraphicsWindow *gw) = 0;
00076 
00077     // Confirm that an associated PixelShader will work with this VertexShader
00083     virtual HRESULT ConfirmPixelShader(IDX8PixelShader *pps) = 0;
00084 
00085     // Can try tristrips for drawing or must geometry using this VertexShader
00086     // be drawn as triangles?  This should return 'true' unless additional per
00087     // vertex data is generated by this VertexShader and this data does not map
00088     // to the Mesh vertices in the same way as existing data the Mesh knows
00089     // about such as texture coordinates.
00095     virtual bool CanTryStrips() = 0;
00096 
00097     // Number of passes for the effect this VertexShader creates.  Note that
00098     // this value will depend on the hardware currently in use.
00102     virtual int GetNumMultiPass() = 0;
00103 
00104     // Retrieve the VertexShader handle for the specified pass for use in GFX
00107     virtual DWORD GetVertexShaderHandle(int numPass) = 0;
00108 
00109     // Set the VertexShader for the specified pass.  This call will be made at
00110     // least once per object to set the per object data for the VertexShader
00111     // such as the VertexShader constants.
00120     virtual HRESULT SetVertexShader(ID3DGraphicsWindow *gw, int numPass) = 0;
00121 
00122 
00123     // Drawing functions.  These functions are necessary as something other
00124     // than a simple default body if:
00125     //
00126     // 1. The VertexShader needs to add additional per vertex data unknown to
00127     //    the Mesh to the VertexBuffer.
00128     //
00129     // 2. The VertexShader needs to have per vertex data ordered differently
00130     //    than the standard position, normal, {color, tex coords ordering}.
00131     //
00132     // 3. The VertexShader is being used to create cached VertexBuffers or
00133     //    using higher order surfaces.
00134     //
00135     // In the first two cases, the VertexShader has the option of not only
00136     // locking and filling the VertexBuffer with data, but also of making the
00137     // actual DrawPrimitive call.  In the third case, the VertexShader must
00138     // make the DrawPrimitive call.  The VertexShader indicates that it has
00139     // done the drawing by returning 'true' in the Draw() functions below.
00140     //
00141     // In the case where the VertexShader does not want to do the drawing but
00142     // does want to fill in a VertexBuffer with data, the VertexShader can
00143     // request the GFX to create a VertexBuffer (and possibly an IndexBuffer)
00144     // of appropriate size.  The GetVertexBuffer and GetIndexBuffer calls on
00145     // the ID3DGraphicsWindow object will do this and return the allocated
00146     // buffers in subsequent calls or reallocate them if necessary.
00147     //
00148     // Please note that if a PixelShader or PixelShaders are in use, these
00149     // Draw() functions may need to set them for the appropriate passes of a
00150     // multipass rendering if the drawing is done in these Draw() functions.
00151     // If the GFX is doing the drawing, then these Draw() functions are only
00152     // being used to fill in the VertexBuffer with data; the GFX will be doing
00153     // the drawing and will be setting the PixelShaders as appropriate.
00154 
00155 
00156     // Draw 3D Mesh as TriStrips.  Fill in the VertexBuffer with data in the
00157     // order desired by the VertexShader.  Return 'true' if the Mesh has
00158     // actually been drawn in this call, 'false' if the GFX is required to make
00159     // the DrawPrimitive call.
00169     virtual bool    DrawMeshStrips(ID3DGraphicsWindow *gw, MeshData *data) = 0;
00170 
00171     // Draw 3D Mesh as wireframe.  Fill in the VertexBuffer with data in the
00172     // order desired by the VertexShader.  Return 'true' if the Mesh has
00173     // actually been drawn in this call, 'false' if the GFX is required to make
00174     // the DrawPrimitive call.
00184     virtual bool    DrawWireMesh(ID3DGraphicsWindow *gw, WireMeshData *data) = 0;
00185 
00186 
00187     // Draw 3D lines.  A Mesh is being drawn by having line segments handed
00188     // down one at a time.
00189 
00190     // Pass in the Mesh data in preparation for drawing 3D lines.
00200     virtual void    StartLines(ID3DGraphicsWindow *gw, WireMeshData *data) = 0;
00201 
00202     // Add the connectivity information for one two point line segment.
00214     virtual void    AddLine(ID3DGraphicsWindow *gw, DWORD *vert, int vis) = 0;
00215 
00216     // Draw the line segments accumulated.  This should restart the filling of
00217     // a VertexBuffer with the next AddLine call if additional data needs to
00218     // be drawn before EndLines is called.  Return 'true' if the Mesh line
00219     // segments have actually been drawn in this call, 'false' if the GFX is
00220     // required to make the DrawPrimitive call.
00229     virtual bool    DrawLines(ID3DGraphicsWindow *gw) = 0;
00230 
00231     // Let the Mesh know that all drawing and data access is finished.
00239     virtual void    EndLines(ID3DGraphicsWindow *gw, GFX_ESCAPE_FN fn) = 0;
00240 
00241 
00242     // Draw 3D triangles.  A Mesh is being drawn by having triangles handed
00243     // down one at a time.
00244 
00245     // Pass in the Mesh data in preparation for drawing 3D triangles.
00254     virtual void    StartTriangles(ID3DGraphicsWindow *gw, MeshFaceData *data) = 0;
00255 
00256     // Add the connectivity information for one triangle.
00267     virtual void    AddTriangle(ID3DGraphicsWindow *gw, DWORD index, int *edgeVis) = 0;
00268 
00269     // Draw the triangles accumulated.  This should restart the filling of a
00270     // VertexBuffer with the next AddTriangle call if additional data needs to
00271     // be drawn before EndTriangles is called.  Return 'true' if the Mesh
00272     // triangles have actually been drawn in this call, 'false' if the GFX is
00273     // required to make the DrawPrimitive call.
00282     virtual bool    DrawTriangles(ID3DGraphicsWindow *gw) = 0;
00283 
00284     // Let the Mesh know that all drawing and data access is finished.
00292     virtual void    EndTriangles(ID3DGraphicsWindow *gw, GFX_ESCAPE_FN fn) = 0;
00293 };