// -------------------------------------------------------------------------- // ========================================================================== // File: TDx_3DDevice.CPP // Authors: BCB_Code_Generator v1.70, // Darren Dwyer (source code, documentation, demos, website), // Hugh Edwards (documentation, icons), // Brian Austin (documentation) // Description: This file contains the code for 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 #pragma hdrstop // -------------------------------------------------------------------------- #include "TDx_3DDevice.H" // -------------------------------------------------------------------------- // external classes used by the TDx_3DDevice component. #include "TDDPixelFormat.h" #include "TDx_DrawSurface.h" // -------------------------------------------------------------------------- // external classes used by TDx_3DDevice methods. #include "TD3DRect.H" #include "TD3DDrawPrimitiveStridedData.H" #include "TDx_3DVertexBuffer.H" #include "TD3DDeviceDesc.H" #include "TD3DClipStatus.H" #include "TDx_3D.H" #include "TD3DLight.H" #include "TD3DMaterial.H" #include "TDx_DrawSurface.H" #include "TD3DMatrix.H" #include "TD3DViewPort.H" // -------------------------------------------------------------------------- #pragma link "TDx_Library_Defns" #pragma link "TDx_Library_Functions" #pragma link "TDx_3DI_Library_Defns" #pragma link "TDx_3DI_Library_Functions" // -------------------------------------------------------------------------- // Object Registration... // -------------------------------------------------------------------------- #if (__BORLANDC__ >= 0x0530) // BCB Version 3+ #pragma package(smart_init) #endif // -------------------------------------------------------------------------- static inline void ValidCtrCheck(TDx_3DDevice*) { new TDx_3DDevice(NULL); } // -------------------------------------------------------------------------- namespace Tdx_3ddevice { #if (__BORLANDC__ >= 0x0530) // BCB Version 3+ void __fastcall PACKAGE Register() #else void __fastcall Register() #endif { TComponentClass classes[1] = {__classid(TDx_3DDevice)}; RegisterComponents("TDx_3DI", classes, 0); } } // -------------------------------------------------------------------------- // Extra code for Callback Handling // -------------------------------------------------------------------------- TDx_3DDevice* TDx_3DDevice_OnEnumTextureFormatsOwner = NULL; // -------------------------------------------------------------------------- // Constructor: TDx_3DDevice::TDx_3DDevice() // Description: The default constructor for the TDx_3DDevice object. // -------------------------------------------------------------------------- __fastcall TDx_3DDevice::TDx_3DDevice(TComponent* Owner) : TComponent(Owner) { fCreated = false; fErrorValue = D3D_OK; } // -------------------------------------------------------------------------- // Destructor: TDx_3DDevice::~TDx_3DDevice() // Description: The destructor for the TDx_3DDevice object. // -------------------------------------------------------------------------- __fastcall TDx_3DDevice::~TDx_3DDevice() { // destroy internals if (Created) Destroy(); } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::FGetCreated() { return fCreated; } // -------------------------------------------------------------------------- void __fastcall TDx_3DDevice::FSetCreated( bool pCreated ) { fCreated = (pCreated && (fLPDIRECT3DDEVICE7==NULL)); } // -------------------------------------------------------------------------- // 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 // -------------------------------------------------------------------------- HRESULT __fastcall TDx_3DDevice::FGetErrorValue() { return fErrorValue; } // -------------------------------------------------------------------------- void __fastcall TDx_3DDevice::FSetErrorValue( HRESULT pErrorValue ) { fErrorValue = pErrorValue; } // -------------------------------------------------------------------------- // 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() // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::ApplyStateBlock( dword pBlockHandle ) { // Original Function Definition // HRESULT ApplyStateBlock( DWORD dwBlockHandle ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::ApplyStateBlock()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->ApplyStateBlock( (DWORD) pBlockHandle ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::ApplyStateBlock()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::BeginScene() { // Original Function Definition // HRESULT BeginScene(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::BeginScene()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->BeginScene( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::BeginScene()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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 // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::BeginStateBlock() { // Original Function Definition // HRESULT BeginStateBlock(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::BeginStateBlock()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->BeginStateBlock( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::BeginStateBlock()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::CaptureStateBlock( dword pBlockHandle ) { // Original Function Definition // HRESULT CaptureStateBlock( DWORD dwBlockHandle ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CaptureStateBlock()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->CaptureStateBlock( (DWORD) pBlockHandle ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CaptureStateBlock()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::Clear( dword pCount, TD3DRect* pRects, dword pFlags, dword pColor, D3DVALUE pZ, dword pStencil ) { // Original Function Definition // HRESULT Clear( // DWORD dwCount, // LPD3DRECT lpRects, // DWORD dwFlags, // DWORD dwColor, // D3DVALUE dvZ, // DWORD dwStencil // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Clear()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->Clear( (DWORD) pCount, (pRects==NULL) ? NULL : pRects->Internal_D3DRECT_Ptr, (DWORD) pFlags, (DWORD) pColor, pZ, (DWORD) pStencil ); // Translate Data returned from Function if (pRects!=NULL) pRects->Internal_D3DRECT_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Clear()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::ComputeSphereVisibility( D3DVECTOR* pCenters, D3DVALUE* pRadii, dword pNumSpheres, dword* pReturnValues ) { // Original Function Definition // HRESULT ComputeSphereVisibility( // LPD3DVECTOR lpCenters, // LPD3DVALUE lpRadii, // DWORD dwNumSpheres, // DWORD dwFlags, // LPDWORD lpdwReturnValues // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::ComputeSphereVisibility()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->ComputeSphereVisibility( (LPD3DVECTOR) pCenters, (LPD3DVALUE) pRadii, (DWORD) pNumSpheres, 0, (LPDWORD) pReturnValues ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::ComputeSphereVisibility()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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 ... // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::Create( TDx_3D* pD3D, REFCLSID pRefID, TDx_DrawSurface* pRenderSurface ) { // if the component internals have already been created, exit if (fCreated) { fErrorValue = TDX_ALREADYCREATED; if (FOnError) FOnError( this, Name+"::Create()", "TDX_ALREADYCREATED", "The "+Name+"::Create() method was called when the component has already been created." ); return false; } // check parameters if (pD3D==NULL) { fErrorValue = TDX_ERROR; if (FOnError) FOnError( this, Name+"::Create()", "TDX_ERROR", Name+"::Create() requires you supply a D3D device created using TDx_D3D::Create()" ); return false; } // create the internal interface fErrorValue = pD3D->CreateDevice( pRefID, pRenderSurface, this ); // check for error result if (fErrorValue!=D3D_OK) { if (FOnError) FOnError( this, Name+"::Create()", "TDX_ERROR", Name+"::Create() failed with Error: "+TDx_3DI_Library_ErrorString(fErrorValue)+", "+TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // successfully created fCreated = true; if (FOnCreate) FOnCreate(this); return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::CreateStateBlock( D3DSTATEBLOCKTYPE pType, dword* pBlockHandle ) { // Original Function Definition // HRESULT CreateStateBlock( D3DSTATEBLOCKTYPE d3dsbType, // LPDWORD lpdwBlockHandle); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreateStateBlock()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->CreateStateBlock( pType, (LPDWORD) pBlockHandle ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateStateBlock()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::DeleteStateBlock( dword pBlockHandle ) { // Original Function Definition // HRESULT DeleteStateBlock ( DWORD dwBlockHandle ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::DeleteStateBlock()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->DeleteStateBlock( (DWORD) pBlockHandle ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DeleteStateBlock()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::Destroy() { // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Destroy()", "TDX_NOTCREATED", "The "+Name+"::Destroy() method was called before being created successfully." ); return false; } // code that destroys the internal interfaces if (FOnDestroy) FOnDestroy(this); if (fLPDIRECT3DDEVICE7==NULL) { fErrorValue = TDX_ERROR; if (FOnError) FOnError( this, Name+"::Destroy()", "TDX_ERROR", "The "+Name+" component's internal fLPDIRECT3DDEVICE7 is NULL. Aborting the Destroy()." ); return false; } try { fLPDIRECT3DDEVICE7->Release(); } catch (...) { fErrorValue = TDX_ERROR; if (FOnError) FOnError( this, Name+"::Destroy()", "TDX_ERROR", "An exception occurred in fLPDIRECT3DDEVICE7->Release(). Check you are destroying all components in reverse order of creation." ); } // successful destruction fCreated = false; return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::DrawIndexedPrimitive( D3DPRIMITIVETYPE pPrimitiveType, dword pVertexTypeDesc, void* pVertices, dword pVertexCount, word* pIndices, dword pIndexCount, dword pFlags ) { // Original Function Definition // HRESULT DrawIndexedPrimitive( // D3DPRIMITIVETYPE d3dptPrimitiveType, // DWORD dwVertexTypeDesc, // LPVOID lpvVertices, // DWORD dwVertexCount, // LPWORD lpwIndices, // DWORD dwIndexCount, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::DrawIndexedPrimitive()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->DrawIndexedPrimitive( pPrimitiveType, (DWORD) pVertexTypeDesc, (LPVOID) pVertices, (DWORD) pVertexCount, (LPWORD) pIndices, (DWORD) pIndexCount, (DWORD) pFlags ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DrawIndexedPrimitive()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::DrawIndexedPrimitiveStrided( D3DPRIMITIVETYPE pPrimitiveType, dword pVertexTypeDesc, TD3DDrawPrimitiveStridedData* pVertexArray, dword pVertexCount, word* pIndices, dword pIndexCount, dword pFlags ) { // Original Function Definition // HRESULT DrawIndexedPrimitiveStrided( // D3DPRIMITIVETYPE d3dptPrimitiveType, // DWORD dwVertexTypeDesc, // LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray, // DWORD dwVertexCount, // LPWORD lpwIndices, // DWORD dwIndexCount, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::DrawIndexedPrimitiveStrided()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->DrawIndexedPrimitiveStrided( pPrimitiveType, (DWORD) pVertexTypeDesc, (pVertexArray==NULL) ? NULL : pVertexArray->Internal_D3DDRAWPRIMITIVESTRIDEDDATA_Ptr, (DWORD) pVertexCount, (LPWORD) pIndices, (DWORD) pIndexCount, (DWORD) pFlags ); // Translate Data returned from Function if (pVertexArray!=NULL) pVertexArray->Internal_D3DDRAWPRIMITIVESTRIDEDDATA_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DrawIndexedPrimitiveStrided()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::DrawIndexedPrimitiveVB( D3DPRIMITIVETYPE pPrimitiveType, TDx_3DVertexBuffer* pD3DVertexBuffer, word pStartVertex, dword pNumVertices, word* pIndices, dword pIndexCount, dword pFlags ) { // Original Function Definition // HRESULT DrawIndexedPrimitiveVB( // D3DPRIMITIVETYPE d3dptPrimitiveType, // LPDIRECT3DVERTEXBUFFER7 lpd3dVertexBuffer, // WORD dwStartVertex, // DWORD dwNumVertices, // LPWORD lpwIndices, // DWORD dwIndexCount, // DWORD dwFlags); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::DrawIndexedPrimitiveVB()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->DrawIndexedPrimitiveVB( pPrimitiveType, (pD3DVertexBuffer==NULL) ? NULL : pD3DVertexBuffer->Internal_LPDIRECT3DVERTEXBUFFER7, (WORD) pStartVertex, (DWORD) pNumVertices, (LPWORD) pIndices, (DWORD) pIndexCount, (DWORD) pFlags ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DrawIndexedPrimitiveVB()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::DrawPrimitive( D3DPRIMITIVETYPE pPrimitiveType, dword pVertexTypeDesc, void* pVertices, dword pVertexCount, dword pFlags ) { // Original Function Definition // HRESULT DrawPrimitive( // D3DPRIMITIVETYPE dptPrimitiveType, // DWORD dwVertexTypeDesc, // LPVOID lpvVertices, // DWORD dwVertexCount, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::DrawPrimitive()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->DrawPrimitive( pPrimitiveType, (DWORD) pVertexTypeDesc, (LPVOID) pVertices, (DWORD) pVertexCount, (DWORD) pFlags ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DrawPrimitive()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::DrawPrimitiveStrided( D3DPRIMITIVETYPE pPrimitiveType, dword pVertexTypeDesc, TD3DDrawPrimitiveStridedData* pVertexArray, dword pVertexCount, dword pFlags ) { // Original Function Definition // HRESULT DrawPrimitiveStrided( // D3DPRIMITIVETYPE dptPrimitiveType, // DWORD dwVertexTypeDesc, // LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray, // DWORD dwVertexCount, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::DrawPrimitiveStrided()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->DrawPrimitiveStrided( pPrimitiveType, (DWORD) pVertexTypeDesc, (pVertexArray==NULL) ? NULL : pVertexArray->Internal_D3DDRAWPRIMITIVESTRIDEDDATA_Ptr, (DWORD) pVertexCount, (DWORD) pFlags ); // Translate Data returned from Function if (pVertexArray!=NULL) pVertexArray->Internal_D3DDRAWPRIMITIVESTRIDEDDATA_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DrawPrimitiveStrided()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::DrawPrimitiveVB( D3DPRIMITIVETYPE pPrimitiveType, TDx_3DVertexBuffer* pVertexBuffer, dword pStartVertex, dword pNumVertices, dword pFlags ) { // Original Function Definition // HRESULT DrawPrimitiveVB( // D3DPRIMITIVETYPE d3dptPrimitiveType, // LPDIRECT3DVERTEXBUFFER7 lpd3dVertexBuffer, // DWORD dwStartVertex, // DWORD dwNumVertices, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::DrawPrimitiveVB()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->DrawPrimitiveVB( pPrimitiveType, (pVertexBuffer==NULL) ? NULL : pVertexBuffer->Internal_LPDIRECT3DVERTEXBUFFER7, (DWORD) pStartVertex, (DWORD) pNumVertices, (DWORD) pFlags ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DrawPrimitiveVB()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::EndScene() { // Original Function Definition // HRESULT EndScene(); // // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::EndScene()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->EndScene( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::EndScene()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::EndStateBlock( dword* pBlockHandle ) { // Original Function Definition // HRESULT EndStateBlock( // LPDWORD lpdwBlockHandle // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::EndStateBlock()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->EndStateBlock( (LPDWORD) pBlockHandle ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::EndStateBlock()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::EnumTextureFormats( void* pArg ) { // Original Function Definition // HRESULT EnumTextureFormats( // LPD3DENUMPIXELFORMATSCALLBACK lpd3dEnumPixelProc, // LPVOID lpArg // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::EnumTextureFormats()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function TDx_3DDevice_OnEnumTextureFormatsOwner = this; fErrorValue = fLPDIRECT3DDEVICE7->EnumTextureFormats( Internal_EnumTextureFormatsCallback, (LPVOID) pArg ); TDx_3DDevice_OnEnumTextureFormatsOwner = NULL; // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::EnumTextureFormats()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::GetCaps( TD3DDeviceDesc* pD3DDevDesc ) { // Original Function Definition // HRESULT GetCaps( LPD3DDEVICEDESC7 lpD3DDevDesc, ); // // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetCaps()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->GetCaps( (pD3DDevDesc==NULL) ? NULL : pD3DDevDesc->Internal_D3DDEVICEDESC7_Ptr ); // Translate Data returned from Function if (pD3DDevDesc!=NULL) pD3DDevDesc->Internal_D3DDEVICEDESC7_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetCaps()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::GetClipPlane( dword pIndex, D3DVALUE* pPlaneEquation ) { // Original Function Definition // HRESULT GetClipPlane( // DWORD dwIndex, // D3DVALUE* pPlaneEquation // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetClipPlane()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->GetClipPlane( (DWORD) pIndex, pPlaneEquation ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetClipPlane()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::GetClipStatus( TD3DClipStatus* pD3DClipStatus ) { // Original Function Definition // HRESULT GetClipStatus( // LPD3DCLIPSTATUS lpD3DClipStatus // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetClipStatus()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->GetClipStatus( (pD3DClipStatus==NULL) ? NULL : pD3DClipStatus->Internal_D3DCLIPSTATUS_Ptr ); // Translate Data returned from Function if (pD3DClipStatus!=NULL) pD3DClipStatus->Internal_D3DCLIPSTATUS_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetClipStatus()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::GetDirect3D( TDx_3D* pD3D ) { // Original Function Definition // HRESULT GetDirect3D( // LPDIRECT3D7 *lplpD3D // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetDirect3D()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->GetDirect3D( (pD3D==NULL) ? NULL : pD3D->Internal_LPDIRECT3D7_Ptr ); // Translate Data returned from Function if (pD3D!=NULL) pD3D->Internal_LPDIRECT3D7_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetDirect3D()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::GetInfo( dword pDevInfoID, void* pDevInfoStruct, dword pSize ) { // Original Function Definition // HRESULT GetInfo( // DWORD dwDevInfoID, // LPVOID pDevInfoStruct, // DWORD dwSize // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetInfo()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->GetInfo( (DWORD) pDevInfoID, (LPVOID) pDevInfoStruct, (DWORD) pSize ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetInfo()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::GetLight( dword pLightIndex, TD3DLight* pLight ) { // Original Function Definition // HRESULT GetLight( // DWORD dwLightIndex, // LPD3DLIGHT7 lpLight // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetLight()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->GetLight( (DWORD) pLightIndex, (pLight==NULL) ? NULL : pLight->Internal_D3DLIGHT7_Ptr ); // Translate Data returned from Function if (pLight!=NULL) pLight->Internal_D3DLIGHT7_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetLight()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::GetLightEnable( dword pLightIndex, bool* pEnable ) { // Original Function Definition // HRESULT GetLightEnable( // DWORD dwLightIndex, // BOOL* pbEnable // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetLightEnable()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->GetLightEnable( (DWORD) pLightIndex, (BOOL*) pEnable ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetLightEnable()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::GetMaterial( TD3DMaterial* pMaterial ) { // Original Function Definition // HRESULT GetMaterial( // LPD3DMATERIAL7 lpMaterial // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetMaterial()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->GetMaterial( (pMaterial==NULL) ? NULL : pMaterial->Internal_D3DMATERIAL7_Ptr ); // Translate Data returned from Function if (pMaterial!=NULL) pMaterial->Internal_D3DMATERIAL7_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetMaterial()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::GetRenderState( D3DRENDERSTATETYPE pRenderStateType, dword* pRenderState ) { // Original Function Definition // HRESULT GetRenderState( // D3DRENDERSTATETYPE dwRenderStateType, // LPDWORD lpdwRenderState // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetRenderState()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->GetRenderState( pRenderStateType, (LPDWORD) pRenderState ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetRenderState()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::GetRenderTarget( TDx_DrawSurface* pRenderTarget ) { // Original Function Definition // HRESULT GetRenderTarget( // LPDIRECTDRAWSURFACE7 *lplpRenderTarget // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetRenderTarget()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->GetRenderTarget( (pRenderTarget==NULL) ? NULL : pRenderTarget->Internal_LPDIRECTDRAWSURFACE7_Ptr ); // Translate Data returned from Function if (pRenderTarget!=NULL) pRenderTarget->Internal_LPDIRECTDRAWSURFACE7_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetRenderTarget()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::GetTexture( dword pStage, TDx_DrawSurface* pTexture ) { // Original Function Definition // HRESULT GetTexture( // DWORD dwStage, // LPDIRECTDRAWSURFACE7* lplpTexture // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetTexture()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->GetTexture( (DWORD) pStage, (pTexture==NULL) ? NULL : pTexture->Internal_LPDIRECTDRAWSURFACE7_Ptr ); // Translate Data returned from Function if (pTexture!=NULL) pTexture->Internal_LPDIRECTDRAWSURFACE7_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetTexture()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::GetTextureStageState( dword pStage, D3DTEXTURESTAGESTATETYPE pState, dword* pValue ) { // Original Function Definition // HRESULT GetTextureStageState( // DWORD dwStage, // D3DTEXTURESTAGESTATETYPE dwState, // LPDWORD lpdwValue // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetTextureStageState()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->GetTextureStageState( (DWORD) pStage, pState, (LPDWORD) pValue ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetTextureStageState()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::GetTransform( D3DTRANSFORMSTATETYPE pTransformStateType, TD3DMatrix* pD3DMatrix ) { // Original Function Definition // HRESULT GetTransform( // D3DTRANSFORMSTATETYPE dtstTransformStateType, // LPD3DMATRIX lpD3DMatrix // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetTransform()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->GetTransform( pTransformStateType, (pD3DMatrix==NULL) ? NULL : pD3DMatrix->Internal_D3DMATRIX_Ptr ); // Translate Data returned from Function if (pD3DMatrix!=NULL) pD3DMatrix->Internal_D3DMATRIX_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetTransform()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::GetViewPort( TD3DViewPort* pViewport ) { // Original Function Definition // HRESULT GetViewport( // LPD3DVIEWPORT7 lpViewport // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetViewPort()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->GetViewport( (pViewport==NULL) ? NULL : pViewport->Internal_D3DVIEWPORT7_Ptr ); // Translate Data returned from Function if (pViewport!=NULL) pViewport->Internal_D3DVIEWPORT7_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetViewPort()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- HRESULT __stdcall TDx_3DDevice::Internal_EnumTextureFormatsCallback( LPDDPIXELFORMAT pDDPixFmt, LPVOID pContext ) { // Original Function Definition //HRESULT CALLBACK D3DEnumTextureFormatsCallback( // LPDDPIXELFORMAT lpDDPixFmt, // LPVOID lpContext //); // Allocate temporary storage for converted data TDDPixelFormat* PixelFormat = new TDDPixelFormat( TDx_3DDevice_OnEnumTextureFormatsOwner ); if (PixelFormat==NULL) { if (TDx_3DDevice_OnEnumTextureFormatsOwner->FOnError) TDx_3DDevice_OnEnumTextureFormatsOwner->FOnError( TDx_3DDevice_OnEnumTextureFormatsOwner, TDx_3DDevice_OnEnumTextureFormatsOwner->Name+"::Internal_OnEnumZBufferFormatsCallback()", "TDX_ERROR", "Could not create a temporary TDDPixelFormat component." ); return D3DENUMRET_CANCEL; } // Translate Parameters before calling Original Function PixelFormat->ArraySize = 1; if (PixelFormat->ArraySize==1) CopyMemory( PixelFormat->Internal_DDPIXELFORMAT_Ptr, pDDPixFmt, sizeof(DDPIXELFORMAT) ); void* context = pContext; // transfer to the Callback Event (if it exists) bool finished = false; if (TDx_3DDevice_OnEnumTextureFormatsOwner->OnEnumTextureFormats) TDx_3DDevice_OnEnumTextureFormatsOwner->OnEnumTextureFormats( TDx_3DDevice_OnEnumTextureFormatsOwner,PixelFormat, context, finished ); // cleanup delete PixelFormat; // Finished, return FALSE to abort if (finished) return FALSE; return TRUE; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::LightEnable( dword pLightIndex, bool pEnable ) { // Original Function Definition // HRESULT LightEnable( // DWORD dwLightIndex, // BOOL bEnable ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::LightEnable()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Translate Parameters before calling Original Function BOOL TempEnable = (pEnable) ? TRUE : FALSE; // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->LightEnable( (DWORD) pLightIndex, TempEnable ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::LightEnable()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::Load( TDx_DrawSurface* pDestTex, POINT* pDestPoint, TDx_DrawSurface* pSrcTex, TRect* pSrcRect, dword pFlags ) { // Original Function Definition // HRESULT Load( // LPDIRECTDRAWSURFACE7 lpDestTex, // LPPOINT lpDestPoint, // LPDIRECTDRAWSURFACE7 lpSrcTex, // LPRECT lprcSrcRect, // DWORD dwFlags); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Load()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Translate Parameters before calling Original Function RECT TempSrcRect; LPRECT TempSrcRect_Ptr; if (pSrcRect==NULL) { TempSrcRect_Ptr = NULL; } else { TempSrcRect.top = pSrcRect->Top; TempSrcRect.left = pSrcRect->Left; TempSrcRect.right = pSrcRect->Right; TempSrcRect.bottom = pSrcRect->Bottom; TempSrcRect_Ptr = &TempSrcRect; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->Load( (pDestTex==NULL) ? NULL : pDestTex->Internal_LPDIRECTDRAWSURFACE7, (LPPOINT) pDestPoint, (pSrcTex==NULL) ? NULL : pSrcTex->Internal_LPDIRECTDRAWSURFACE7, TempSrcRect_Ptr, (DWORD) pFlags ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Load()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::MultiplyTransform( D3DTRANSFORMSTATETYPE pTransformStateType, TD3DMatrix* pD3DMatrix ) { // Original Function Definition // HRESULT MultiplyTransform( // D3DTRANSFORMSTATETYPE dtstTransformStateType, // LPD3DMATRIX lpD3DMatrix // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::MultiplyTransform()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->MultiplyTransform( pTransformStateType, (pD3DMatrix==NULL) ? NULL : pD3DMatrix->Internal_D3DMATRIX_Ptr ); // Translate Data returned from Function if (pD3DMatrix!=NULL) pD3DMatrix->Internal_D3DMATRIX_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::MultiplyTransform()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::PreLoad( TDx_DrawSurface* pTexture ) { // Original Function Definition // HRESULT PreLoad( // LPDIRECTDRAWSURFACE7 lpddsTexture); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::PreLoad()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->PreLoad( (pTexture==NULL) ? NULL : pTexture->Internal_LPDIRECTDRAWSURFACE7 ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::PreLoad()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::SetClipPlane( dword pIndex, D3DVALUE* pPlaneEquation ) { // Original Function Definition // HRESULT SetClipPlane( // DWORD dwIndex, // D3DVALUE* pPlaneEquation); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetClipPlane()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->SetClipPlane( (DWORD) pIndex, pPlaneEquation ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetClipPlane()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::SetClipStatus( TD3DClipStatus* pD3DClipStatus ) { // Original Function Definition // HRESULT SetClipStatus( // LPD3DCLIPSTATUS lpD3DClipStatus // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetClipStatus()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->SetClipStatus( (pD3DClipStatus==NULL) ? NULL : pD3DClipStatus->Internal_D3DCLIPSTATUS_Ptr ); // Translate Data returned from Function if (pD3DClipStatus!=NULL) pD3DClipStatus->Internal_D3DCLIPSTATUS_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetClipStatus()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::SetLight( dword pLightIndex, TD3DLight* pLight ) { // Original Function Definition // HRESULT SetLight( // DWORD dwLightIndex, // LPD3DLIGHT7 lpLight // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetLight()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->SetLight( (DWORD) pLightIndex, (pLight==NULL) ? NULL : pLight->Internal_D3DLIGHT7_Ptr ); // Translate Data returned from Function if (pLight!=NULL) pLight->Internal_D3DLIGHT7_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetLight()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::SetMaterial( TD3DMaterial* pMaterial ) { // Original Function Definition // HRESULT SetMaterial( // LPD3DMATERIAL7 lpMaterial // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetMaterial()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->SetMaterial( (pMaterial==NULL) ? NULL : pMaterial->Internal_D3DMATERIAL7_Ptr ); // Translate Data returned from Function if (pMaterial!=NULL) pMaterial->Internal_D3DMATERIAL7_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetMaterial()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::SetRenderState( D3DRENDERSTATETYPE pRenderStateType, dword pRenderState ) { // Original Function Definition // HRESULT SetRenderState( // D3DRENDERSTATETYPE dwRenderStateType, // DWORD dwRenderState // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetRenderState()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->SetRenderState( pRenderStateType, (DWORD) pRenderState ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetRenderState()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::SetRenderTarget( TDx_DrawSurface* pNewRenderTarget ) { // Original Function Definition // HRESULT SetRenderTarget( // LPDIRECTDRAWSURFACE7 lpNewRenderTarget, // DWORD dwFlags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetRenderTarget()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->SetRenderTarget( (pNewRenderTarget==NULL) ? NULL : pNewRenderTarget->Internal_LPDIRECTDRAWSURFACE7, 0 ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetRenderTarget()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::SetTexture( dword pStage, TDx_DrawSurface* pTexture ) { // Original Function Definition // HRESULT SetTexture( // DWORD dwStage, // LPDIRECTDRAWSURFACE7 lpTexture // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetTexture()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->SetTexture( (DWORD) pStage, (pTexture==NULL) ? NULL : pTexture->Internal_LPDIRECTDRAWSURFACE7 ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetTexture()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::SetTextureStageState( dword pStage, D3DTEXTURESTAGESTATETYPE pState, dword pValue ) { // Original Function Definition // HRESULT SetTextureStageState( // DWORD dwStage, // D3DTEXTURESTAGESTATETYPE dwState, // DWORD dwValue // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetTextureStageState()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->SetTextureStageState( (DWORD) pStage, pState, (DWORD) pValue ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetTextureStageState()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::SetTransform( D3DTRANSFORMSTATETYPE pTransformStateType, TD3DMatrix* pD3DMatrix ) { // Original Function Definition // HRESULT SetTransform( // D3DTRANSFORMSTATETYPE dtstTransformStateType, // LPD3DMATRIX lpD3DMatrix // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetTransform()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->SetTransform( pTransformStateType, (pD3DMatrix==NULL) ? NULL : pD3DMatrix->Internal_D3DMATRIX_Ptr ); // Translate Data returned from Function if (pD3DMatrix!=NULL) pD3DMatrix->Internal_D3DMATRIX_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetTransform()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::SetViewPort( TD3DViewPort* pViewport ) { // Original Function Definition // HRESULT SetViewport( // LPD3DVIEWPORT7 lpViewport // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetViewPort()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->SetViewport( (pViewport==NULL) ? NULL : pViewport->Internal_D3DVIEWPORT7_Ptr ); // Translate Data returned from Function if (pViewport!=NULL) pViewport->Internal_D3DVIEWPORT7_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetViewPort()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // 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. // -------------------------------------------------------------------------- bool __fastcall TDx_3DDevice::ValidateDevice( dword* pPasses ) { // Original Function Definition // HRESULT ValidateDevice( // LPDWORD lpdwPasses // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::ValidateDevice()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = fLPDIRECT3DDEVICE7->ValidateDevice( (LPDWORD) pPasses ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::ValidateDevice()", TDx_3DI_Library_ErrorString(fErrorValue), TDx_3DI_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Internal Interface Access // -------------------------------------------------------------------------- LPDIRECT3DDEVICE7 __fastcall TDx_3DDevice::FGetInternal_LPDIRECT3DDEVICE7() { return fLPDIRECT3DDEVICE7; } // -------------------------------------------------------------------------- LPDIRECT3DDEVICE7* __fastcall TDx_3DDevice::FGetInternal_LPDIRECT3DDEVICE7_Ptr() { return &fLPDIRECT3DDEVICE7; } // -------------------------------------------------------------------------- void __fastcall TDx_3DDevice::FSetInternal_LPDIRECT3DDEVICE7( LPDIRECT3DDEVICE7 pLPDIRECT3DDEVICE7 ) { if (!fCreated) { fLPDIRECT3DDEVICE7 = pLPDIRECT3DDEVICE7; fCreated = (fLPDIRECT3DDEVICE7!=NULL); } } // -------------------------------------------------------------------------- void __fastcall TDx_3DDevice::Internal_LPDIRECT3DDEVICE7_Update() { fCreated = (fLPDIRECT3DDEVICE7!=NULL); } // -------------------------------------------------------------------------- LPDIRECT3DDEVICE __fastcall TDx_3DDevice::FGetInternal_LPDIRECT3DDEVICE() { return fLPDIRECT3DDEVICE; } // -------------------------------------------------------------------------- LPDIRECT3DDEVICE* __fastcall TDx_3DDevice::FGetInternal_LPDIRECT3DDEVICE_Ptr() { return &fLPDIRECT3DDEVICE; } // -------------------------------------------------------------------------- void __fastcall TDx_3DDevice::FSetInternal_LPDIRECT3DDEVICE( LPDIRECT3DDEVICE pLPDIRECT3DDEVICE ) { if (!fCreated) { fLPDIRECT3DDEVICE = pLPDIRECT3DDEVICE; fCreated = (fLPDIRECT3DDEVICE!=NULL); } } // -------------------------------------------------------------------------- void __fastcall TDx_3DDevice::Internal_LPDIRECT3DDEVICE_Update() { fCreated = (fLPDIRECT3DDEVICE7!=NULL); } // --------------------------------------------------------------------------