// -------------------------------------------------------------------------- // ========================================================================== // 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) 2002 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 ApplyStateBlock method is used to ...The // IDirect3DDevice7::ApplyStateBlock method applies an existing // device-state block to the rendering device. // Params: pBlockHandle - // The BlockHandle parameter ...Handle to the device state block // to be executed, as returned by a previous call to the // IDirect3DDevice7::EndStateBlock method. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::BeginScene method begins a scene. // Applications must call this method before performing any // rendering, and must call IDirect3DDevice3::EndScene when // rendering is complete, and before calling // IDirect3DDevice::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 BeginStateBlock method is used to ...The // IDirect3DDevice7::BeginStateBlock method signals Direct3D to // begin recording a device state block. // -------------------------------------------------------------------------- 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 CaptureStateBlock method is used to ...The // IDirect3DDevice7::CaptureStateBlock method updates the values // within an existing state block to the values currently set // for the device. // Params: pBlockHandle - // The BlockHandle parameter ...Handle to the state block into // which the current device state is captured. // -------------------------------------------------------------------------- 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 Clear method is used to ... // Params: pCount - // The Count parameter ...Number of rectangles in the array at // lpRects. If you set lpRects to NULL, this parameter must be // set to 0. // pRects - // The Rects parameter ...Array of D3DRECT structures that // describe the rectangles to be cleared. Set a rectangle to the // dimensions of the rendering target to clear the entire // surface. Each rectangle uses screen coordinates that // correspond to points on the render target surface. // Coordinates are clipped to the bounds of the viewport // rectangle. This parameter can be set to NULL to indicate that // the entire viewport rectangle is to be cleared. // pFlags - // The Flags parameter ...Flags indicating which surfaces should // be cleared. This parameter can be any combination of the // following flags, but at least one flag must be used: // Flags: // D3DCLEAR_STENCIL - // The D3DCLEAR_STENCIL Flag is used to...Clear the // stencil buffer to the value in the dwStencil parameter. // D3DCLEAR_TARGET - // The D3DCLEAR_TARGET Flag is used to...Clear the // rendering target to the color in the dwColor parameter. // D3DCLEAR_ZBUFFER - // The D3DCLEAR_ZBUFFER Flag is used to...Clear the depth // buffer to the value in the dvZ parameter. // pColor - // The Color parameter ...A 32-bit RGBA color value to which the // render target surface is cleared. // pZ - // The Z parameter ...New z value that this method stores in the // depth buffer. This parameter can be in the range from 0.0 // through 1.0 (for z-based or w-based depth buffers). A value // of 0.0 represents the nearest distance to the viewer, and 1.0 // the farthest distance. // pStencil - // The Stencil parameter ...Integer value to store in each // stencil-buffer entry. This parameter can be in the range from // 0 through 2n#1, where n is the bit depth of the stencil // buffer. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::ComputeSphereVisibility method // calculates the visibility (complete, partial, or no // visibility) of an array spheres within the current viewport // for this device. // Params: pCenters - // lpCenters // Array of D3DVECTOR structures describing the center point for // each sphere, in world-space coordinates... array wrapper // d3dvector.,, // pRadii - // lpRadii // Array of D3DVALUE variables that represent the radius for // each sphere. // array wrapper D3DValue... // pNumSpheres - // dwNumSpheres // Number of spheres. This value must be greater than zero. // pReturnValues - // lpdwReturnValues // Array of DWORD values. The array need not be initialized, but // it must be large enough to contain a DWORD for each sphere // being tested. When the method returns, each element in the // array contains a combination of the following flags that // describe the visibility of that sphere within the current // viewport for this device:... // -------------------------------------------------------------------------- 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 CreateStateBlock method is used to ... // Params: pType - // The Type parameter ...Type of state data that the method // should capture. This parameter can be set to one of the // values defined in the D3DSTATEBLOCKTYPE enumerated type. // pBlockHandle - // The BlockHandle parameter ...Address of a variable to contain // the state block handle if the method succeeds. // -------------------------------------------------------------------------- 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 DeleteStateBlock method is used to ...The // IDirect3DDevice7::DeleteStateBlock method deletes a // previously recorded device state block. // Params: pBlockHandle - // The BlockHandle parameter ...Handle to the device state block // to be deleted, as returned by a previous call to the // IDirect3DDevice7::EndStateBlock method. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::DrawIndexedPrimitive method renders the // specified geometric primitive based on indexing into an array // of vertices. // // // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value can be one of the // following values: // // D3DERR_INVALIDRAMPTEXTURE // D3DERR_INVALIDPRIMITIVETYPE // D3DERR_INVALIDVERTEXTYPE // DDERR_INVALIDPARAMS // DDERR_WASSTILLDRAWING // Params: pPrimitiveType - // d3dptPrimitiveType // Type of primitive to be rendered by this command. This must // be one of the members of the D3DPRIMITIVETYPE enumerated // type. // Note that the D3DPT_POINTLIST member of D3DPRIMITIVETYPE is // not indexed.... // pVertexTypeDesc - // dwVertexTypeDesc // A combination of flexible vertex format flags that describes // the vertex format for this set of primitives... // pVertices - // lpvVertices // Pointer to the list of vertices to be used in the primitive // sequence... // pVertexCount - // dwVertexCount // Defines the number of vertices in the list. // Notice that this parameter is used differently from the // dwVertexCount parameter in the // IDirect3DDevice3::DrawPrimitive method. In that method, the // dwVertexCount parameter gives the number of vertices to draw, // but here it gives the total number of vertices in the array // pointed to by the lpvVertices parameter. When you call // IDirect3DDevice3::DrawIndexedPrimitive, you specify the // number of vertices to draw in the dwIndexCount parameter... // pIndices - // lpwIndices // Pointer to a list of WORDs that are to be used to index into // the specified vertex list when creating the geometry to // render.... // pIndexCount - // dwIndexCount // Specifies the number of indices provided for creating the // geometry. The maximum number of indices allowed is 65,535 // (0xFFFF).... // pFlags - // Flags defining how the primitive is drawn. Typically set to // zero. // Flags: // D3DDP_WAIT - // D3DDP_WAIT // Causes the method to wait until the polygons have been // rendered before it returns, instead of returning as // soon as the polygons have been sent to the card. (On // scene-capture cards, the method returns as soon as the // card responds.) This flag is typically used for // debugging. Applications should not attempt to use this // flag to ensure that a 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 IDirect3DDevice3::DrawIndexedPrimitiveStrided method // renders a geometric primitive based on indexing into an array // of strided vertices. For more information, see Strided Vertex // Format... // // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value can be one of the // following values: // // D3DERR_INVALIDRAMPTEXTURE // D3DERR_INVALIDPRIMITIVETYPE // D3DERR_INVALIDVERTEXTYPE // DDERR_INVALIDPARAMS // DDERR_WASSTILLDRAWING // // Params: pPrimitiveType - // d3dptPrimitiveType // Type of primitive to be rendered by this command. This must // be one of the members of the D3DPRIMITIVETYPE enumerated // type. // Note that the D3DPT_POINTLIST member of D3DPRIMITIVETYPE is // not indexed.... // pVertexTypeDesc - // dwVertexTypeDesc... // A combination of flexible vertex format flags vertex format // for this primitive. // pVertexArray - // lpVertexArray // Array of D3DDRAWPRIMITIVESTRIDEDDATA structures that contains // the vertices for this primitive, in the format specified by // the flags in dwVertexTypeDesc.... // pVertexCount - // dwVertexCount // Defines the number of vertices in the list. // Notice that this parameter is used differently from the // dwVertexCount parameter in the // IDirect3DDevice3::DrawPrimitive method. In that method, the // dwVertexCount parameter gives the number of vertices to draw, // but here it gives the total number of vertices in the array // pointed to by the lpVertexArray parameter. When you call // IDirect3DDevice3::DrawIndexedPrimitiveStrided, you specify // the number of vertices to draw in the dwIndexCount // parameter.... // pIndices - // lpwIndices // Pointer to a list of WORDs that are to be used to index into // the specified vertex list when creating the geometry to // render.... // pIndexCount - // dwIndexCount // Specifies the number of indices provided for creating the // geometry. The maximum number of indices allowed is 65,535 // (0xFFFF).... // pFlags - // dwFlags // One or more of the following flags defining how the primitive // is drawn. Most applications will use a value of 0. // Flags: // D3DDP_WAIT - // The method will not return until rendering is // completed. // // Causes the method to wait until the polygons have been // rendered before it returns, instead of returning as // soon as the polygons have been sent to the card. (On // scene-capture cards, the method returns as soon as the // card responds.) This flag is typically used for // debugging. Applications should not attempt to use this // flag to ensure that a 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 IDirect3DDevice3::DrawIndexedPrimitiveVB method renders a // geometric primitive based on indexing into an array of // vertices within a vertex buffer. // success value DD_OK ????? // // If the method succeeds, the return value is DD_OK. // // If the method fails, the return value can be one of the // following values: // // D3DERR_INVALIDPRIMITIVETYPE // D3DERR_INVALIDVERTEXTYPE // D3DERR_VERTEXBUFFERLOCKED // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // DDERR_WASSTILLDRAWING // Params: pPrimitiveType - // d3dptPrimitiveType... // Type of primitive to be rendered by this command. This must // be one of the members of the D3DPRIMITIVETYPE enumerated // type. // Note that the D3DPT_POINTLIST member of D3DPRIMITIVETYPE is // not indexed. // pD3DVertexBuffer - // lpd3dVertexBuffer... // Address of the IDirect3DVertexBuffer interface for the vertex // buffer that contains the array of vertices. Vertices can be // transformed or untransformed, optimized or unoptimized. // pStartVertex - // The StartVertex parameter ...dwStartVertex // Index of the first vertex in the vertex buffer to be // rendered. // pNumVertices - // The NumVertices parameter ...Total number of vertices in the // vertex buffer to be rendered. // pIndices - // lpwIndices... // Address of an array of WORDs that will be used to index into // the vertices in the vertex buffer. // pIndexCount - // dwIndexCount... // The number of indices in the array at lpwIndices. The maximum // number of indices allowed is 65,535 (0xFFFF). // pFlags - // dwFlags... // One or more of the following flags defining how the primitive // is drawn: // Flags: // D3DDP_WAIT - // // Causes the method to wait until the polygons have been // rendered before it returns, instead of returning as // soon as the polygons have been sent to the card. (On // scene-capture cards, the method returns as soon as the // card responds.) This flag is typically used for // debugging. Applications should not attempt to use this // flag to ensure that a 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 IDirect3DDevice3::DrawPrimitive method renders the // specified array of vertices as a sequence of geometric // primitives of the specified type.... // Params: pPrimitiveType - // dptPrimitiveType... // Type of primitive to be rendered by this command. This must // be one of the members of the D3DPRIMITIVETYPE enumerated // type. // pVertexTypeDesc - // dwVertexTypeDesc... // A combination of flexible vertex format flags that describe // the vertex format used for this set of primitives. // pVertices - // lpvVertices... // Pointer to the array of vertices to be used in the primitive // sequence. // pVertexCount - // dwVertexCount... // The number of vertices in the array. The maximum number of // vertices allowed is 65,535 (0xFFFF). // pFlags - // dwFlags... // One or more of the following flags defining how the primitive // is drawn // Flags: // D3DDP_WAIT - // D3DDP_WAIT // Causes the method to wait until the polygons have been // rendered before it returns, instead of returning as // soon as the polygons have been sent to the card. (On // scene-capture cards, the method returns as soon as the // card responds.) This flag is typically used for // debugging. Applications should not attempt to use this // flag to ensure that a 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 IDirect3DDevice3::DrawPrimitiveStrided method renders the // specified array of strided vertices as a sequence of // geometric primitives. For more information, see Strided // Vertex Format.... // Params: pPrimitiveType - // PrimitiveType... // Type of primitive to be rendered by this command. This must // be one of the members of the D3DPRIMITIVETYPE enumerated // type. // pVertexTypeDesc - // dwVertexTypeDesc... // A combination of flexible vertex format flags that describe // the vertex format. // pVertexArray - // lpVertexArray... // Array of D3DDRAWPRIMITIVESTRIDEDDATA structures that contains // the vertices for this primitive. // pVertexCount - // dwVertexCount... // Number of vertices in the array at lpVertexArray. The maximum // number of vertices allowed is 65,535 (0xFFFF). // pFlags - // The Flags parameter is used to ..Zero to render the primitive // without waiting, or the following flag: . // Flags: // D3DDP_WAIT - // The D3DDP_WAIT Flag is used to...Causes the method to // wait until the polygons have been rendered before it // returns, instead of returning as soon as the polygons // have been sent to the card. (On scene-capture cards, // the method returns as soon as the card responds.) This // flag is typically used for debugging. Applications // should not attempt to use this flag to ensure that a // 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 IDirect3DDevice3::DrawPrimitiveVB method renders an array // of vertices in a vertex buffer as a sequence of geometric // primitives. // Params: pPrimitiveType - // d3dptPrimitiveType... // Type of primitive to be rendered by this command. This must // be one of the members of the D3DPRIMITIVETYPE enumerated // type. // pVertexBuffer - // lpd3dVertexBuffer.. // Address of the IDirect3DVertexBuffer interface for the vertex // buffer that contains the array of vertices. Vertices can be // transformed or untransformed, optimized or unoptimized. // pStartVertex - // dwStartVertex... // Index value of the first vertex in the primitive. The highest // possible starting index is 65,535 (0xFFFF). In debug builds, // specifying a starting index value that exceeds this limit // will cause the method to fail and return DDERR_INVALIDPARAMS. // pNumVertices - // dwNumVertices... // Number of vertices to be rendered. The maximum number of // vertices allowed is 65,535 (0xFFFF). // pFlags - // dwFlags... // One or more of the following flags defining how the primitive // is drawn: // Flags: // D3DDP_WAIT - // D3DDP_WAIT... // Causes the method to wait until the polygons have been // rendered before it returns, instead of returning as // soon as the polygons have been sent to the card. (On // scene-capture cards, the method returns as soon as the // card responds.) This flag is typically used for // debugging. Applications should not attempt to use this // flag to ensure that a 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 IDirect3DDevice3::EndScene method ends a scene that was // begun by calling the IDirect3DDevice3::BeginScene method.... // -------------------------------------------------------------------------- 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 EndStateBlock method is used to ...The // IDirect3DDevice7::EndStateBlock method signals Direct3D to // stop recording a device state block and retrieve a handle to // the state block. // Params: pBlockHandle - // The BlockHandle parameter ...Address of a variable to be // filled with the handle to the completed device state block. // This value is used with the IDirect3DDevice7::ApplyStateBlock // and IDirect3DDevice7::DeleteStateBlock methods. // Return Values // -------------------------------------------------------------------------- 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 IDirect3DDevice3::EnumTextureFormats method queries the // current driver for a list of supported texture formats... // Params: pArg - // lpArg... // Address of application-defined data passed to the callback // function. // // -------------------------------------------------------------------------- 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 IDirect3DDevice3::GetCaps method retrieves the // capabilities of the Direct3D device. // // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value can be one of the // following: // // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // // // Remarks // This method does not retrieve the capabilities of the display // device. To retrieve this information, use the // IDirectDraw7::GetCaps method. // // In previous versions of this interface, this method // simultaneously retrieved capabilities for hardware // abstraction layer (HAL) devices and hardware emulation layer // (HEL) devices by accepting pointers to the legacy // D3DDEVICEDESC structure. In the IDirect3DDevice7 interface, // this method only retrieves the capabilities of the device on // which the method is called. // Params: pD3DDevDesc - // The D3DDevDesc parameter ...lpD3DDevDesc // Address of the D3DDEVICEDESC7 structure to contain the // hardware features of the device. // -------------------------------------------------------------------------- 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 GetClipPlane method is used to ...The // IDirect3DDevice7::GetClipPlane method retrieves the // coefficients of a user-defined clipping plane for the device. // // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value is DDERR_INVALIDPARAMS. // This error indicates that the value in dwIndex exceeds the // maximum clipping plane index supported by the device or that // the array at pPlaneEquation is not large enough to contain // four floating-point values. // // Remarks // The coefficients that this method reports take the form of // the general plane equation. If the values in the array at // pPlaneEquation were labeled A, B, C, and D in the order that // they appear in the array, they would fit into the general // plane equation so that Ax + By + Cz + D = 0. A point with // homogeneous coordinates (x, y, z, w) is visible in the half // space of the plane if Ax + By + Cz + Dw >= 0. Points that // exist on or behind the clipping plane are clipped from the // scene. // // The plane equation used by this method exists in world space // and is set by a previous call to the // IDirect3DDevice7::SetClipPlane method. // // Params: pIndex - // The Index parameter ...dwIndex // Index of the clipping plane for which the plane equation // coefficients are retrieved. // pPlaneEquation - // The PlaneEquation parameter ...pPlaneEquation // Address of a four-element array of values that represent the // coefficients of the clipping plane, in the form of the // general plane equation. See remarks. // -------------------------------------------------------------------------- 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 GetClipStatus method is used to ...The // IDirect3DDevice7::GetClipStatus method gets the current clip // status. // // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value is an error. The method // returns DDERR_INVALIDPARAMS if one of the arguments is // invalid. // Params: pD3DClipStatus - // The D3DClipStatus parameter ...lpD3DClipStatus // Address of a D3DCLIPSTATUS structure that describes the // current clip status. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::GetDirect3D method retrieves the // Direct3D object for this device. // // // Params: pD3D - // lplpD3D // Address that will contain a pointer to the Direct3D object's // IDirect3D3 interface when the method returns. // -------------------------------------------------------------------------- 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 GetInfo method is used to ...The // IDirect3DDevice7::GetInfo method retrieves information about // the rendering device. Information can pertain to Direct3D or // the underlying device driver. // // // // Return Values // If the method succeeds, the return value is D3D_OK. This // method returns S_FALSE on retail builds of DirectX. // // If the method fails, the return value can be one of the // following error values: // // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // // // Remarks // This method makes it possible for drivers to declare specific // information types, and corresponding structures, that are not // documented in this SDK. // // This method executes synchronously and can negatively impact // your application's performance when it executes slowly. Do // not call this method during scene rendering (between calls to // IDirect3DDevice7::BeginScene and IDirect3DDevice7::EndScene). // // This method is intended to be used for performance tracking // and debugging during product development (on the debug // version of DirectX). The method can succeed, returning // S_FALSE, without retrieving device data. This occurs when the // retail version of the DirectX runtime is installed on the // host system. // Params: pDevInfoID - // The DevInfoID parameter ..Flags indicating the type of device // information structure at pDevInfoStruct. This parameter can // be set to one of the following flags: // Flags: // D3DDEVINFOID_D3DTEXTUREMANAGER - // The D3DDEVINFOID_D3DTEXTUREMANAGER Flag is used // to...The structure at pDevInfoStruct is a // D3DDEVINFO_TEXTUREMANAGER structure that contains // information about texture management that is performed // by Direct3D. // D3DDEVINFOID_TEXTUREMANAGER - // The D3DDEVINFOID_TEXTUREMANAGER Flag is used to...The // structure at pDevInfoStruct is a // D3DDEVINFO_TEXTUREMANAGER structure that contains // information about the texture management being // performed by the driver. If the driver does not manage // textures, information about texture management // performed by Direct3D is retrieved. // D3DDEVINFOID_TEXTURING - // The D3DDEVINFOID_TEXTURING Flag is used to...The // structure at pDevInfoStruct is a D3DDEVINFO_TEXTURING // structure that contains information about texturing // activity of the application. // pDevInfoStruct - // The DevInfoStruct parameter ....Address of a structure that // receives the specified device information if the call // succeeds. The type of structure, and how the data it contains // is to be interpreted, is determined by the flag in // dwDevInfoID. // pSize - // The Size parameter ...Size of the structure at // pDevInfoStruct, in bytes. // -------------------------------------------------------------------------- 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 GetLight method is used to ...The // IDirect3DDevice7::GetLight method retrieves a set of lighting // properties that this device uses. // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value is an error. The method // returns DDERR_INVALIDPARAMS if the lpLight parameter is // invalid. // // Remarks // This method was introduced with the IDirect3DDevice7 // interface. // // Unlike its predecessors, the IDirect3DDevice7 interface does // not use light objects. This method, and its use of the // D3DLIGHT7 structure to describe a set of lighting properties, // replaces the lighting semantics used by previous versions of // the device interface. // Params: pLightIndex - // The LightIndex parameter ...Zero-based index of the lighting // property set to be retrieved. // pLight - // The Light parameter ...Address of a D3DLIGHT7 structure that // is filled with the retrieved lighting-parameter set. // -------------------------------------------------------------------------- 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 GetLightEnable method is used to ...The // IDirect3DDevice7::GetLightEnable method retrieves the // activity status#enabled or disabled#for a set of lighting // parameters within a device. // // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value is an error. For a // complete list of Direct3D Immediate Mode error values and // descriptions, see Return Values. // Params: pLightIndex - // The LightIndex parameter ...Zero-based index of the set of // lighting parameters that are the target of this method. // pEnable - // The Enable parameter ...Address of a variable to be filled // with the status of the specified lighting parameters. After // the call, a nonzero value at this address indicates that the // specified lighting parameters are enabled; a value of 0 // indicates that they are disabled. // -------------------------------------------------------------------------- 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 GetMaterial method is used to ...The // IDirect3DDevice7::GetMaterial method retrieves the current // material properties for the device. // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value is an error. The method // returns DDERR_INVALIDPARAMS if the lpMaterial parameter is // invalid. // // Params: pMaterial - // The Material parameter ...Address of a D3DMATERIAL7 structure // to be filled with the currently set material properties. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::GetRenderState method gets a single // Direct3DDevice rendering state parameter. // Params: pRenderStateType - // dwRenderStateType // Device state variable that is being queried. This parameter // can be any of the members of the D3DRENDERSTATETYPE // enumerated type. // pRenderState - // lpdwRenderState // Address of a variable that will contain the Direct3DDevice // render state when the method returns. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::GetRenderTarget method retrieves a // pointer to the DirectDraw surface that is being used as a // render target. // Params: pRenderTarget - // lplpRenderTarget // Address that will contain a pointer to the // IDirectDrawSurface4 interface of the render target surface // for this device. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::GetTexture method retrieves a texture // assigned to a given stage for a device... // // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value can be one of the // following values: // // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // Params: pStage - // dwStage // Stage identifier of the texture to be retrieved. Stage // identifiers are zero-based. Currently, devices can have up to // 8 set textures, so the maximum allowable value allowed for // dwStage is 7. // pTexture - // lplpTexture // Address of a variable to be filled with a pointer to the // specified texture's IDirectDrawSurface7 interface if the call // succeeds. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::GetTextureStageState method retrieves a // state value for a currently assigned texture... // // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value can be one of the // following values: // // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // Params: pStage - // dwStage... // Stage identifier of the texture for which the state will be // retrieved. Stage identifiers are zero-based. Currently, // devices can have up to 8 set textures, so the maximum // allowable value allowed for dwStage is 7. // pState - // dwState... // Texture state to be retrieved. This parameter can be any // member of the D3DTEXTURESTAGESTATETYPE enumerated type. // pValue - // lpdwValue... // Address of a variable that will be filled with the retrieved // state value. The meaning of the retrieved value is determined // by the dwState parameter. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::GetTransform method gets a matrix // describing a transformation state. // Params: pTransformStateType - // dtstTransformStateType... // Device state variable that is being modified. This parameter // can be any of the members of the D3DTRANSFORMSTATETYPE // enumerated type. // pD3DMatrix - // lpD3DMatrix... // Address of a D3DMATRIX structure describing the // transformation. // -------------------------------------------------------------------------- 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 IDirect3DDevice7::GetViewport method retrieves the // viewport parameters currently set for the device.... // // // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value is an error. The method // returns DDERR_INVALIDPARAMS if the lpViewport parameter is // invalid. // // Remarks // Params: pViewport - // The Viewport parameter ...lpViewport // Address of a D3DVIEWPORT7 structure to be filled with the // current viewport parameters if the call succeeds. // -------------------------------------------------------------------------- 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 Internal_EnumTextureFormatsCallback method is used to ... // Params: pDDPixFmt - // The DDPixFmt parameter ... // pContext - // The Context parameter ... // -------------------------------------------------------------------------- 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 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 ); // Finished, return FALSE to abort if (finished) return FALSE; return TRUE; } // -------------------------------------------------------------------------- // Method: LightEnable() // Description: The LightEnable method is used to ... The // IDirect3DDevice7::LightEnable method enables or disables a // set of lighting parameters within a device. // // .If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value is an error. For a // complete list of Direct3D Immediate Mode error values and // descriptions, see Return Values. // // // Remarks // If you supply a value for dwLightIndex outside the range of // the light property sets currently assigned within the device, // the LightEnable method creates a light source with the // following properties and sets its enabled state to the value // specified in bEnable: // // Member Default // // dltType D3DLIGHT_DIRECTIONAL // dcvDiffuse (R:1, G:1, B:1, A:0) // dcvSpecular (R:0, G:0, B:0, A:0) // dcvAmbient (R:0, G:0, B:0, A:0) // dvPosition (0, 0, 0) // dvDirection (0, 0, 1) // dvRange 0 // dvFalloff 0 // dvAttenuation0 0 // dvAttenuation1 0 // dvAttenuation2 0 // dvTheta 0 // dvPhi 0 // Params: pLightIndex - // The LightIndex parameter ...dwLightIndex // Zero-based index of the set of lighting parameters that are // the target of this method // pEnable - // The Enable parameter ...bEnable // Value indicating if the set of lighting parameters are being // enabled or disabled. Set this parameter to TRUE to enable // lighting with the parameters at the specified index, or FALSE // to disable it. // -------------------------------------------------------------------------- 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 IDirect3DDevice7::Load method loads a rectangular area of // a source texture to a specified point in a destination // texture or to faces within a cubic environment map. // ... // // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value can be one of the // following values: // // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // // // Remarks // The destination texture can be used with any rendering // device, not just the one that created it. On hardware // devices, the load operation is hardware-accelerated. // // Loading textures into video memory by calling this method is // preferred over blit operations. // // This method copies all mip-levels, cubemap faces, palettes // and color keys from the source texture to the destination // texture. // // When using this method to load mipmaps, the following special // points apply: // // The destination texture surface can be a subset of the // mip-levels contained in the source texture. In this case, // only the mip-levels common to both textures are copied. This // is useful in implementing texture LOD. You can create a video // memory texture with only two mip-levels, then use this method // to copy those levels from a source texture that comprises the // entire set of mip-levels. // The source and destination surface pointers must point to // top-level surfaces. // When loading a subrectangle of a mipmap, the subrectangle // refers to the top-level surface in the mipmap chain, and is // divided by two for each lower mip-level. // Params: pDestTex - // The DestTex parameter ...Address of the IDirectDrawSurface7 // interface of the texture that receives image data from the // source texture. The destination texture can be a cubic // environment map. For complex texture surfaces like cubic // envionment maps and mipmaps, this must point to the top-level // surface. // pDestPoint - // The DestPoint parameter ...Address of a POINT structure that // describes the point at which the method loads the image data // onto the destination texture. Set this parameter to NULL when // the destination point should be the origin of the destination // texture. // pSrcTex - // The SrcTex parameter ...Address of the IDirect3DTexture7 // interface of the texture that contains the image data to be // loaded. For complex texture surfaces like cubic envionment // maps and mipmaps, this must point to the top-level surface. // pSrcRect - // The SrcRect parameter ...Address of a RECT structure that // describes the area within the source texture that the method // loads. Set this parameter to NULL when the source rectangle // should cover the entire source texture. // pFlags - // The Flags parameter ...Value indicating, in the case of a // cubic environment map, which face of the destination texture // is to receive the image data. This can be any combination of // the following flags. // 0 // Required if the destination texture is a managed texture. // DDSCAPS2_CUBEMAP_ALLFACES // All faces should be loaded with the image data within the // source texture. // DDSCAPS2_CUBEMAP_NEGATIVEX, DDSCAPS2_CUBEMAP_NEGATIVEY, or // DDSCAPS2_CUBEMAP_NEGATIVEZ // The negative x, y, or z faces should receive the image data. // DDSCAPS2_CUBEMAP_POSITIVEX, DDSCAPS2_CUBEMAP_POSITIVEY, or // DDSCAPS2_CUBEMAP_POSITIVEZ // The positive x, y, or z faces should receive the image data. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::MultiplyTransform method multiplies a // device's world, view, or projection matrices by a specified // matrix. The multiplication order is lpD3DMatrix times // dtstTransformStateType... // // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value is an error. The method // returns DDERR_INVALIDPARAMS if one of the arguments is // invalid. // // Remarks // An application might use the MultiplyTransform method to work // with hierarchies of transformations. For example, the // geometry and transformations describing an arm might be // arranged in the following hierarchy: // // shoulder_transformation // upper_arm geometry // elbow transformation // lower_arm geometry // wrist transformation // hand geometry // An application might use the following series of calls to // render this hierarchy. (Not all the parameters are shown in // this pseudocode.) // // IDirect3DDevice7::SetTransform(D3DTRANSFORMSTATE_WORLD, // shoulder_transform) // IDirect3DDevice7::DrawPrimitive(upper_arm) // IDirect3DDevice7::MultiplyTransform(D3DTRANSFORMSTATE_WORLD, // elbow_transform) // IDirect3DDevice7::DrawPrimitive(lower_arm) // IDirect3DDevice7::MultiplyTransform(D3DTRANSFORMSTATE_WORLD, // wrist_transform) // IDirect3DDevice7::DrawPrimitive(hand) // Params: pTransformStateType - // dtstTransformStateType... // A member of the D3DTRANSFORMSTATETYPE enumerated type that // identifies which device matrix is to be modified. The most // common setting, D3DTRANSFORMSTATE_WORLD, modifies the world // matrix, but you can specify that the method modify the view // or projection matrices if needed. // pD3DMatrix - // lpD3DMatrix... // Address of a D3DMATRIX structure that modifies the current // transformation. // -------------------------------------------------------------------------- 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 PreLoad method is used to ... // // The IDirect3DDevice7::Preload method instructs the Direct3D // texture manager to load a managed texture into video memory. // // Remarks // This method forces the system to load a managed texture into // video memory. If sufficient video memory is not available, // the system removes other textures to regain memory, then // loads the texture. The texture being loaded must be a managed // texture (created with the DDSCAPS2_TEXTUREMANAGE or // DDSCAPS2_D3DTEXTUREMANAGE flags). If not, the method fails // and returns DDERR_INVALIDPARAMS. // Params: pTexture - // The Texture parameter ...Address of the IDirectDrawSurface7 // interface for the texture surface to be loaded into 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 IDirect3DDevice7::SetClipPlane method sets the // coefficients of a user-defined clipping plane for the device. // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value is DDERR_INVALIDPARAMS. // This error indicates that the value in dwIndex exceeds the // maximum clipping plane index supported by the device or that // the array at pPlaneEquation is not large enough to contain // four floating-point values. // // Remarks // The coefficients that this method sets take the form of the // general plane equation. If the values in the array at // pPlaneEquation were labeled A, B, C, and D in the order that // they appear in the array, they would fit into the general // plane equation so that Ax + By + Cz + D = 0. A point with // homogeneous coordinates (x, y, z, w) is visible in the half // space of the plane if Ax + By + Cz + Dw >= 0. Points that // exist on or behind the clipping plane are clipped from the // scene. // // The plane equation used by this method exists in world space. // // This method does not enable the clipping plane equation being // set. To enable a clipping plane, set the corresponding bit in // the DWORD value applied to the D3DRENDERSTATE_CLIPPLANEENABLE // render state. // ... // Params: pIndex - // The Index parameter ...Index of the clipping plane for which // the plane equation coefficients are to be set. // pPlaneEquation - // The PlaneEquation parameter ...Address of a four-element // array of values that represent the coefficients of the // clipping plane, in the form of the general plane equation. // See remarks. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::SetClipStatus method sets the current // clip status. // // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value is an error. The method // returns DDERR_INVALIDPARAMS if one of the arguments is // invalid. // // // // Params: pD3DClipStatus - // lpD3DClipStatus // Address of a D3DCLIPSTATUS structure that describes the new // settings for the clip status. // -------------------------------------------------------------------------- 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 SetLight method is used to ...The // IDirect3DDevice7::SetLight method assigns a set of lighting // properties for this device. // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value can be one of the // following values: // // DDERR_INVALIDPARAMS // DDERR_OUTOFMEMORY // // See Also // IDirect3DDevice7::GetLight, IDirect3DDevice7::GetLightEnable, // IDirect3DDevice7::LightEnable // Params: pLightIndex - // The LightIndex parameter ...Zero-based index of the set of // lighting properties to be set. If a set of lighting // properties already exists at this index, it is overwritten by // the new properties in lpLight. // pLight - // The Light parameter ...Address of a D3DLIGHT7 structure that // contains the lighting-parameters 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 IDirect3DDevice7::SetMaterial method sets the material // properties for the device... // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value is an error. The method // returns DDERR_INVALIDPARAMS if the lpMaterial parameter is // invalid. // Params: pMaterial - // The Material parameter ...Address of a D3DMATERIAL7 structure // that describes the material properties to be set. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::SetRenderState method sets a single // Direct3DDevice rendering state parameter. // Params: pRenderStateType - // dwRenderStateType // Device state variable that is being modified. This parameter // can be any of the members of the D3DRENDERSTATETYPE // enumerated type. // pRenderState - // dwRenderState // New value for the Direct3DDevice render state. The meaning of // this parameter is dependent on the value specified for // dwRenderStateType. For example, if dwRenderStateType were // D3DRENDERSTATE_SHADEMODE, the second parameter would be one // of the members of the D3DSHADEMODE enumerated type. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::SetRenderTarget method permits the // application to easily route rendering output to a new // DirectDraw surface as a render target... // // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value is an error. The error // can be one of the following values: // // DDERR_INVALIDPARAMS // DDERR_INVALIDSURFACETYPE // // // Remarks // Do not use this method to set a new render target surface // with a depth buffer if the current render target does not // have a depth buffer. Likewise, you cannot use this method to // switch from a nondepth-buffered render target to a // depth-buffered render target. Attempts to do this fail in // debug builds and can exhibit unreliable behavior in retail // builds. Since both the new and the old render targets use // depth buffers, the depth buffer attached to the new render // target replaces the previous depth buffer for the context. // // Unlike this method's implementation in previous interfaces, // IDirect3DDevice7::SetRenderTarget does not invalidate the // current material or viewport for the device. // // Capabilities do not change with changes in the properties of // the render target surface. Both the Direct3D hardware // abstraction layer (HAL) and the software rasterizers have // only one opportunity to expose capabilities to the // application. The system cannot expose different sets of // capabilities, depending on the format of the destination // surface. // // If more than one depth buffer is attached to the render // target, this function fails. // Params: pNewRenderTarget - // lpNewRenderTarget... // Address of a IDirectDrawSurface4 interface for the surface // object that will be the new rendering target. This surface // must be created with the DDSCAPS_3DDEVICE capability. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::SetTexture method assigns a texture to // a given stage for a device. // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value can be one of the // following values: // // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // // // Remarks // This method method increments the reference count of the // texture surface being assigned. When the texture is no longer // needed, you should set the texture at the appropriate stage // to NULL. If you fail to do this, the surface will not be // released, resulting in a memory leak. // // Software devices do not support assigning a texture to more // than one texture stage at a time. // // In the legacy IDirect3DDevice3 interface, this method // accepted a pointer to an IDirect3DTexture2 interface. // Params: pStage - // dwStage // Stage identifier to which the texture will be set. Stage // identifiers are zero-based. Currently, devices can have up to // 8 set textures, so the maximum allowable value allowed for // dwStage is 7... // pTexture - // lpTexture... // Address of the IDirect3DTexture2 interface for the texture // being set. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::SetTextureStageState method sets the // state value for a currently assigned texture. // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value can be one of the // following values: // // DDERR_INVALIDOBJECT // DDERR_INVALIDPARAMS // // // Remarks // Applications should use this method to set texture states, // rather than the legacy texture-related render states. For // more information, see About Render States. // ... // Params: pStage - // dwStage... // Stage identifier of the texture for which the state value // will be set. Stage identifiers are zero-based. Currently, // devices can have up to 8 set textures, so the maximum // allowable value allowed for dwStage is 7. // pState - // dwState... // Texture state to be set. This parameter can be any member of // the D3DTEXTURESTAGESTATETYPE enumerated type. // pValue - // dwValue... // State value to be set. The meaning of this value is // determined by the dwState parameter. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::SetTransform method sets a single // Direct3DDevice transformation-related state. // ... // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value is an error. The method // returns DDERR_INVALIDPARAMS if one of the arguments is // invalid. // Params: pTransformStateType - // dtstTransformStateType... // Device state variable that is being modified. This parameter // can be any of the members of the D3DTRANSFORMSTATETYPE // enumerated type. // pD3DMatrix - // lpD3DMatrix... // Address of a D3DMATRIX structure that modifies the current // transformation. // -------------------------------------------------------------------------- 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 IDirect3DDevice7::SetViewport method sets the viewport // parameters for the device.... // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value is an error. The method // returns DDERR_INVALIDPARAMS if the lpViewport parameter is // invalid. // // Remarks // This method was introduced with the IDirect3DDevice7 // interface. // // If the viewport parameters described by the D3DVIEWPORT7 // structure describe a region that cannot exist within the // render target surface, the method fails, returning // DDERR_INVALIDPARAMS. // Params: pViewport - // The Viewport parameter ...Address of a D3DVIEWPORT7 structure // that contains the viewport parameters to be set. // -------------------------------------------------------------------------- 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 IDirect3DDevice3::ValidateDevice method reports the // device's ability to render the currently set texture blending // operations and arguments in a single pass... // Return Values // If the method succeeds, the return value is D3D_OK. // // If the method fails, the return value can be 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 // // // Remarks // Current hardware does not necessarily implement all possible // combinations of operations and arguments. You can determine // whether a particular blending operation can be performed with // given arguments by setting up the desired blending operation, // then calling the ValidateDevice method. // // The ValidateDevice method uses the currently set render // states, textures, and texture-stage states to perform // validation at the time of the call. Any changes to these // factors after the call invalidate the previous result, and // the method must be called again before rendering a scene. // // Using diffuse iterated values, either as an argument or as an // operation (D3DTA_DIFFUSE or D3DTOP_BLENDDIFFUSEALPHA) is // rarely supported on current hardware. Most hardware can only // introduce iterated color data at the last texture operation // stage. // // Try to specify the texture (D3DTA_TEXTURE) for each stage as // the first argument, rather than the second argument. // // Many cards do not support use of diffuse or scalar values at // arbitrary texture stages. Often, these are only available at // the first or last texture-blending stage. // // Many cards do not have a blending unit associated with the // first texture that is capable of more than replicating alpha // to color channels or inverting the input. Therefore, your // application might need to use only the second texture stage, // if possible. On such hardware, the first unit is presumed to // be in its default state, which has the first color argument // set to D3DTA_TEXTURE with the D3DTOP_SELECTARG1 operation. // // Operations on the output alpha that are more intricate than, // or substantially different from, the color operations are // less likely to be supported. // // Some hardware does not support simultaneous use of both // D3DTA_TFACTOR and D3DTA_DIFFUSE. // // Many cards do not support simultaneous use of multiple // textures and mipmapped trilinear filtering. If trilinear // filtering has been requested for a texture involved in // multitexture blending operations and validation fails, turn // off trilinear filtering, and revalidate. In this case, you // might want to perform multipass rendering instead. // Params: pPasses - // lpdwPasses // Address that will be filled with the number of rendering // passes to complete the desired effect through multipass // rendering.... // -------------------------------------------------------------------------- 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); } // --------------------------------------------------------------------------