#ifndef TDx_3DDeviceH #define TDx_3DDeviceH // ========================================================================== // File: TDx_3DDevice.H // Authors: BCB_Code_Generator v1.70, // Darren Dwyer (source code, documentation, demos, website), // Hugh Edwards (documentation, icons), // Brian Austin (documentation) // Description: This file defines the TDx_3DDevice Component // // "TDx_3DI_Library v1.70" // (c) 2003 BCB-Tools.com Pty. Ltd., Sydney, Australia. // All Rights Reserved. // // Refer to the 'Licence.Txt' file for licencing & copyright information. // ========================================================================== // -------------------------------------------------------------------------- // #includes // -------------------------------------------------------------------------- #include #include #include #include // -------------------------------------------------------------------------- #include "TDx_Library_Defns.H" #include "TDx_Library_Functions.H" // -------------------------------------------------------------------------- #include "TDx_3DI_Library_Defns.H" #include "TDx_3DI_Library_Functions.H" // -------------------------------------------------------------------------- // external classes used by the TDx_3DDevice component. class TDDPixelFormat; class TDx_DrawSurface; // -------------------------------------------------------------------------- // external classes used by TDx_3DDevice methods. class TD3DRect; class TD3DDrawPrimitiveStridedData; class TDx_3DVertexBuffer; class TD3DDeviceDesc; class TD3DClipStatus; class TDx_3D; class TD3DLight; class TD3DMaterial; class TD3DMatrix; class TD3DViewPort; // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // Definition for the OnEnumTextureFormats callback event. typedef __fastcall void (__closure* TDx_3D_EnumTextureFormatsCallback ) ( TObject* Sender, TDDPixelFormat* PixelFormat, void* Context, bool& Continue ); // ========================================================================== // Class: TDx_3DDevice // Description: The TDx_3DDevice component wraps the DirectX IDirect3DDevice7 // interface which is used to perform the majority of 3D // DrawPrimitive rendering tasks. // // It can be used to: // Retrieve device capabilities and information as well as the // parent TDx_3D component. // Render with primitives, strided primitives or vertex buffers // and also with indexed versions of the each type. // Manipulate lighting and materials by retrieving and defining // lights and materials, as well as enabling and disabling // lights and checking their current status. // Handle textures, including format enumeration, device // validation, loading or pre-loading textures, retrieving and // defining the texture and the texture stage state. // Process device states, including creation, application, // capture, beginning, ending and deletion of state blocks, // retrieval and definition of clip, rendering, rendering // target, data and transform status. // Define and retrieve custom clip planes, clear, define and // retrieve viewports, begin and end scenes, compute viewport // sphere visibility and multiply transform matrices. // ========================================================================== #if (__BORLANDC__ >= 0x0530) // BCB Version 3 + class PACKAGE TDx_3DDevice : public TComponent { // -------------------------------------------------------------------------- #else // BCB Version 1 class TDx_3DDevice : public TComponent { #endif // ========================================================================== __published: // ========================================================================== // ---------------------------------------------------------------------- // Event: OnCreate() // Description: The OnCreate() event is triggered by the // TDx_3DDevice::Create() method after it has successfully // created the internal LPDIRECT3DDEVICE7 used within the // TDx_3DDevice component. // // Note that since this event is only called upon successful // creation, this event is an ideal place for code that is // to be activated only once, immediately upon the // successful creation of the LPDIRECT3DDEVICE7 interface. // // For example, you could retrieve the TDx_3DDevice // component's capabilities, Create() dependant components, // allocate memory, etc. // // When used in conjunction with the // TDx_3DDevice::OnDestroy() event, you can fully automate // and insulate your code on a per-component basis. // ---------------------------------------------------------------------- __property TDx_Event OnCreate = {read=FOnCreate, write=FOnCreate, nodefault}; // ---------------------------------------------------------------------- // Event: OnDestroy() // Description: The OnDestroy() event is triggered by the // TDx_3DDevice::Destroy() method, just before the // TDx_3DDevice internal LPDIRECT3DDEVICE7 interface is // destroyed. // // Note: This event is an ideal place to place code that // reverses the results of the TDx_3DDevice::OnCreate() // event. For example, assume you have already setup the // TDx_3DDevice::OnCreate() event to retrieve the // component's capabilities, Create() a dependant component // and allocate some memory; // You can then fully automate and insulate your code on a // per-component basis by placing code in the // TDx_3DDevice::OnDestroy() event to deallocate memory, // Destroy() the dependant components and, when required, // destroy the capabilities component. // ---------------------------------------------------------------------- __property TDx_Event OnDestroy = {read=FOnDestroy, write=FOnDestroy, nodefault}; // ---------------------------------------------------------------------- // Event: OnError() // Description: The OnError event is called when an error occurs in the // TDx_3DDevice component. // ---------------------------------------------------------------------- __property TDx_Error OnError = {read=FOnError, write=FOnError, nodefault}; // ---------------------------------------------------------------------- // Callback: OnEnumTextureFormats() // Description: The OnEnumTextureFormats Callback event processes each // result returned by TDx_3DDevice::EnumTextureFormats(). // ---------------------------------------------------------------------- __property TDx_3D_EnumTextureFormatsCallback OnEnumTextureFormats = {read=FOnEnumTextureFormats, write=FOnEnumTextureFormats, nodefault}; // ========================================================================== public: // ========================================================================== // ---------------------------------------------------------------------- // Property: Created // Description: The Created property is true if the internal // LPDIRECT3DDEVICE7 used in this component has been // successfully created, otherwise Created is false. // // To create the internal LPDIRECT3DDEVICE7, call the // TDx_3DDevice::Create() method. // ---------------------------------------------------------------------- __property bool Created = { read=FGetCreated, write=FSetCreated, default=false }; // ---------------------------------------------------------------------- // Property: ErrorValue // Description: The ErrorValue property contains the last error value // returned from a call to a TDx_3DDevice method or // fget/fset. eg. D3D_OK or DDERR_SURFACELOST or TDX_ERROR // ---------------------------------------------------------------------- __property HRESULT ErrorValue = { read=FGetErrorValue, write=FSetErrorValue, default=D3D_OK }; // ---------------------------------------------------------------------- // Method: ApplyStateBlock() // Description: The TDx_3DDevice::ApplyStateBlock() method will apply an // existing device state block to the rendering device. // // A device state block cannot be applied while another // block is being recorded. // State block modifications should be made during scene // rendering, ie: between TDx_3DDevice::BeginScene() and // TDx_3DDevice::EndScene() calls. // // If the method call fails, the OnError event will be // triggered with one of the following values: // D3DERR_INBEGINSTATEBLOCK // D3DERR_INVALIDSTATEBLOCK // Params: pBlockHandle - // The BlockHandle parameter references the device state // block to be applied. // // Use the reference returned by // TDx_3DDevice::EndStateBlock() // ---------------------------------------------------------------------- virtual bool __fastcall ApplyStateBlock( dword pBlockHandle ); // ---------------------------------------------------------------------- // Method: BeginScene() // Description: The TDx_3DDevice::BeginScene() method will start a scene // so rendering can commence. // // Attempts to render before this method is called will // fail. // If BeginScene fails, EndScene will also fail and need not // be called. // Call TDx_3DDevice::EndScene() when rendering is complete // and before calling TDx_3DDevice::BeginScene() again. // ---------------------------------------------------------------------- virtual bool __fastcall BeginScene(); // ---------------------------------------------------------------------- // Method: BeginStateBlock() // Description: The TDx_3DDevice::BeginStateBlock() method will start // recording a device state block. // // If the method call fails, the OnError event will be // triggered with one of the following values: // D3DERR_INBEGINSTATEBLOCK // DDERR_OUTOFMEMORY // ---------------------------------------------------------------------- virtual bool __fastcall BeginStateBlock(); // ---------------------------------------------------------------------- // Method: CaptureStateBlock() // Description: The TDx_3DDevice::CaptureStateBlock() method will modify // an existing state block to match the current settings for // the device. // // Only states already specified within the existing state // block will be retrieved, not the whole device state. // // If the method call fails, the OnError event will be // triggered with one of the following values: // D3DERR_INBEGINSTATEBLOCK // Params: pBlockHandle - // The BlockHandle parameter references the device state // block to be modified. // ---------------------------------------------------------------------- virtual bool __fastcall CaptureStateBlock( dword pBlockHandle ); // ---------------------------------------------------------------------- // Method: Clear() // Description: The TDx_3DDevice::Clear() method will set the viewport or // sections of it to a single RGBA color and set the // corresponding depth and stencil buffers to specified // values. // // Setting D3DCLEAR_ZBUFFER or D3DCLEAR_STENCIL when such // information is not present in the rendering surface will // cause this method to fail. // // If the method call fails, the OnError event will be // triggered with one of the following values: // D3DERR_STENCILBUFFER_NOTPRESENT // D3DERR_VIEWPORTHASNODEVICE // D3DERR_ZBUFFER_NOTPRESENT // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // Params: pCount - // The Count parameter specifies how many elements there are // in the Rects array. // // If Rects is NULL, this parameter must be 0. // pRects - // The Rects parameter defines an array of TD3DRect // components defining the screen coordinate area to be // cleared. // // Set the render target dimensions to clear the whole // surface or NULL to clear the entire viewport. // Coordinates are clipped by the viewport. // pFlags - // The Flags parameter indicates which surfaces to clear. // The described effect applies when the flag is set. // // At least one flag must be set. // Flags: // D3DCLEAR_STENCIL - // Set the stencil buffer to the value in the Stencil // parameter. // D3DCLEAR_TARGET - // Set the rendering target to the value in the Color // parameter. // D3DCLEAR_ZBUFFER - // Set the z-buffer to the value in the Z parameter. // pColor - // The Color parameter contains the 32-bit RGBA color to // which the render target surface will be set. // pZ - // The Z parameter holds the value to replace the current // z-buffer entries. // // Values can range from 0.0 through to 1.0 // pStencil - // The Stencil parameter holds an integer value to replace // the current stencil buffer entries. // // Values can range from 0 to 2^n -1, where n is the stencil // buffer bit depth. // ---------------------------------------------------------------------- virtual bool __fastcall Clear( dword pCount, TD3DRect* pRects, dword pFlags, dword pColor, D3DVALUE pZ, dword pStencil ); // ---------------------------------------------------------------------- // Method: ComputeSphereVisibility() // Description: The TDx_3DDevice::ComputeSphereVisibility() method will // ascertain the viewport visibility of an array spheres. // // The visibility calculation needs to invert the combined // world, view or projection matrices. // If inversion of the combined matrix is not possible (ie: // the determinant is 0), D3DERR_INVALIDMATRIX is returned. // // If the method call fails, the OnError event will be // triggered with one of the following values: // D3DERR_INVALIDMATRIX // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // Params: pCenters - // The Centers parameter references an array of TD3DVector // components defining the world space center of each // sphere. // pRadii - // The Radii parameter references an array of D3DVALUE's // representing the radius of each sphere. // pNumSpheres - // The NumSpheres parameter defines how many spheres are to // be tested. // // This parameter must be greater than zero. // pReturnValues - // The ReturnValues parameter will reference an array of // DWORD's, one element for each sphere tested, if this // method returns successfully. // // If a sphere is fully visible, its corresponding element // will be 0. // If a sphere is partially or completely obscured, the // corresponding element will contain a combination of // clipping flags that indicate the spheres visibility. // // The clip flags returned correspond to those described in // TD3DClipStatus::Status. // ---------------------------------------------------------------------- virtual bool __fastcall ComputeSphereVisibility( D3DVECTOR* pCenters, D3DVALUE* pRadii, dword pNumSpheres, dword* pReturnValues ); // ---------------------------------------------------------------------- // Method: Create() // Description: The Create() method is used to automatically create the // internal LPDIRECT3DDEVICE7 interface used in the // TDx_3DDevice component and must be called before any // methods of the TDx_3DDevice component will function. // Params: pD3D - // The D3D parameter refers to a created DirectDraw // interface, created using the TD3D::Create() method. // pRefID - // The RefID parameter ... // pRenderSurface - // The RenderSurface parameter ... // ---------------------------------------------------------------------- virtual bool __fastcall Create( TDx_3D* pD3D, REFCLSID pRefID, TDx_DrawSurface* pRenderSurface ); // ---------------------------------------------------------------------- // Method: CreateStateBlock() // Description: The TDx_3DDevice::CreateStateBlock() method will create a // new state block from all or some of the current device // settings. // // If the method call fails, the OnError event will be // triggered with one of the following values: // D3DERR_INBEGINSTATEBLOCK // DDERR_INVALIDPARAMS // DDERR_OUTOFMEMORY // Params: pType - // The Type parameter defines the type of state data that // the new state block should contain. // // Possible values are: // D3DSBT_ALL for all states. // D3DSBT_PIXELSTATE for only pixel related states. // D3DSBT_VERTEXSTATE for only vertex related states. // // Pixel states are those affecting pixel and depth buffer // processing during rasterisation. // Vertex states are those affectiing vertex processing. // Some states are present in both the pixel and the vertex // subgroups. // pBlockHandle - // The BlockHandle parameter will reference the new device // state block if this method returns successfully. // ---------------------------------------------------------------------- virtual bool __fastcall CreateStateBlock( D3DSTATEBLOCKTYPE pType, dword* pBlockHandle ); // ---------------------------------------------------------------------- // Method: DeleteStateBlock() // Description: The TDx_3DDevice::DeleteStateBlock() method will delete a // specified state block. // // A device state block cannot be deleted while another // block is being recorded. // // If the method call fails, the OnError event will be // triggered with one of the following values: // D3DERR_INBEGINSTATEBLOCK // D3DERR_INVALIDSTATEBLOCK // Params: pBlockHandle - // The BlockHandle parameter references the device state // block to be deleted. // ---------------------------------------------------------------------- virtual bool __fastcall DeleteStateBlock( dword pBlockHandle ); // ---------------------------------------------------------------------- // Method: Destroy() // Description: The Destroy() method is used to automatically destroy the // internal LPDIRECT3DDEVICE7 interface used in the // TDx_3DDevice component and should be called when the // internal interface is no longer required. // // Note: This method is called by the component's // destructor. // ---------------------------------------------------------------------- virtual bool __fastcall Destroy(); // ---------------------------------------------------------------------- // Method: DrawIndexedPrimitive() // Description: The TDx_3DDevice::DrawIndexedPrimitive() method will // render a geometric primitive by indexing into a vertex // array. // // Ensure the vertices to be rendered match the vertex // format or memory faults may result. // The entire array is transformed, so do not use this // method to render a small subset from a large array. // // This method somtimes generates a larger update rectangle // than is needed, affecting performance when many vertices // are processed. // If using TD3DTLVertex and this is occurring, set // D3DDP_DONOTCLIP and D3DDP_DONOTUPDATEEXTENTS flags to // remedy the situation. // // If the method call fails, the OnError event will be // triggered with one of the following values: // D3DERR_INVALIDRAMPTEXTURE // D3DERR_INVALIDPRIMITIVETYPE // D3DERR_INVALIDVERTEXTYPE // DDERR_INVALIDPARAMS // DDERR_WASSTILLDRAWING // Params: pPrimitiveType - // The PrimitiveType parameter defines the type of primitive // that is to be rendered. // // Possible values are: // D3DPT_LINELIST // D3DPT_LINESTRIP // D3DPT_TRIANGLELIST // D3DPT_TRIANGLESTRIP // D3DPT_TRIANGLEFAN // pVertexTypeDesc - // The VertexTypeDesc parameter indicates the vertex format // by setting a combination of flexible vertex format flags. // // The flexible vertex format flags used correspond to those // described in TD3DVertexBufferFormat::FVF. // pVertices - // The Vertices parameter references the vertex array from // which vertices will be rendered as specified by the // indices in the Indices array. // pVertexCount - // The VertexCount parameter defines the total number of // vertices stored in the Vertices array. // pIndices - // The Indices parameter references a WORD array of values // for indexing into the Vertices array. // pIndexCount - // The IndexCount parameter defines how many indices are in // the Indices array and thus how many vertices are to be // drawn from the Vertices array. // pFlags - // The Flags parameter indicates whether the method should // wait for rendering before returning. // The described effect applies when the flag is set. // // Set 0 to return as soon as the polygons are sent to the // card. // Flags: // D3DDP_WAIT - // Wait until rendering has been done rather than // returning as soon as the data has been sent to the // card. // // The method will return immediately when a scene // capture cards responds. // Usually for debugging, do not use this flag to // ensure the scene is up to date before continuing. // ---------------------------------------------------------------------- virtual bool __fastcall DrawIndexedPrimitive( D3DPRIMITIVETYPE pPrimitiveType, dword pVertexTypeDesc, void* pVertices, dword pVertexCount, word* pIndices, dword pIndexCount, dword pFlags ); // ---------------------------------------------------------------------- // Method: DrawIndexedPrimitiveStrided() // Description: The TDx_3DDevice::DrawIndexedPrimitiveStrided() method // will render a geometric primitive by indexing into a // strided vertex array. // // Ensure the vertices to be rendered match the vertex // format or memory faults may result. // Transformed vertices are not supported so if // D3DFVF_XYZRHW is set in VertexTypeDesc the method will // fail with D3DERR_INVALIDVERTEXTYPE. // // If the method call fails, the OnError event will be // triggered with one of the following values: // D3DERR_INVALIDRAMPTEXTURE // D3DERR_INVALIDPRIMITIVETYPE // D3DERR_INVALIDVERTEXTYPE // DDERR_INVALIDPARAMS // DDERR_WASSTILLDRAWING // Params: pPrimitiveType - // The PrimitiveType parameter defines the type of primitive // that is to be rendered. // // Possible values are: // D3DPT_LINELIST // D3DPT_LINESTRIP // D3DPT_TRIANGLELIST // D3DPT_TRIANGLESTRIP // D3DPT_TRIANGLEFAN // pVertexTypeDesc - // The VertexTypeDesc parameter indicates the vertex format // by setting a combination of flexible vertex format flags. // // The flexible vertex format flags used correspond to those // described in TD3DVertexBufferFormat::FVF. // pVertexArray - // The VertexArray parameter references the // TD3DDrawPrimitveStridedData component holding the // pointers and memory strides of the vertices. // pVertexCount - // The VertexCount parameter defines the total number of // vertices stored in the vertex list referenced by // VertexArray. // pIndices - // The Indices parameter references a WORD array of values // for indexing into the vertex list referenced by // VertexArray. // pIndexCount - // The IndexCount parameter defines how many indices are in // the Indices array and thus how many vertices from // VertexArray are to be used. // pFlags - // The Flags parameter indicates whether the method should // wait for rendering before returning. // The described effect applies when the flag is set. // // Set 0 to return as soon as the polygons are sent to the // card. // Flags: // D3DDP_WAIT - // Wait until rendering has been done rather than // returning as soon as the data has been sent to the // card. // // The method will return immediately when a scene // capture cards responds. // Usually for debugging, do not use this flag to // ensure the scene is up to date before continuing. // ---------------------------------------------------------------------- virtual bool __fastcall DrawIndexedPrimitiveStrided( D3DPRIMITIVETYPE pPrimitiveType, dword pVertexTypeDesc, TD3DDrawPrimitiveStridedData* pVertexArray, dword pVertexCount, word* pIndices, dword pIndexCount, dword pFlags ); // ---------------------------------------------------------------------- // Method: DrawIndexedPrimitiveVB() // Description: The TDx_3DDevice::DrawIndexedPrimitiveVB() method will // render a geometric primitive by indexing into a vertex // buffer. // // Ensure the vertices to be rendered match the vertex // format or memory faults may result. // A locked vertex buffer cannot be rendered and will return // D3DERR_VERTEXBUFFERLOCKED. // Software devices can ony render from system memory vertex // buffers, hardware devices can render from both system and // video memory vertex buffers. // // If the method call fails, the OnError event will be // triggered with one of the following values: // D3DERR_INVALIDPRIMITIVETYPE // D3DERR_INVALIDVERTEXTYPE // D3DERR_VERTEXBUFFERLOCKED // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // DDERR_WASSTILLDRAWING // Params: pPrimitiveType - // The PrimitiveType parameter defines the type of primitive // that is to be rendered. // // Possible values are: // D3DPT_LINELIST // D3DPT_LINESTRIP // D3DPT_TRIANGLELIST // D3DPT_TRIANGLESTRIP // D3DPT_TRIANGLEFAN // pD3DVertexBuffer - // The D3DVertexBuffer parameter references the // TDx_3DVertexBuffer that holds the vertex array. // pStartVertex - // The StartVertex parameter defines the index of the first // vertex to be rendered from the vertex buffer. // pNumVertices - // The NumVertices parameter defines the total number of // vertices in the vertex buffer. // pIndices - // The Indices parameter references a WORD array of values // for indexing into the vertex buffer. // // Value can range from 0 to // TD3DVertexBufferDesc::NumVertices - 1. // pIndexCount - // The IndexCount parameter defines how many indices are in // the Indices array and thus how many vertices are to be // rendered. // pFlags - // The Flags parameter indicates whether the method should // wait for rendering before returning. // The described effect applies when the flag is set. // // Set 0 to return as soon as the polygons are sent to the // card. // Flags: // D3DDP_WAIT - // Wait until rendering has been done rather than // returning as soon as the data has been sent to the // card. // // The method will return immediately when a scene // capture cards responds. // Usually for debugging, do not use this flag to // ensure the scene is up to date before continuing. // ---------------------------------------------------------------------- virtual bool __fastcall DrawIndexedPrimitiveVB( D3DPRIMITIVETYPE pPrimitiveType, TDx_3DVertexBuffer* pD3DVertexBuffer, word pStartVertex, dword pNumVertices, word* pIndices, dword pIndexCount, dword pFlags ); // ---------------------------------------------------------------------- // Method: DrawPrimitive() // Description: The TDx_3DDevice::DrawPrimitive() method will render a // vertex array as a sequence of geometric primitives. // // Ensure the vertices to be rendered match the vertex // format or memory faults may result. // // If the method call fails, the OnError event will be // triggered with one of the following values: // D3DERR_INVALIDRAMPTEXTURE // D3DERR_INVALIDPRIMITIVETYPE // D3DERR_INVALIDVERTEXTYPE // DDERR_INVALIDPARAMS // DDERR_WASSTILLDRAWING // Params: pPrimitiveType - // The PrimitiveType parameter defines the type of primitive // that is to be rendered. // // Possible values are: // D3DPT_POINTLIST // D3DPT_LINELIST // D3DPT_LINESTRIP // D3DPT_TRIANGLELIST // D3DPT_TRIANGLESTRIP // D3DPT_TRIANGLEFAN // pVertexTypeDesc - // The VertexTypeDesc parameter indicates the vertex format // by setting a combination of flexible vertex format flags. // // The flexible vertex format flags used correspond to those // described in TD3DVertexBufferFormat::FVF. // pVertices - // The Vertices parameter references an array of vertices to // be used in the primitive sequence. // pVertexCount - // The VertexCount parameter defines how many vertices are // in the Vertices array. // pFlags - // The Flags parameter indicates whether the method should // wait for rendering before returning. // The described effect applies when the flag is set. // // Set 0 to return as soon as the polygons are sent to the // card. // Flags: // D3DDP_WAIT - // Wait until rendering has been done rather than // returning as soon as the data has been sent to the // card. // // The method will return immediately when a scene // capture cards responds. // Usually for debugging, do not use this flag to // ensure the scene is up to date before continuing. // ---------------------------------------------------------------------- virtual bool __fastcall DrawPrimitive( D3DPRIMITIVETYPE pPrimitiveType, dword pVertexTypeDesc, void* pVertices, dword pVertexCount, dword pFlags ); // ---------------------------------------------------------------------- // Method: DrawPrimitiveStrided() // Description: The TDx_3DDevice::DrawPrimitiveStrided() method will // render a strided vertex array as a sequence of geometric // primitives. // // Ensure the vertices to be rendered match the vertex // format or memory faults may result. // Transformed vertices are not supported so if // D3DFVF_XYZRHW is set in VertexTypeDesc the method will // fail with D3DERR_INVALIDVERTEXTYPE. // // If the method call fails, the OnError event will be // triggered with one of the following values: // D3DERR_INVALIDRAMPTEXTURE // D3DERR_INVALIDPRIMITIVETYPE // D3DERR_INVALIDVERTEXTYPE // DDERR_INVALIDPARAMS // DDERR_WASSTILLDRAWING // Params: pPrimitiveType - // The PrimitiveType parameter defines the type of primitive // that is to be rendered. // // Possible values are: // D3DPT_POINTLIST // D3DPT_LINELIST // D3DPT_LINESTRIP // D3DPT_TRIANGLELIST // D3DPT_TRIANGLESTRIP // D3DPT_TRIANGLEFAN // pVertexTypeDesc - // The VertexTypeDesc parameter indicates the vertex format // by setting a combination of flexible vertex format flags. // // The flexible vertex format flags used correspond to those // described in TD3DVertexBufferFormat::FVF. // pVertexArray - // The VertexArray parameter references the // TD3DDrawPrimitveStridedData component holding the // pointers and memory strides of the vertices. // pVertexCount - // The VertexCount parameter defines the total number of // vertices stored in the vertex list referenced by // VertexArray. // pFlags - // The Flags parameter indicates whether the method should // wait for rendering before returning. // The described effect applies when the flag is set. // // Set 0 to return as soon as the polygons are sent to the // card. // Flags: // D3DDP_WAIT - // Wait until rendering has been done rather than // returning as soon as the data has been sent to the // card. // // The method will return immediately when a scene // capture cards responds. // Usually for debugging, do not use this flag to // ensure the scene is up to date before continuing. // ---------------------------------------------------------------------- virtual bool __fastcall DrawPrimitiveStrided( D3DPRIMITIVETYPE pPrimitiveType, dword pVertexTypeDesc, TD3DDrawPrimitiveStridedData* pVertexArray, dword pVertexCount, dword pFlags ); // ---------------------------------------------------------------------- // Method: DrawPrimitiveVB() // Description: The TDx_3DDevice::DrawIndexedPrimitiveVB() method will // render a vertex buffer as a sequence of geometric // primitives. // // Ensure the vertices to be rendered match the vertex // format or memory faults may result. // A locked vertex buffer cannot be rendered and will return // D3DERR_VERTEXBUFFERLOCKED. // Software devices can ony render from system memory vertex // buffers, hardware devices can render from both system and // video memory vertex buffers. // // If the method call fails, the OnError event will be // triggered with one of the following values: // D3DERR_INVALIDRAMPTEXTURE // D3DERR_INVALIDPRIMITIVETYPE // D3DERR_INVALIDVERTEXTYPE // D3DERR_VERTEXBUFFERLOCKED // DDERR_INVALIDPARAMS // DDERR_WASSTILLDRAWING // Params: pPrimitiveType - // The PrimitiveType parameter defines the type of primitive // that is to be rendered. // // Possible values are: // D3DPT_POINTLIST // D3DPT_LINELIST // D3DPT_LINESTRIP // D3DPT_TRIANGLELIST // D3DPT_TRIANGLESTRIP // D3DPT_TRIANGLEFAN // pVertexBuffer - // The VertexBuffer parameter references the // TDx_3DVertexBuffer that holds the vertex array. // pStartVertex - // The StartVertex parameter defines the index of the first // vertex to be rendered from the vertex buffer. // pNumVertices - // The NumVertices parameter defines how many vertices will // be rendered. // pFlags - // The Flags parameter indicates whether the method should // wait for rendering before returning. // The described effect applies when the flag is set. // // Set 0 to return as soon as the polygons are sent to the // card. // Flags: // D3DDP_WAIT - // Wait until rendering has been done rather than // returning as soon as the data has been sent to the // card. // // The method will return immediately when a scene // capture cards responds. // Usually for debugging, do not use this flag to // ensure the scene is up to date before continuing. // ---------------------------------------------------------------------- virtual bool __fastcall DrawPrimitiveVB( D3DPRIMITIVETYPE pPrimitiveType, TDx_3DVertexBuffer* pVertexBuffer, dword pStartVertex, dword pNumVertices, dword pFlags ); // ---------------------------------------------------------------------- // Method: EndScene() // Description: The TDx_3DDevice::EndScene() method will end a scene, // signalling that the scene has been rendered and is held // by the device surface. // // This method should only be called after a successful // TDx_3DDevice::BeginScene() call and before // TDx_3DDevice::BeginScene() is called again. // ---------------------------------------------------------------------- virtual bool __fastcall EndScene(); // ---------------------------------------------------------------------- // Method: EndStateBlock() // Description: The TDx_3DDevice::EndStateBlock() method will finish // recording and return the handle of the new device state // block. // // If the method call fails, the OnError event will be // triggered with one of the following values: // D3DERR_NOTINBEGINSTATEBLOCK // DDERR_INVALIDPARAMS // Params: pBlockHandle - // The BlockHandle parameter will reference the completed // device state block's handle if this method returns // successfully. // ---------------------------------------------------------------------- virtual bool __fastcall EndStateBlock( dword* pBlockHandle ); // ---------------------------------------------------------------------- // Method: EnumTextureFormats() // Description: The TDx_3DDevice::EnumTextureFormats() method will // retrieve a list of supported texture formats from the // device driver. // // This method may not reveal newly implemented texture // formats for some devices. // If the format is required, try creating a surface of that // format and if creation succeeds the format is supported. // // This method will trigger a // TDx_3DDevice::OnEnumTextureFormats() event for each // texture format enumerated. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // Params: pArg - // The Arg parameter references application defined data to // be passed to the OnEnumPixelFormatsCallback() event for // each texture format enumerated. // ---------------------------------------------------------------------- virtual bool __fastcall EnumTextureFormats( void* pArg ); // ---------------------------------------------------------------------- // Method: GetCaps() // Description: The TDx_3DDevice::GetCaps() method will retrieve the 3D // capabilities of the device. // // Use TDx_Draw::GetCaps() to retrieve display device // capabilities. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // Params: pD3DDevDesc - // The D3DDevDesc parameter references a TD3DDeviceDesc // component for holding the 3D device capabilities if thiis // method returns successfully. // ---------------------------------------------------------------------- virtual bool __fastcall GetCaps( TD3DDeviceDesc* pD3DDevDesc ); // ---------------------------------------------------------------------- // Method: GetClipPlane() // Description: The TDx_3DDevice::GetClipPlane() method will retrieve the // coefficients of the user defined clipping plane for this // device. // // The plane equation exists in world space and is set using // TDx_3DDevice::SetClipPlane(). // // The coefficients returned take the form of the general // plane equation. // Eg: If values A, B, C, and D were returned in // PlaneEquation they would fit the general plane equation // such that Ax + By + Cz + D = 0. // A homogeneous coordinate point (x, y, z, w) will be // visible where Ax + By + Cz + Dw >= 0. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pIndex - // The Index parameter identifies the clipping plane for // which the coefficients are being retrieved. // pPlaneEquation - // The PlaneEquation parameter references a 4 element // floating point array for holding the coefficients if this // method returns successfully. // ---------------------------------------------------------------------- virtual bool __fastcall GetClipPlane( dword pIndex, D3DVALUE* pPlaneEquation ); // ---------------------------------------------------------------------- // Method: GetClipStatus() // Description: The TDx_3DDevice::GetClipStatus() method will retrieve // the current clip status. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pD3DClipStatus - // The D3DClipStatus parameter references a TD3DClipStatus // component for holding the current clip status if this // method returns successfully. // ---------------------------------------------------------------------- virtual bool __fastcall GetClipStatus( TD3DClipStatus* pD3DClipStatus ); // ---------------------------------------------------------------------- // Method: GetDirect3D() // Description: The TDx_3DDevice::GetDirect3D() method will retrieve the // device's parent TDx_3D component. // // // Params: pD3D - // The D3D parameter will reference the device's parent // TDx_3D component if this method returns successfully. // ---------------------------------------------------------------------- virtual bool __fastcall GetDirect3D( TDx_3D* pD3D ); // ---------------------------------------------------------------------- // Method: GetInfo() // Description: The TDx_3DDevice::GetInfo() method will retrieve Direct3D // or device driver rendering information. // // This method can reveal driver specific types and // structures not documented in Dx7. // Use this method on debug Dx7, as attempts to use it on // retail Dx7 will cause the method succeed but return with // S_FALSE. // Execution is synchronous and can impact performance, so // do not call it between calls to // TDx_3DDevice::BeginScene() and TDx_3DDevice::EndScene(). // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // Params: pDevInfoID - // The DevInfoID parameter indicates what type of // information to retrieve. // The described effect applies when the flag is set. // Flags: // D3DDEVINFOID_D3DTEXTUREMANAGER - // DevInfoStruct references a // TD3DDevInfo_TextureManager component for holding // Direct3D texture management information. // D3DDEVINFOID_TEXTUREMANAGER - // DevInfoStruct references a // TD3DDevInfo_TextureManager component for holding // device driver texture management information. // // If the driver performs no texture management, // Direct3D texture management information will be // retrieved instead. // D3DDEVINFOID_TEXTURING - // DevInfoStruct references a TD3DDevInfo_Texturing // component for holding the applications texturing // activity. // pDevInfoStruct - // The DevInfoStruct parameter will reference the specified // device information if this method returns successfully. // // This can be a TD3DDevInfo_Texturing or a // TD3DDevInfo_TextureManager component, as specified by the // DevInfoID parameter. // pSize - // The Size parameter defines the size, in bytes, of the // component referenced by the DevInfoStruct parameter. // ---------------------------------------------------------------------- virtual bool __fastcall GetInfo( dword pDevInfoID, void* pDevInfoStruct, dword pSize ); // ---------------------------------------------------------------------- // Method: GetLight() // Description: The TDx_3DDevice::GetLight() method will retrieve a set // of the device's lighting properties. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pLightIndex - // The LightIndex parameter defines the 0 based index of the // lighting property set to be retrieved. // pLight - // The Light parameter references a TD3DLight component for // holding the retrieved lighting properties if this method // returns successfully. // ---------------------------------------------------------------------- virtual bool __fastcall GetLight( dword pLightIndex, TD3DLight* pLight ); // ---------------------------------------------------------------------- // Method: GetLightEnable() // Description: The TDx_3DDevice::GetLightEnable() method will determine // if a given lighting property set is enabled or disabled // for this device. // Params: pLightIndex - // The LightIndex parameter defines the 0 based index of the // lighting property set whose status is to be queried. // pEnable - // The Enable parameter will reference the current status of // the specified lighting properties if this method returns // successfully. // // A value of zero means disabled, a non zero value means // enabled. // ---------------------------------------------------------------------- virtual bool __fastcall GetLightEnable( dword pLightIndex, bool* pEnable ); // ---------------------------------------------------------------------- // Method: GetMaterial() // Description: The TDx_3DDevice::GetMaterial() method will retrieve the // device's material properties. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pMaterial - // The Material parameter references a TD3DMaterial // component for holding the device's material properties if // this method returns successfully. // ---------------------------------------------------------------------- virtual bool __fastcall GetMaterial( TD3DMaterial* pMaterial ); // ---------------------------------------------------------------------- // Method: GetRenderState() // Description: The TDx_3DDevice::GetRenderState() method will retrieve a // single rendering state parameter. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pRenderStateType - // The RenderStateType parameter defines which rendering // state parameter is being queried. // // Possible values are: // D3DRENDERSTATE_ANTIALIAS // D3DRENDERSTATE_TEXTUREPERSPECTIVE // D3DRENDERSTATE_ZENABLE // D3DRENDERSTATE_FILLMODE // D3DRENDERSTATE_SHADEMODE // D3DRENDERSTATE_LINEPATTERN // D3DRENDERSTATE_ZWRITEENABLE // D3DRENDERSTATE_ALPHATESTENABLE // D3DRENDERSTATE_LASTPIXEL // D3DRENDERSTATE_SRCBLEND // D3DRENDERSTATE_DESTBLEND // D3DRENDERSTATE_CULLMODE // D3DRENDERSTATE_ZFUNC // D3DRENDERSTATE_ALPHAREF // D3DRENDERSTATE_ALPHAFUNC // D3DRENDERSTATE_DITHERENABLE // D3DRENDERSTATE_ALPHABLENDENABLE // D3DRENDERSTATE_FOGENABLE // D3DRENDERSTATE_SPECULARENABLE // D3DRENDERSTATE_STIPPLEDALPHA // D3DRENDERSTATE_FOGCOLOR // D3DRENDERSTATE_FOGTABLEMODE // D3DRENDERSTATE_FOGSTART // D3DRENDERSTATE_FOGEND // D3DRENDERSTATE_FOGDENSITY // D3DRENDERSTATE_EDGEANTIALIAS // D3DRENDERSTATE_COLORKEYENABLE // D3DRENDERSTATE_ZBIAS // D3DRENDERSTATE_RANGEFOGENABLE // D3DRENDERSTATE_STENCILENABLE // D3DRENDERSTATE_STENCILFAIL // D3DRENDERSTATE_STENCILZFAIL // D3DRENDERSTATE_STENCILPASS // D3DRENDERSTATE_STENCILFUNC // D3DRENDERSTATE_STENCILREF // D3DRENDERSTATE_STENCILMASK // D3DRENDERSTATE_STENCILWRITEMASK // D3DRENDERSTATE_TEXTUREFACTOR // D3DRENDERSTATE_WRAP0 // D3DRENDERSTATE_WRAP1 // D3DRENDERSTATE_WRAP2 // D3DRENDERSTATE_WRAP3 // D3DRENDERSTATE_WRAP4 // D3DRENDERSTATE_WRAP5 // D3DRENDERSTATE_WRAP6 // D3DRENDERSTATE_WRAP7 // D3DRENDERSTATE_CLIPPING // D3DRENDERSTATE_LIGHTING // D3DRENDERSTATE_EXTENTS // D3DRENDERSTATE_AMBIENT // D3DRENDERSTATE_FOGVERTEXMODE // D3DRENDERSTATE_COLORVERTEX // D3DRENDERSTATE_LOCALVIEWER // D3DRENDERSTATE_NORMALIZENORMALS // D3DRENDERSTATE_COLORKEYBLENDENABLE // D3DRENDERSTATE_DIFFUSEMATERIALSOURCE // D3DRENDERSTATE_SPECULARMATERIALSOURCE // D3DRENDERSTATE_AMBIENTMATERIALSOURCE // D3DRENDERSTATE_EMISSIVEMATERIALSOURCE // D3DRENDERSTATE_VERTEXBLEND // D3DRENDERSTATE_CLIPPLANEENABLE // pRenderState - // The RenderState parameter will reference the specified // rendering state parameter if this method returns // successfully. // ---------------------------------------------------------------------- virtual bool __fastcall GetRenderState( D3DRENDERSTATETYPE pRenderStateType, dword* pRenderState ); // ---------------------------------------------------------------------- // Method: GetRenderTarget() // Description: The TDx_3DDevice::GetRenderTarget method will retrieve // the rendering target surface. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pRenderTarget - // The RenderTarget parameter will reference the // TDx_DrawSurface component acting as the rendering target // of this device if this method returns successfully. // ---------------------------------------------------------------------- virtual bool __fastcall GetRenderTarget( TDx_DrawSurface* pRenderTarget ); // ---------------------------------------------------------------------- // Method: GetTexture() // Description: The TDx_3DDevice::GetTexture method will retrieve the // texture associated with a specified texture stage. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // Params: pStage - // The Stage parameter defines which stage's texture is to // be retrieved. // // Dx7 supports up to 8 texture stages, so this value must // be between 0 and 7. // pTexture - // The Texture parameter will reference the TDx_DrawSurface // component holding the retrieved texture if this method // returns successfully. // ---------------------------------------------------------------------- virtual bool __fastcall GetTexture( dword pStage, TDx_DrawSurface* pTexture ); // ---------------------------------------------------------------------- // Method: GetTextureStageState() // Description: The TDx_3DDevice::GetTextureStageState() method will // retrieve the state of the texture assigned to a specified // texture stage. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // Params: pStage - // The Stage parameter defines which stage's texture state // is to be retrieved. // // Dx7 supports up to 8 texture stages, so this value must // be between 0 and 7. // pState - // The State parameter defines which texture state type is // to be retrieved. // // Possible values are: // D3DTSS_COLOROP // D3DTSS_COLORARG1 // D3DTSS_COLORARG2 // D3DTSS_ALPHAOP // D3DTSS_ALPHAARG1 // D3DTSS_ALPHAARG2 // D3DTSS_BUMPENVMAT00 // D3DTSS_BUMPENVMAT01 // D3DTSS_BUMPENVMAT10 // D3DTSS_BUMPENVMAT11 // D3DTSS_TEXCOORDINDEX // D3DTSS_ADDRESS // D3DTSS_ADDRESSU // D3DTSS_ADDRESSV // D3DTSS_BORDERCOLOR // D3DTSS_MAGFILTER // D3DTSS_MINFILTER // D3DTSS_MIPFILTER // D3DTSS_MIPMAPLODBIAS // D3DTSS_MAXMIPLEVEL // D3DTSS_MAXANISOTROPY // D3DTSS_BUMPENVLSCALE // D3DTSS_BUMPENVLOFFSET // D3DTSS_TEXTURETRANSFORMFLAGS // pValue - // The Value parameter will reference the specified textures // state value if this method returns successfully. // ---------------------------------------------------------------------- virtual bool __fastcall GetTextureStageState( dword pStage, D3DTEXTURESTAGESTATETYPE pState, dword* pValue ); // ---------------------------------------------------------------------- // Method: GetTransform() // Description: The TDx_3DDevice::GetTransform() method will retrieve a // specified transformation state matrix. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pTransformStateType - // The TransformStateType parameter defines which transform // state type is to be retrieved. // // Possible values are: // D3DTRANSFORMSTATE_WORLD // D3DTRANSFORMSTATE_VIEW // D3DTRANSFORMSTATE_PROJECTION // D3DTRANSFORMSTATE_WORLD1 // D3DTRANSFORMSTATE_WORLD2 // D3DTRANSFORMSTATE_WORLD3 // D3DTRANSFORMSTATE_TEXTURE0 // D3DTRANSFORMSTATE_TEXTURE1 // D3DTRANSFORMSTATE_TEXTURE2 // D3DTRANSFORMSTATE_TEXTURE3 // D3DTRANSFORMSTATE_TEXTURE4 // D3DTRANSFORMSTATE_TEXTURE5 // D3DTRANSFORMSTATE_TEXTURE6 // D3DTRANSFORMSTATE_TEXTURE7 // pD3DMatrix - // The D3DMatrix parameter references a TD3DMatrix component // for holding the retrieved transformation matrix if this // method returns successfully. // ---------------------------------------------------------------------- virtual bool __fastcall GetTransform( D3DTRANSFORMSTATETYPE pTransformStateType, TD3DMatrix* pD3DMatrix ); // ---------------------------------------------------------------------- // Method: GetViewPort() // Description: The TDx_3DDevice::GetViewport() method will retrieve the // device's viewport settings. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pViewport - // The Viewport parameter references a TD3DViewPort // component for holding the retrieved viewport settings if // this method returns successfully. // ---------------------------------------------------------------------- virtual bool __fastcall GetViewPort( TD3DViewPort* pViewport ); // ---------------------------------------------------------------------- // Method: Internal_EnumTextureFormatsCallback() // Description: The TDx_3DDevice::Internal_EnumTextureFormatsCallback() // method is used internally by the TDx_3DI_Library to // redirect a standard callback function to a BCB style // event. // // It receives all enumeration callbacks generated by the // TDx_3DDevice::EnumTextureFormats() method and on each // enumeration calls the // TDx_3DDevice::OnEnumTextureFormats() event, translating // parameters between DirectX and BCB as required. // Params: pDDPixFmt - // The DDPixFmt parameter references a TDDPixelFormat // component containing the pixel format of the enumerated // texture format. // pContext - // The Context parameter references application defined data // to be passed to the callback event. // ---------------------------------------------------------------------- static HRESULT __stdcall Internal_EnumTextureFormatsCallback( LPDDPIXELFORMAT pDDPixFmt, LPVOID pContext ); // ---------------------------------------------------------------------- // Method: LightEnable() // Description: The TDx_3DDevice::LightEnable() method will enable or // disable a given lighting property set for this device. // // If the LightIndex parameter specifies an unassigned light // property set, a new light source will be created and its // state set to that specified in the Enable parameter. // The new light's settings will be as follows: // Type D3DLIGHT_DIRECTIONAL // Diffuse (R:1, G:1, B:1, A:0) // Specular (R:0, G:0, B:0, A:0) // Ambient (R:0, G:0, B:0, A:0) // Position (0, 0, 0) // Direction (0, 0, 1) // Range 0 // Falloff 0 // Attenuation0 0 // Attenuation1 0 // Attenuation2 0 // Theta 0 // Phi 0 // Params: pLightIndex - // The LightIndex parameter defines the 0 based index of the // lighting property set whose state is to be defined. // // An out of range index results in the creation of a new // light source. // pEnable - // The Enable parameter defines the state of the lighting // property set. // // Set TRUE to enable and FALSE to disable. // ---------------------------------------------------------------------- virtual bool __fastcall LightEnable( dword pLightIndex, bool pEnable ); // ---------------------------------------------------------------------- // Method: Load() // Description: The TDx_3DDevice::Load() method will load a specified // section of a source texture into a specified point of a // destination texture or onto some or all faces of a // cubemap. // // Hardware devices will accelerate load operations. // Any rendering device may use the destination texture, it // is not limited to the creating device. // This method is preferred over blitting when loading into // video memory and can copy mipmap levels, cubemap faces, // palettes and color keys. // // For mipmaps, only mipmap levels common to both source and // destination are copied, but the surface pointers must // point to the top level surfaces of each mipmap. // When specifying a subsection of a mipmap texture, the // rectangle is defined on the top level surface and divided // by two for each lower mipmap level. // Params: pDestTex - // The DestTex parameter references the TDx_DrawSurface // component holding the destination texture. // // In the case of cubemaps and mipmaps, this must point to // the top level surface. // pDestPoint - // The DestPoint parameter defines the destination point the // image data is to be loaded onto the destination texture. // // Set NULL if the destination point is the origin of the // destination texture. // pSrcTex - // The SrcTex parameter references the TDx_DrawSurface // component holding the source texture. // // In the case of cubemaps and mipmaps, this must point to // the top level surface. // pSrcRect - // The SrcRect parameter defines the rectangle that is to be // copied from the source texture to the DestPoint of the // destination texture. // // Set NULL if copying the entire source texture. // pFlags - // The Flags parameter indicates which faces of a cubemap // should be filled by the SrcRect section from the SrcTex // texture. // The described effect applies when the flag is set. // // You must set 0 if the destination is a managed texture. // Flags: // DDSCAPS2_CUBEMAP_ALLFACES - // All faces of the cubemap should be filled. // DDSCAPS2_CUBEMAP_NEGATIVEX - // The negative X face should be filled. // DDSCAPS2_CUBEMAP_NEGATIVEY - // The negative Y face should be filled. // DDSCAPS2_CUBEMAP_NEGATIVEZ - // The negative Z face should be filled. // DDSCAPS2_CUBEMAP_POSITIVEX - // The positive X face should be filled. // DDSCAPS2_CUBEMAP_POSITIVEY - // The positive Y face should be filled. // DDSCAPS2_CUBEMAP_POSITIVEZ - // The positive Z face should be filled. // ---------------------------------------------------------------------- virtual bool __fastcall Load( TDx_DrawSurface* pDestTex, POINT* pDestPoint, TDx_DrawSurface* pSrcTex, TRect* pSrcRect, dword pFlags ); // ---------------------------------------------------------------------- // Method: MultiplyTransform() // Description: The TDx_3DDevice::MultiplyTransform method will multiply // the device's current world, view or projection matrix // with a specified matrix. // // Order of operations: Supplied matrix times existing // matrix. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pTransformStateType - // The TransformStateType parameter indicates which of the // device's transformation matrices is to multipy the matrix // referenced by the D3DMatrix parameter. // // Possible values are: // D3DTRANSFORMSTATE_WORLD // D3DTRANSFORMSTATE_VIEW // D3DTRANSFORMSTATE_PROJECTION // D3DTRANSFORMSTATE_WORLD1 // D3DTRANSFORMSTATE_WORLD2 // D3DTRANSFORMSTATE_WORLD3 // D3DTRANSFORMSTATE_TEXTURE0 // D3DTRANSFORMSTATE_TEXTURE1 // D3DTRANSFORMSTATE_TEXTURE2 // D3DTRANSFORMSTATE_TEXTURE3 // D3DTRANSFORMSTATE_TEXTURE4 // D3DTRANSFORMSTATE_TEXTURE5 // D3DTRANSFORMSTATE_TEXTURE6 // D3DTRANSFORMSTATE_TEXTURE7 // pD3DMatrix - // The D3DMatrix parameter references a TD3DMatrix component // that will be multiplied by the transformation matrix // specified in TransforStateType. // ---------------------------------------------------------------------- virtual bool __fastcall MultiplyTransform( D3DTRANSFORMSTATETYPE pTransformStateType, TD3DMatrix* pD3DMatrix ); // ---------------------------------------------------------------------- // Method: PreLoad() // Description: The TDx_3DDevice::PreLoad() method will force the texture // manager to load a specified managed texture into video // memory, expelling other textures if neccessary. // // Managed textures are those created with the // DDSCAPS2_TEXTUREMANAGE or DDSCAPS2_D3DTEXTUREMANAGE flag. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // Params: pTexture - // The Texture parameter references the TDx_DrawSurface // holding the managed texture that is to be loaded into // video memory. // ---------------------------------------------------------------------- virtual bool __fastcall PreLoad( TDx_DrawSurface* pTexture ); // ---------------------------------------------------------------------- // Method: SetClipPlane() // Description: The TDx_3DDevice::SetClipPlane() method allows the // application to define the clipping plane coefficients for // this device. // // The plane equation exists in world space and the // coefficients should take the form of the general plane // equation. // Eg: If values A, B, C, and D were specified in // PlaneEquation they should fit the general plane equation // such that Ax + By + Cz + D = 0. // A homogeneous coordinate point (x, y, z, w) will be // visible where Ax + By + Cz + Dw >= 0. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pIndex - // The Index parameter identifies the clipping plane for // which the coefficients are being set. // pPlaneEquation - // The PlaneEquation parameter references a 4 element // floating point array holding the coefficients to be set // for the clipping plane indicated by the Index parameter. // ---------------------------------------------------------------------- virtual bool __fastcall SetClipPlane( dword pIndex, D3DVALUE* pPlaneEquation ); // ---------------------------------------------------------------------- // Method: SetClipStatus() // Description: The TDx_3DDevice::SetClipStatus() method will set the // clip status to specified values. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pD3DClipStatus - // The D3DClipStatus parameter references a TD3DClipStatus // component that defines the new clip status that is to be // set. // ---------------------------------------------------------------------- virtual bool __fastcall SetClipStatus( TD3DClipStatus* pD3DClipStatus ); // ---------------------------------------------------------------------- // Method: SetLight() // Description: The TDx_3DDevice::SetLight() method will define a set of // the device's lighting properties. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // DDERR_OUTOFMEMORY // Params: pLightIndex - // The LightIndex parameter defines the 0 based index of the // lighting property set that is to be defined. // // Lighting properties existing at this index will be // overwritten. // pLight - // The Light parameter references a TD3DLight component that // defines the lighting properties that are to be set. // ---------------------------------------------------------------------- virtual bool __fastcall SetLight( dword pLightIndex, TD3DLight* pLight ); // ---------------------------------------------------------------------- // Method: SetMaterial() // Description: The TDx_3DDevice::SetMaterial() method will define the // device's material properties. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pMaterial - // The Material parameter references a TD3DMaterial // component that defines the material properties to be set // for this device. // ---------------------------------------------------------------------- virtual bool __fastcall SetMaterial( TD3DMaterial* pMaterial ); // ---------------------------------------------------------------------- // Method: SetRenderState() // Description: The TDx_3DDevice::SetRenderState() method will define a // single rendering state parameter. // // Use TDx_3DDevice::SetTextureStageState() to define // texture states rather than this method. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pRenderStateType - // The RenderStateType parameter defines which rendering // state parameter is being defined. // // Possible values are: // D3DRENDERSTATE_ANTIALIAS // D3DRENDERSTATE_TEXTUREPERSPECTIVE // D3DRENDERSTATE_ZENABLE // D3DRENDERSTATE_FILLMODE // D3DRENDERSTATE_SHADEMODE // D3DRENDERSTATE_LINEPATTERN // D3DRENDERSTATE_ZWRITEENABLE // D3DRENDERSTATE_ALPHATESTENABLE // D3DRENDERSTATE_LASTPIXEL // D3DRENDERSTATE_SRCBLEND // D3DRENDERSTATE_DESTBLEND // D3DRENDERSTATE_CULLMODE // D3DRENDERSTATE_ZFUNC // D3DRENDERSTATE_ALPHAREF // D3DRENDERSTATE_ALPHAFUNC // D3DRENDERSTATE_DITHERENABLE // D3DRENDERSTATE_ALPHABLENDENABLE // D3DRENDERSTATE_FOGENABLE // D3DRENDERSTATE_SPECULARENABLE // D3DRENDERSTATE_STIPPLEDALPHA // D3DRENDERSTATE_FOGCOLOR // D3DRENDERSTATE_FOGTABLEMODE // D3DRENDERSTATE_FOGSTART // D3DRENDERSTATE_FOGEND // D3DRENDERSTATE_FOGDENSITY // D3DRENDERSTATE_EDGEANTIALIAS // D3DRENDERSTATE_COLORKEYENABLE // D3DRENDERSTATE_ZBIAS // D3DRENDERSTATE_RANGEFOGENABLE // D3DRENDERSTATE_STENCILENABLE // D3DRENDERSTATE_STENCILFAIL // D3DRENDERSTATE_STENCILZFAIL // D3DRENDERSTATE_STENCILPASS // D3DRENDERSTATE_STENCILFUNC // D3DRENDERSTATE_STENCILREF // D3DRENDERSTATE_STENCILMASK // D3DRENDERSTATE_STENCILWRITEMASK // D3DRENDERSTATE_TEXTUREFACTOR // D3DRENDERSTATE_WRAP0 // D3DRENDERSTATE_WRAP1 // D3DRENDERSTATE_WRAP2 // D3DRENDERSTATE_WRAP3 // D3DRENDERSTATE_WRAP4 // D3DRENDERSTATE_WRAP5 // D3DRENDERSTATE_WRAP6 // D3DRENDERSTATE_WRAP7 // D3DRENDERSTATE_CLIPPING // D3DRENDERSTATE_LIGHTING // D3DRENDERSTATE_EXTENTS // D3DRENDERSTATE_AMBIENT // D3DRENDERSTATE_FOGVERTEXMODE // D3DRENDERSTATE_COLORVERTEX // D3DRENDERSTATE_LOCALVIEWER // D3DRENDERSTATE_NORMALIZENORMALS // D3DRENDERSTATE_COLORKEYBLENDENABLE // D3DRENDERSTATE_DIFFUSEMATERIALSOURCE // D3DRENDERSTATE_SPECULARMATERIALSOURCE // D3DRENDERSTATE_AMBIENTMATERIALSOURCE // D3DRENDERSTATE_EMISSIVEMATERIALSOURCE // D3DRENDERSTATE_VERTEXBLEND // D3DRENDERSTATE_CLIPPLANEENABLE // pRenderState - // The RenderState parameter defines the new value for the // specified rendering state parameter. // ---------------------------------------------------------------------- virtual bool __fastcall SetRenderState( D3DRENDERSTATETYPE pRenderStateType, dword pRenderState ); // ---------------------------------------------------------------------- // Method: SetRenderTarget() // Description: The TDx_3DDevice::SetRenderTarget method will define a // new rendering target surface for this device. // // The new target must match the current target in terms of // depth buffer status. // Eg: If the current target has a depth buffer, the new // target must also have a depth buffer. // The depth buffer attached to the new target replaces the // one attached to the current target for context. // // Changing the render target for one with different // properties will not expose different HAL or HEL // capabilities. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pNewRenderTarget - // The RenderTarget parameter references the TDx_DrawSurface // component that will act as the new rendering target for // this device. // // The new target surface must have the DDSCAPS_3DDEVICE // flag set. // ---------------------------------------------------------------------- virtual bool __fastcall SetRenderTarget( TDx_DrawSurface* pNewRenderTarget ); // ---------------------------------------------------------------------- // Method: SetTexture() // Description: The TDx_3DDevice::SetTexture method will define the // texture associated with a specified texture stage. // // The textures reference count will be incremented. // When a textures reference count is zero, the surface is // released and memory recovered. // Set the texture to NULL for the specified texture stage // to decrement the textures reference count. // Software devices cannot assign a texture to more than one // texture stage at a time. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // Params: pStage - // The Stage parameter defines which stage's texture is to // be set. // // Dx7 supports up to 8 texture stages, so this value must // be between 0 and 7. // pTexture - // The Texture parameter references the TDx_DrawSurface // component that holds the texture to be set for the // specified texture stage. // ---------------------------------------------------------------------- virtual bool __fastcall SetTexture( dword pStage, TDx_DrawSurface* pTexture ); // ---------------------------------------------------------------------- // Method: SetTextureStageState() // Description: The TDx_3DDevice::SetTextureStageState() method will // define the state of the texture assigned to a specified // texture stage. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // Params: pStage - // The Stage parameter defines which stage's texture state // is to be defined. // // Dx7 supports up to 8 texture stages, so this value must // be between 0 and 7. // pState - // The State parameter defines which texture state type is // to be defined. // // Possible values are: // D3DTSS_COLOROP // D3DTSS_COLORARG1 // D3DTSS_COLORARG2 // D3DTSS_ALPHAOP // D3DTSS_ALPHAARG1 // D3DTSS_ALPHAARG2 // D3DTSS_BUMPENVMAT00 // D3DTSS_BUMPENVMAT01 // D3DTSS_BUMPENVMAT10 // D3DTSS_BUMPENVMAT11 // D3DTSS_TEXCOORDINDEX // D3DTSS_ADDRESS // D3DTSS_ADDRESSU // D3DTSS_ADDRESSV // D3DTSS_BORDERCOLOR // D3DTSS_MAGFILTER // D3DTSS_MINFILTER // D3DTSS_MIPFILTER // D3DTSS_MIPMAPLODBIAS // D3DTSS_MAXMIPLEVEL // D3DTSS_MAXANISOTROPY // D3DTSS_BUMPENVLSCALE // D3DTSS_BUMPENVLOFFSET // D3DTSS_TEXTURETRANSFORMFLAGS // pValue - // The Value parameter defines the value to which the // specified texture state should be set. // ---------------------------------------------------------------------- virtual bool __fastcall SetTextureStageState( dword pStage, D3DTEXTURESTAGESTATETYPE pState, dword pValue ); // ---------------------------------------------------------------------- // Method: SetTransform() // Description: The TDx_3DDevice::SetTransform() method will define a // specified transformation state matrix. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pTransformStateType - // The TransformStateType parameter defines which transform // state type is to be defined. // // Possible values are: // D3DTRANSFORMSTATE_WORLD // D3DTRANSFORMSTATE_VIEW // D3DTRANSFORMSTATE_PROJECTION // D3DTRANSFORMSTATE_WORLD1 // D3DTRANSFORMSTATE_WORLD2 // D3DTRANSFORMSTATE_WORLD3 // D3DTRANSFORMSTATE_TEXTURE0 // D3DTRANSFORMSTATE_TEXTURE1 // D3DTRANSFORMSTATE_TEXTURE2 // D3DTRANSFORMSTATE_TEXTURE3 // D3DTRANSFORMSTATE_TEXTURE4 // D3DTRANSFORMSTATE_TEXTURE5 // D3DTRANSFORMSTATE_TEXTURE6 // D3DTRANSFORMSTATE_TEXTURE7 // pD3DMatrix - // The D3DMatrix parameter references the TD3DMatrix // component holding the matrix to be set for the specified // transformation type. // ---------------------------------------------------------------------- virtual bool __fastcall SetTransform( D3DTRANSFORMSTATETYPE pTransformStateType, TD3DMatrix* pD3DMatrix ); // ---------------------------------------------------------------------- // Method: SetViewPort() // Description: The TDx_3DDevice::SetViewport() method will define the // device's viewport settings. // // Viewport settings beyond those possiible within the // render target surface will cause this method to fail. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDPARAMS // Params: pViewport - // The Viewport parameter references the TD3DViewPort // component holding the viewport settings to be defined for // this device. // ---------------------------------------------------------------------- virtual bool __fastcall SetViewPort( TD3DViewPort* pViewport ); // ---------------------------------------------------------------------- // Method: ValidateDevice() // Description: The TDx_3DDevice::ValidateDevice() method will check if // the device can render the currently set render states, // textures and texture stage states in one pass. // // You can determine if a specific blending operation can be // performed by setting it up and calling this method. // Since this method uses the current render state, texture // states and textures, modifications to those values may // invalidate the results of previous ValidateDevice calls. // Try to specify the texture (D3DTA_TEXTURE) for each stage // as the 1st argument rather than the second. // // At the time Dx7 was published: // Diffuse iterated values as an argument or operation // (D3DTA_DIFFUSE or D3DTOP_BLENDDIFFUSEALPHA) were rarely // supported, iterated color data often only being // introduceable at the last texture stage. // Diffuse or scalar values at arbitrary texture stages were // rarely supported, more often it was required that they be // applied to the first or last texture stage. // Alpha operations that were intricate or substantially // different to the color operations were less likely to be // supported. // Often cards only have a simple blending unit associated // with the first texture, so you may need to only use the // 2nd texture stage, setting D3DTA_TEXTURE -> // D3DTOP_SELECTARG1 for the first one. // Sometimes simultaneous use of D3DTA_TFACTOR and // D3DTA_DIFFUSE is unsupported. // Sometimes simultaneous multitexture blending and // mipmapped trilinear filtering is unsupported, try turning // off trilinear and revalidating. Maybe use multipass // rendering instead. // // If the method call fails, the OnError event will be // triggered with one of the following values: // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // D3DERR_CONFLICTINGTEXTUREFILTER // D3DERR_CONFLICTINGTEXTUREPALETTE // D3DERR_TOOMANYOPERATIONS // D3DERR_UNSUPPORTEDALPHAARG // D3DERR_UNSUPPORTEDALPHAOPERATION // D3DERR_UNSUPPORTEDCOLORARG // D3DERR_UNSUPPORTEDCOLOROPERATION // D3DERR_UNSUPPORTEDFACTORVALUE // D3DERR_UNSUPPORTEDTEXTUREFILTER // D3DERR_WRONGTEXTUREFORMAT // Params: pPasses - // The Passes parameter will reference the number of // rendering passes required to complete the currently // defined operation. // ---------------------------------------------------------------------- virtual bool __fastcall ValidateDevice( dword* pPasses ); // ---------------------------------------------------------------------- // Constructor() and Destructor() // ---------------------------------------------------------------------- __fastcall TDx_3DDevice(TComponent* Owner); virtual __fastcall ~TDx_3DDevice(); // ---------------------------------------------------------------------- // The following properties and methods are used internally by // TDx_3DI_Library and should not be used. // ---------------------------------------------------------------------- __property LPDIRECT3DDEVICE7 Internal_LPDIRECT3DDEVICE7 = { read=FGetInternal_LPDIRECT3DDEVICE7, write=FSetInternal_LPDIRECT3DDEVICE7, nodefault }; __property LPDIRECT3DDEVICE7* Internal_LPDIRECT3DDEVICE7_Ptr = { read=FGetInternal_LPDIRECT3DDEVICE7_Ptr, nodefault }; void __fastcall Internal_LPDIRECT3DDEVICE7_Update(); __property LPDIRECT3DDEVICE Internal_LPDIRECT3DDEVICE = { read=FGetInternal_LPDIRECT3DDEVICE, write=FSetInternal_LPDIRECT3DDEVICE, nodefault }; __property LPDIRECT3DDEVICE* Internal_LPDIRECT3DDEVICE_Ptr = { read=FGetInternal_LPDIRECT3DDEVICE_Ptr, nodefault }; void __fastcall Internal_LPDIRECT3DDEVICE_Update(); // ========================================================================== protected: // ========================================================================== // ---------------------------------------------------------------------- // Property Access Methods // ---------------------------------------------------------------------- bool __fastcall FGetCreated(); void __fastcall FSetCreated( bool pCreated ); HRESULT __fastcall FGetErrorValue(); void __fastcall FSetErrorValue( HRESULT pErrorValue ); // ========================================================================== private: // ========================================================================== // ---------------------------------------------------------------------- // Internal Interface Access // ---------------------------------------------------------------------- LPDIRECT3DDEVICE7 __fastcall FGetInternal_LPDIRECT3DDEVICE7(); void __fastcall FSetInternal_LPDIRECT3DDEVICE7( LPDIRECT3DDEVICE7 pLPDIRECT3DDEVICE7 ); LPDIRECT3DDEVICE7* __fastcall FGetInternal_LPDIRECT3DDEVICE7_Ptr(); LPDIRECT3DDEVICE __fastcall FGetInternal_LPDIRECT3DDEVICE(); void __fastcall FSetInternal_LPDIRECT3DDEVICE( LPDIRECT3DDEVICE pLPDIRECT3DDEVICE ); LPDIRECT3DDEVICE* __fastcall FGetInternal_LPDIRECT3DDEVICE_Ptr(); // ---------------------------------------------------------------------- // Property Variables // ---------------------------------------------------------------------- bool fCreated; HRESULT fErrorValue; // ---------------------------------------------------------------------- // Interface Variables // ---------------------------------------------------------------------- LPDIRECT3DDEVICE7 fLPDIRECT3DDEVICE7; LPDIRECT3DDEVICE fLPDIRECT3DDEVICE; // ---------------------------------------------------------------------- // Event Variables // ---------------------------------------------------------------------- TDx_Event FOnCreate; TDx_Event FOnDestroy; TDx_Error FOnError; // ---------------------------------------------------------------------- // Callback Variables // ---------------------------------------------------------------------- TDx_3D_EnumTextureFormatsCallback FOnEnumTextureFormats; }; // -------------------------------------------------------------------------- #endif // --------------------------------------------------------------------------