// -------------------------------------------------------------------------- // ========================================================================== // File: TDx9_3DDevice.CPP // Authors: BCB_Code_Generator v2.00, // Darren Dwyer (source code, documentation, demos, website), // Hugh Edwards (documentation, icons) // Description: This file contains the code for the TDx9_3DDevice Component // // "TDx9_Graphics_Library v1.00" // (c) 2005 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 "TDx9_3DDevice.H" // -------------------------------------------------------------------------- // external classes used by TDx9_3DDevice methods. #include "TDx9_3DSurface.H" #include "TDx9_3DSwapChain.H" #include "TDx9_3DCubeTexture.H" #include "TDx9_3DIndexBuffer.H" #include "TDx9_3DPixelShader.H" #include "TDx9_3DQuery.H" #include "TDx9_3DStateBlock.H" #include "TDx9_3DTexture.H" #include "TDx9_3DVertexBuffer.H" #include "TD3DVertexElement.H" #include "TDx9_3DVertexDeclaration.H" #include "TDx9_3DVertexShader.H" #include "TDx9_3DVolumeTexture.H" #include "TDx9_3D.H" #include "TDx9_3DBaseTexture.H" // -------------------------------------------------------------------------- #pragma link "TDx_Library_Defns" #pragma link "TDx_Library_Functions" #pragma link "TDx9_Graphics_Library_Defns" #pragma link "TDx9_Graphics_Library_Functions" // -------------------------------------------------------------------------- // Object Registration... // -------------------------------------------------------------------------- #if (__BORLANDC__ >= 0x0530) // BCB Version 3+ #pragma package(smart_init) #endif // -------------------------------------------------------------------------- static inline void ValidCtrCheck(TDx9_3DDevice*) { new TDx9_3DDevice(NULL); } // -------------------------------------------------------------------------- namespace Tdx9_3ddevice { #if (__BORLANDC__ >= 0x0530) // BCB Version 3+ void __fastcall PACKAGE Register() #else void __fastcall Register() #endif { TComponentClass classes[1] = {__classid(TDx9_3DDevice)}; RegisterComponents("TDx9_Graphics", classes, 0); } } // -------------------------------------------------------------------------- // Constructor: TDx9_3DDevice::TDx9_3DDevice() // Description: The default constructor for the TDx9_3DDevice object. // -------------------------------------------------------------------------- __fastcall TDx9_3DDevice::TDx9_3DDevice(TComponent* Owner) : TComponent(Owner) { fErrorValue = D3D_OK; fCreated = false; } // -------------------------------------------------------------------------- // Destructor: TDx9_3DDevice::~TDx9_3DDevice() // Description: The destructor for the TDx9_3DDevice object. // -------------------------------------------------------------------------- __fastcall TDx9_3DDevice::~TDx9_3DDevice() { // destroy internals if (Created) Destroy(); } // -------------------------------------------------------------------------- // Property: Created // Description: The Created property is true if the internal // LPDIRECT3DDEVICE9 used in this component has been // successfully created, otherwise Created is false. // // To create the internal LPDIRECT3DDEVICE9, call the // TDx9_3DDevice::Create() method. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::FGetCreated() { return fCreated; } // -------------------------------------------------------------------------- void __fastcall TDx9_3DDevice::FSetCreated( bool pCreated ) { fCreated = (pCreated && (fLPDIRECT3DDEVICE9==NULL)); } // -------------------------------------------------------------------------- // Property: ErrorValue // Description: The ErrorValue property contains the last error value // returned from a call to a TDx9_3DDevice method or fget/fset. // eg. D3D_OK or DDERR_SURFACELOST or TDX_ERROR // -------------------------------------------------------------------------- HRESULT __fastcall TDx9_3DDevice::FGetErrorValue() { return fErrorValue; } // -------------------------------------------------------------------------- void __fastcall TDx9_3DDevice::FSetErrorValue( HRESULT pErrorValue ) { fErrorValue = pErrorValue; } // -------------------------------------------------------------------------- // Method: BeginScene() // Description: The TDx9_3DDevice::BeginScene() method begins a scene so the // application can perform rendering calls. // // Attempts to render outside a TDx9_3DDevice::BeginScene() and // TDx9_3DDevice::EndScene() pair will fail and only one pair // should be called between TDx9_3DDevice::Present or // TDx9_3DSwapChain::Present() calls. TDx9_3DDevice::EndScene() // need not be called if this method fails. // // Try to call TDx9_3DDevice::Present or // TDx9_3DSwapChain::Present() as long after // TDx9_3DDevice::EndScene() as possible to allow optimal // parrallelism between the CPU and the graphics accelerator. // The idea is to give rendering time to complete before // presentation, minimising waiting time. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when this method has already been called // without a matching TDx9_3DDevice::EndScene(). // -------------------------------------------------------------------------- bool __fastcall TDx9_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 = (uint) fLPDIRECT3DDEVICE9->BeginScene( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::BeginScene()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: BeginStateBlock() // Description: The TDx9_3DDevice::BeginStateBlock() method tells Direct3D to // start recording various device settings into a state block. // // TDx9_3DDevice::ValidateDevice() can check that the currently // set states are valid before calling this method. // // This is a list of the methods that can be recorded in a state // block between the TDx9_3DDevice::BeginStateBlock() and // TDx9_3DDevice::EndStateBlock() pair. // The state block does not record the order of these calls, // only the final values of the states they affect. // TDx9_3DDevice::LightEnable() // TDx9_3DDevice::SetClipPlane() // TDx9_3DDevice::SetCurrentTexturePalette() // TDx9_3DDevice::SetFVF() // TDx9_3DDevice::SetIndices() // TDx9_3DDevice::SetLight() // TDx9_3DDevice::SetMaterial() // TDx9_3DDevice::SetNPatchMode() // TDx9_3DDevice::SetPixelShader() // TDx9_3DDevice::SetPixelShaderConstantB() // TDx9_3DDevice::SetPixelShaderConstantF() // TDx9_3DDevice::SetPixelShaderConstantI() // TDx9_3DDevice::SetRenderState() // TDx9_3DDevice::SetSamplerState() // TDx9_3DDevice::SetScissorRect() // TDx9_3DDevice::SetStreamSource() // TDx9_3DDevice::SetStreamSourceFreq() // TDx9_3DDevice::SetTexture() // TDx9_3DDevice::SetTextureStageState() // TDx9_3DDevice::SetTransform() // TDx9_3DDevice::SetViewport() // TDx9_3DDevice::SetVertexDeclaration() // TDx9_3DDevice::SetVertexShader() // TDx9_3DDevice::SetVertexShaderConstantB() // TDx9_3DDevice::SetVertexShaderConstantF() // TDx9_3DDevice::SetVertexShaderConstantI() // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when state blocks are unavailable, at // least at the moment. // E_OUTOFMEMORY when insufficient memory could be allocated for // the call. // -------------------------------------------------------------------------- bool __fastcall TDx9_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 = (uint) fLPDIRECT3DDEVICE9->BeginStateBlock( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::BeginStateBlock()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Clear() // Description: The TDx9_3DDevice::Clear() method can be used to clear // sections of render target surfaces or their associated depth // or stencil buffers. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when invalid parameters are provided or // you try to clear depth or stencil buffers that do not exist. // Params: pCount - // The Count parameter specifies how many regions are defined by // the TD3DRect referenced by Rects. // // This value must be 0 if Rects is NULL and cannot be 0 // otherwise. // pRects - // The Rects parameter references a TD3DRect defining one or // more regions to clear. // // Regions use screen coordinates corresponding to points on the // render target which are clipped to the viewport dimensions. // Define a region that matches the rendering target dimensions // to clear the whole surface. // Set NULL and Count to 0 to clear the whole viewport. // pFlags - // The Flags parameter contains settings indicating which // surfaces should be cleared, as defined by the D3DCLEAR // constant. // pColor - // The Color parameter indicates what ARGB color to set for the // cleared regions. // pZ - // The Z parameter indicates what z value to set for the cleared // depth buffer regions. // // This value can be between 0 and 1. // pStencil - // The Stencil parameter indicates what value to set for the // cleared stencil buffer regions. // // This value can be between 0 and 2^n - 1, where n = stencil // buffer bit depth. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::Clear( dword pCount, D3DRECT* pRects, dword pFlags, D3DCOLOR pColor, float pZ, dword pStencil ) { // Original Function Definition // HRESULT Clear( // DWORD Count, // const D3DRECT *pRects, // DWORD Flags, // D3DCOLOR Color, // float Z, // DWORD Stencil // ); // 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 = (uint) fLPDIRECT3DDEVICE9->Clear( (DWORD) pCount, (const D3DRECT*) pRects, (DWORD) pFlags, pColor, pZ, (DWORD) pStencil ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Clear()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: ColorFill() // Description: The TDx9_3DDevice::ColorFill() method will fill a region of a // D3DPOOL_DEFAULT surface with a specified color. // // When using a reference or software device, fillable formats // are limited to D3DFMT_X1R5G5B5, D3DFMT_A1R5G5B5, // D3DFMT_R5G6B5, D3DFMT_X8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_YUY2, // D3DFMT_G8R8_G8B8, D3DFMT_UYVY, D3DFMT_R8G8_B8G8, D3DFMT_R16F, // D3DFMT_G16R16F, D3DFMT_A16B16G16R16F, D3DFMT_R32F, // D3DFMT_G32R32F and D3DFMT_A32B32G32R32F. // When using DirectX 7.0 or 8.x driver, only the D3DFMT_UYVY // and D3DFMT_YUY2 YUV formats can be filled. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when invalid parameters are provided or // you fill an incompatible surface. // Params: pSurface - // The Surface parameter references the TDx9_3DSurface that is // to be filled. // pRect - // The Rect parameter defines the region that is to be filled. // // Set NULL to fill the entire surface. // pcolor - // The color parameter specifies the color to fill. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::ColorFill( TDx9_3DSurface* pSurface, TRect* pRect, D3DCOLOR pcolor ) { // Original Function Definition // HRESULT ColorFill( // LPDIRECT3DSURFACE9 pSurface, // CONST RECT *pRect, // D3DCOLOR color // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::ColorFill()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->ColorFill( (pSurface==NULL) ? NULL : pSurface->Internal_LPDIRECT3DSURFACE9, (CONST RECT*) pRect, pcolor ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::ColorFill()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Create() // Description: The Create() method is used to automatically create the // internal LPDIRECT3DDEVICE9 interface used in the // TDx9_3DDevice component and must be called before any methods // of the TDx9_3DDevice component will function. // Params: p3D - // The 3D parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::Create( TDx9_3D* p3D ) { // 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 successfully." ); return false; } // check params for accuracy if (p3D==NULL) { fErrorValue = TDX_BADPARAMS; if (FOnError) FOnError( this, Name+"::Create()", "TDX_BADPARAMS", "The 'p3D' parameter must point to an existing TDx9_3D component and cannot be NULL." ); return false; } // code that creates the internal interface //fErrorValue = p3D->CreateDevice( this ); // check for error result if (fErrorValue!=D3D_OK) { if (FOnError) FOnError( this, Name+"::Create()", "TDX_ERROR", Name+"::Create() failed with Error: "+TDx9_Graphics_Library_ErrorString(fErrorValue)+", "+TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // successfully created fCreated = true; if (FOnCreate) FOnCreate(this); return true; } // -------------------------------------------------------------------------- // Method: CreateAdditionalSwapChain() // Description: The TDx9_3DDevice::CreateAdditionalSwapChain() method can be // used to create an additional swap chain if you need to render // multiple views. // // There is automatically an implicit swap chain so only use // this method if you need an extra swap chain. Only one full // screen swap chain is allowed per device. // D3DFMT_UNKNOWN can be specified as the windowed mode back // buffer format in this method, TDx9_3D::CreateDevice() and // TDx9_3DDevice::Reset() calls, so you dont need to retrieve // the current desktop format before this call for windowed // mode. Full screen mode requires the back buffer format be // specified. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_NOTAVAILABLE if the specified multisample type is // unsupported. // D3DERR_DEVICELOST when the device is lost and cannot be reset // right now. // D3DERR_INVALIDCALL when invalid parameters are provided. // D3DERR_OUTOFVIDEOMEMORY if not enough display memory was // available for the operation. // E_OUTOFMEMORY if not enough memory could be allocated to // complete the call. // Params: pPresentationParameters - // The PresentationParameters parameter references a // TD3DPresent_Parameters component holding the presentation // parameters for the new swap chain. // // Some of the TD3DPresent_Parameters properties may change as a // result of this call. // Specifically, if BackBufferCount is 0 it will be set to 1 and // if BackBufferWidth or BackBufferHeight is 0 in windowed mode, // they will be set to the client area width and height of the // hwnd. // pSwapChain - // The SwapChain parameter will reference the created // TDx9_3DSwapChain when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::CreateAdditionalSwapChain( D3DPRESENT_PARAMETERS* pPresentationParameters, TDx9_3DSwapChain* pSwapChain ) { // Original Function Definition // HRESULT CreateAdditionalSwapChain( // D3DPRESENT_PARAMETERS* pPresentationParameters, // LPDIRECT3DSWAPCHAIN9* ppSwapChain // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreateAdditionalSwapChain()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->CreateAdditionalSwapChain( pPresentationParameters, (pSwapChain==NULL) ? NULL : pSwapChain->Internal_LPDIRECT3DSWAPCHAIN9_Ptr ); // Translate Data returned from Function if (pSwapChain!=NULL) pSwapChain->Internal_LPDIRECT3DSWAPCHAIN9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateAdditionalSwapChain()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: CreateCubeTexture() // Description: The TDx9_3DDevice::CreateCubeTexture() method will create a // cube texture. // // Call TDx9_3DDevice::CheckDeviceFormat with // D3DUSAGE_AUTOGENMIPMAP set to find out if automatic // generation of mipmaps is supported for a specific format. A // return value of D3DOK_NOAUTOGEN indicates this creation call // would succeed but return a cube texture with only one level. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when invalid parameters are provided. // D3DERR_OUTOFVIDEOMEMORY if not enough display memory was // available for the operation. // E_OUTOFMEMORY if not enough memory could be allocated to // complete the call. // Params: pEdgeLength - // The EdgeLength parameter specifies the dimensions of the top // level of the cube texture. // // This is a single value used for all 3 dimensions, it is a // cube after all. // It is usually best to use a power of two for this value as // each level is half the size of the previous one, rounded // down, but with a minimum dimension of 1. // pLevels - // The Levels parameter specifies how many mipmap levels the // cube texture should have. // // Setting 0 results in levels being generated all the way down // to 1 pixel size if the hardware supports mimmaped cube // textures. // Call TDx9_3DCubeTexture::GetLevelCount() of the returned cube // texture to find out how many levels were generated. // pUsage - // The Usage parameter specifies the usage parameters for the // cube texture, as values of the D3DUSAGE constant. // // Setting 0 is allowed, otherwise its good practice for the // usage to match the settings used in the // TDx9_3D::CreateDevice() call. // pFormat - // The Format parameter specifies the format to be used for all // faces and levels of the cube texture, as a value of the // D3DFORMAT enumerated type. // pPool - // The Pool parameter indicates what class memory the cube // texture should use, as a value of the TD3DPOOL enumerated // type. // pCubeTexture - // The CubeTexture parameter will reference the created // TDx9_3DCubeTexture when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::CreateCubeTexture( uint pEdgeLength, uint pLevels, dword pUsage, D3DFORMAT pFormat, D3DPOOL pPool, TDx9_3DCubeTexture* pCubeTexture ) { // Original Function Definition // HRESULT CreateCubeTexture( // UINT EdgeLength, // UINT Levels, // DWORD Usage, // D3DFORMAT Format, // D3DPOOL Pool, // LPDIRECT3DCUBETEXTURE9* ppCubeTexture, // HANDLE* pHandle // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreateCubeTexture()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->CreateCubeTexture( (UINT) pEdgeLength, (UINT) pLevels, (DWORD) pUsage, pFormat, pPool, (pCubeTexture==NULL) ? NULL : pCubeTexture->Internal_LPDIRECT3DCUBETEXTURE9_Ptr, NULL ); // Translate Data returned from Function if (pCubeTexture!=NULL) pCubeTexture->Internal_LPDIRECT3DCUBETEXTURE9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateCubeTexture()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: CreateDepthStencilSurface() // Description: The TDx9_3DDevice::CreateDepthStencilSurface() method will // create a depth stencil surface. // // Stencil depth surfaces are always D3DPOOL_DEFAULT. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_NOTAVAILABLE if the specified multisample type is // unsupported. // D3DERR_INVALIDCALL when invalid parameters are provided. // D3DERR_OUTOFVIDEOMEMORY if not enough display memory was // available for the operation. // E_OUTOFMEMORY if not enough memory could be allocated to // complete the call. // Params: pWidth - // The Width parameter specifies the width, in pixels, of the // new depth stencil surface. // pHeight - // The Height parameter specifies the height, in pixels, of the // new depth stencil surface. // pFormat - // The Format parameter specifies the format of the new depth // stencil surface, as a value of the D3DFORMAT enumerated type. // // This value must be one of the enumerated depth stencil // formats for this device. // pMultiSample - // The MultiSample parameter specifies the multisampling buffer // type, as a value of the D3DMULTISAMPLE_TYPE enumerated type. // // This value must be an allowed multisample type and when // passed to TDx9_3DDevice::SetDepthStencilSurface() this type // must match that set for the render target by // TDx9_3DDevice::SetRenderTarget(). // pMultisampleQuality - // The MultisampleQuality parameter specifies the multisample // quality level. // // This value must be between 0 and // TDx9_3D::CheckDeviceMultiSampleType->QualityLevels - 1. The // quality level must match for the render target, depth stencil // and multisample type. // pDiscard - // The Discard parameter indicates whether to discard the depth // stencil buffer contents whenever TDx9_3DDevice::Present() or // TDx9_3DDevice::SetDepthStencilSurface() is called with a // different depth surface. // // Setting TRUE behaves the same way as the // D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL flag. // pSurface - // The Surface parameter will reference the TDx9_3DSurface // holding the new depth stencil surface when the method // returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::CreateDepthStencilSurface( uint pWidth, uint pHeight, D3DFORMAT pFormat, D3DMULTISAMPLE_TYPE pMultiSample, dword pMultisampleQuality, bool pDiscard, TDx9_3DSurface* pSurface ) { // Original Function Definition // HRESULT CreateDepthStencilSurface( // UINT Width, // UINT Height, // D3DFORMAT Format, // D3DMULTISAMPLE_TYPE MultiSample, // DWORD MultisampleQuality, // BOOL Discard, // LPDIRECT3DSURFACE9* ppSurface, // HANDLE* pHandle // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreateDepthStencilSurface()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->CreateDepthStencilSurface( (UINT) pWidth, (UINT) pHeight, pFormat, pMultiSample, (DWORD) pMultisampleQuality, (BOOL) pDiscard, (pSurface==NULL) ? NULL : pSurface->Internal_LPDIRECT3DSURFACE9_Ptr, NULL ); // Translate Data returned from Function if (pSurface!=NULL) pSurface->Internal_LPDIRECT3DSURFACE9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateDepthStencilSurface()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: CreateIndexBuffer() // Description: The TDx9_3DDevice::CreateIndexBuffer() method will create an // index buffer. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when invalid parameters are provided. // D3DERR_OUTOFVIDEOMEMORY if not enough display memory was // available for the operation. // D3DXERR_INVALIDDATA when the provided data is invalid. // E_OUTOFMEMORY if not enough memory could be allocated to // complete the call. // Params: pLength - // The Length parameter defines the size, in bytes, of the index // buffer. // pUsage - // The Usage parameter specifies the usage parameters for the // index buffer, as values of the D3DUSAGE constant. // // Setting 0 is allowed, otherwise its good practice for the // usage to match the settings used in the // TDx9_3D::CreateDevice() call. // pFormat - // The Format parameter specifies the index buffer format, as a // value of the D3DFORMAT enumerated type. // // Valid values are D3DFMT_INDEX16 for 16 bit indices and // D3DFMT_INDEX32 for 32 bit indices. // If TD3DCaps->MaxVertexIndex > 0x0000FFFF indicates 32 bit // indices will be valid for rendering. // pPool - // The Pool parameter indicates what class memory the index // buffer should use, as a value of the TD3DPOOL enumerated // type. // pIndexBuffer - // The IndexBuffer parameter will reference the created // TDx9_3DIndexBuffer when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::CreateIndexBuffer( uint pLength, dword pUsage, D3DFORMAT pFormat, D3DPOOL pPool, TDx9_3DIndexBuffer* pIndexBuffer ) { // Original Function Definition // HRESULT CreateIndexBuffer( // UINT Length, // DWORD Usage, // D3DFORMAT Format, // D3DPOOL Pool, // LPDIRECT3DINDEXBUFFER9* ppIndexBuffer, // HANDLE* pHandle // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreateIndexBuffer()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->CreateIndexBuffer( (UINT) pLength, (DWORD) pUsage, pFormat, pPool, (pIndexBuffer==NULL) ? NULL : pIndexBuffer->Internal_LPDIRECT3DINDEXBUFFER9_Ptr, NULL ); // Translate Data returned from Function if (pIndexBuffer!=NULL) pIndexBuffer->Internal_LPDIRECT3DINDEXBUFFER9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateIndexBuffer()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: CreateOffscreenPlainSurface() // Description: The TDx9_3DDevice::CreateOffscreenPlainSurface() method will // create an ordinary offscreen surface. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when invalid parameters are provided. // Params: pWidth - // The Width parameter defines the width, in pixels, of the new // surface. // pHeight - // The Height parameter defines the height, in pixels of the new // surface. // pFormat - // The Format parameter specifies the format of the new surface, // as a value of the D3DFORMAT enumerated type. // pPool - // The Pool parameter indicates what class memory the surface // should use, as a value of the TD3DPOOL enumerated type. // // This kind of surface is always lockable, regardless of pool // type. // D3DPOOL_SCRATCH returns a surface the same as that produced // by the DirectX 8 CreateImageSurface method . // D3DPOOL_DEFAULT is the best pool for surfaces that need to // TDx9_3DDevice::StretchRect() and TDx9_3DDevice::ColorFill(). // D3DPOOL_MANAGED is invalid for plain offscreen surfaces. // pSurface - // The Surface parameter will reference the created // TDx9_3DSurface when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::CreateOffscreenPlainSurface( uint pWidth, uint pHeight, D3DFORMAT pFormat, dword pPool, TDx9_3DSurface* pSurface ) { // Original Function Definition // HRESULT CreateOffscreenPlainSurface( // UINT Width, // UINT Height, // D3DFORMAT Format, // DWORD Pool, // LPDIRECT3DSURFACE9* ppSurface, // HANDLE* pHandle // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreateOffscreenPlainSurface()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->CreateOffscreenPlainSurface( (UINT) pWidth, (UINT) pHeight, pFormat, (DWORD) pPool, (pSurface==NULL) ? NULL : pSurface->Internal_LPDIRECT3DSURFACE9_Ptr, NULL ); // Translate Data returned from Function if (pSurface!=NULL) pSurface->Internal_LPDIRECT3DSURFACE9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateOffscreenPlainSurface()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: CreatePixelShader() // Description: The TDx9_3DDevice::CreatePixelShader() method will create a // pixel shader. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when invalid parameters are provided. // D3DERR_OUTOFVIDEOMEMORY if not enough display memory was // available for the operation. // E_OUTOFMEMORY if not enough memory could be allocated to // complete the call. // Params: pFunction - // The Function parameter references the blending operations for // the pixel shader, as specified by the pixel shader function // token array. // // This value cannot be NULL. // pShader - // The Shader parameter will reference the new // TDx9_3DPixelShader when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::CreatePixelShader( dword* pFunction, TDx9_3DPixelShader* pShader ) { // Original Function Definition // HRESULT CreatePixelShader( // CONST DWORD *pFunction, // LPDIRECT3DPIXELSHADER9* ppShader // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreatePixelShader()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Check Parameters for Accuracy if (pFunction==NULL) { fErrorValue = TDX_BADPARAMS; if (FOnError) FOnError( this, Name+"::CreatePixelShader()", "TDX_BADPARAMS", "'pFunction' cannot be 'NULL'"); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->CreatePixelShader( (CONST DWORD*) pFunction, (pShader==NULL) ? NULL : pShader->Internal_LPDIRECT3DPIXELSHADER9_Ptr ); // Translate Data returned from Function if (pShader!=NULL) pShader->Internal_LPDIRECT3DPIXELSHADER9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreatePixelShader()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: CreateQuery() // Description: The TDx9_3DDevice::CreateQuery() method will create a device // status query. // // Once created and after the relevant API calls have been made, // the synchronous or asynchronous query is initiated with // TDx9_3DQuery::Issue() the results can be retrieved with // TDx9_3DQuery::GetData(). // This method replaces the GetInfo method from earlier DirectX // versions. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_NOTAVAILABLE if the specified query is not supported. // E_OUTOFMEMORY if not enough memory could be allocated to // complete the call. // Params: pType - // The Type parameter specifies the type of query to create, as // a value of the D3DQUERYTYPE enumerated type. // pQuery - // The Query parameter will reference the new TDx9_3DQuery when // the method returns. // // Set NULL to check a specified query Type is supported. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::CreateQuery( D3DQUERYTYPE pType, TDx9_3DQuery* pQuery ) { // Original Function Definition // HRESULT CreateQuery( // D3DQUERYTYPE Type, // LPDIRECT3DQUERY9* ppQuery // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreateQuery()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->CreateQuery( pType, (pQuery==NULL) ? NULL : pQuery->Internal_LPDIRECT3DQUERY9_Ptr ); // Translate Data returned from Function if (pQuery!=NULL) pQuery->Internal_LPDIRECT3DQUERY9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateQuery()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: CreateRenderTarget() // Description: The TDx9_3DDevice::CreateRenderTarget() method will create a // render target surface. // // Render target surfaces are placed in D3DPOOL_DEFAULT memory. // Lockable, multisampled render targets are not supported. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_NOTAVAILABLE when the specified multisample type is // unsupported. // D3DERR_INVALIDCALL when invalid parameters are provided. // D3DERR_OUTOFVIDEOMEMORY if not enough display memory was // available for the operation. // E_OUTOFMEMORY if not enough memory could be allocated to // complete the call. // Params: pWidth - // The Width parameter specifies the width, in pixels, of the // new render target surface. // pHeight - // The Height parameter specifies the height, in pixels, of the // new render target surface. // pFormat - // The Format parameter defines the format of the new render // target surface, as a value of the D3DFORMAT enumerated type. // pMultiSample - // The MultiSample parameter defines the antialiasing type for // the new render target surface, as a value of the // D3DMULTISAMPLE_TYPE enumerated type. // // When passed to TDx9_3DDevice::SetRenderTarget(), the // multisample type must match that of the depth stencil, as set // by TDx9_3DDevice::SetDepthStencilSurface(). // pMultisampleQuality - // The MultisampleQuality parameter specifies the multisample // quality level. // // This value must be between 0 and // TDx9_3D::CheckDeviceMultiSampleType->QualityLevels - 1. The // quality level must match for the render target, depth stencil // and multisample type. // pLockable - // The Lockable parameter indicates that the new render target // should be lockable. // // Set TRUE if you want to be able to lock the new render target // surface, but keep in mind that it may affect performance on // some graphics hardware. // pSurface - // The Surface parameter will reference the new render target // TDx9_3DSurface when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::CreateRenderTarget( uint pWidth, uint pHeight, D3DFORMAT pFormat, D3DMULTISAMPLE_TYPE pMultiSample, dword pMultisampleQuality, bool pLockable, TDx9_3DSurface* pSurface ) { // Original Function Definition // HRESULT CreateRenderTarget( // UINT Width, // UINT Height, // D3DFORMAT Format, // D3DMULTISAMPLE_TYPE MultiSample, // DWORD MultisampleQuality, // BOOL Lockable, // LPDIRECT3DSURFACE9* ppSurface, // HANDLE* pHandle // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreateRenderTarget()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->CreateRenderTarget( (UINT) pWidth, (UINT) pHeight, pFormat, pMultiSample, (DWORD) pMultisampleQuality, (BOOL) pLockable, (pSurface==NULL) ? NULL : pSurface->Internal_LPDIRECT3DSURFACE9_Ptr, NULL ); // Translate Data returned from Function if (pSurface!=NULL) pSurface->Internal_LPDIRECT3DSURFACE9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateRenderTarget()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: CreateStateBlock() // Description: The TDx9_3DDevice::CreateStateBlock() method will create a // state block of vertex related, pixel related or all device // state values. // // Vertex states are mainly those affecting how vertices are // processed. Pixel states are mainly those affecting how pixel // or depth buffer data is processed during rasterization. There // are some values in both groups. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when invalid parameters are provided. // D3DERR_OUTOFVIDEOMEMORY if not enough display memory was // available for the operation. // E_OUTOFMEMORY if not enough memory could be allocated to // complete the call. // Params: pType - // The Type parameter specifies the type of state data that // should be captured, as a value of the D3DSTATEBLOCKTYPE // enumerated type. // pSB - // The SB parameter will reference the new TDx9_3DStateBlock // when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::CreateStateBlock( D3DSTATEBLOCKTYPE pType, TDx9_3DStateBlock* pSB ) { // Original Function Definition // HRESULT CreateStateBlock( // D3DSTATEBLOCKTYPE Type, // LPDIRECT3DSTATEBLOCK9* ppSB // ); // 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 = (uint) fLPDIRECT3DDEVICE9->CreateStateBlock( pType, (pSB==NULL) ? NULL : pSB->Internal_LPDIRECT3DSTATEBLOCK9_Ptr ); // Translate Data returned from Function if (pSB!=NULL) pSB->Internal_LPDIRECT3DSTATEBLOCK9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateStateBlock()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: CreateTexture() // Description: The TDx9_3DDevice::CreateTexture() method will create an // ordinary texture. // // Call TDx9_3DDevice::CheckDeviceFormat with // D3DUSAGE_AUTOGENMIPMAP set to find out if automatic // generation of mipmaps is supported for a specific format. A // return value of D3DOK_NOAUTOGEN indicates this creation call // would succeed but return a texture with only one level. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when invalid parameters are provided. // D3DERR_OUTOFVIDEOMEMORY if not enough display memory was // available for the operation. // E_OUTOFMEMORY if not enough memory could be allocated to // complete the call. // Params: pWidth - // The Width parameter specifies the width of the top level of // the texture. // // It is usually best to use a power of two for this value as // each level is half the size of the previous one, rounded // down, but with a minimum dimension of 1. // pHeight - // The Height parameter specifies the height of the top level of // the texture. // // It is usually best to use a power of two for this value as // each level is half the size of the previous one, rounded // down, but with a minimum dimension of 1. // pLevels - // The Levels parameter specifies how many mipmap levels the // texture should have. // // Setting 0 results in levels being generated all the way down // to 1 pixel size if the hardware supports mimmaped textures. // Call TDx9_3DTexture::GetLevelCount() of the returned texture // to find out how many levels were generated. // pUsage - // The Usage parameter specifies the usage parameters for the // texture, as values of the D3DUSAGE constant. // // Setting 0 is allowed, otherwise its good practice for the // usage to match the settings used in the // TDx9_3D::CreateDevice() call. // pFormat - // The Format parameter specifies the format to be used for all // levels of the texture, as a value of the D3DFORMAT enumerated // type. // pPool - // The Pool parameter indicates what class memory the texture // should use, as a value of the TD3DPOOL enumerated type. // pTexture - // The Texture parameter will reference the created // TDx9_3DTexture when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::CreateTexture( uint pWidth, uint pHeight, uint pLevels, dword pUsage, D3DFORMAT pFormat, D3DPOOL pPool, TDx9_3DTexture* pTexture ) { // Original Function Definition // HRESULT CreateTexture( // UINT Width, // UINT Height, // UINT Levels, // DWORD Usage, // D3DFORMAT Format, // D3DPOOL Pool, // LPDIRECT3DTEXTURE9* ppTexture, // HANDLE* pHandle // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreateTexture()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->CreateTexture( (UINT) pWidth, (UINT) pHeight, (UINT) pLevels, (DWORD) pUsage, pFormat, pPool, (pTexture==NULL) ? NULL : pTexture->Internal_LPDIRECT3DTEXTURE9_Ptr, NULL ); // Translate Data returned from Function if (pTexture!=NULL) pTexture->Internal_LPDIRECT3DTEXTURE9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateTexture()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: CreateVertexBuffer() // Description: The TDx9_3DDevice::CreateVertexBuffer() method will create a // vertex buffer. // // A vertex buffer can only be used by the TDx9_3DDevice that // created it. // Hardware and software vertex processing can both use vertex // buffers, the type of processing is determined at the creation // time of both the device and the vertex buffer. // For mixed mode vertex processing, // TDx9_3DDevice::SetSoftwareVertexProcessing() may need to be // called after device creation. // Vertex buffer usage should match device behaviour, so when // using a vertex buffer with a mixed mode device, set the // vertex buffer with TDx9_3DDevice::SetStreamSource() and if // neccessary, change the device behaviour to match with // TDx9_3DDevice::SetRenderState(). // Software processed vertex buffers cannot be located in video // memory. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when invalid parameters are provided. // D3DERR_OUTOFVIDEOMEMORY if not enough display memory was // available for the operation. // E_OUTOFMEMORY if not enough memory could be allocated to // complete the call. // Params: pLength - // The Length parameter defines the size, in bytes, of the // vertex buffer. // // If FVF is not 0, this value must be at least the size of one // vertex but need not be an exact multiple of the vertex size. // When FVF is 0, this parameter is not validated. // pUsage - // The Usage parameter specifies the usage settings for the new // vertex buffer, as values of the D3DUSAGE constant. // // Setting 0 is allowed, otherwise its good practice for the // usage to match the TDx9_3D::CreateDevice->BehaviourFlags // settings used in the call. // // If D3DCREATE_HARDWARE_VERTEXPROCESSING was set this value // should be 0. // If D3DCREATE_SOFTWARE_VERTEXPROCESSING or // D3DCREATE_MIXED_VERTEXPROCESSING was set this value can be 0 // or D3DUSAGE_SOFTWAREPROCESSING. // pFVF - // The FVF parameter specifies the FVF settings for the new // vertex buffer, as values of the D3DFVF constant. // // This value may be 0, but if a valid FVF code is set the // buffer content will be characterised by that FVF code. // For FVF vertex buffers each element needs to contain geometry // and texture coordinate information, resulting in duplicated // geometry information for each associated texture coordinate. // For Non-FVF vertex buffers the texture and geometry data can // be interleaved during multipass rendering or multitexture // rendering in a single pass. For this, one buffer contains // geometry while the other contains texture coordinates. Since // there are usually multiple texture coordinate elements for // each geometry element, this results in either a speed or // memory advantage over a FVF buffer. // pPool - // The Pool parameter indicates what class memory the vertex // buffer should use, as a value of the TD3DPOOL enumerated // type. // pVertexBuffer - // The VertexBuffer parameter will reference the new // TDx9_3DVertexBuffer when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::CreateVertexBuffer( uint pLength, dword pUsage, dword pFVF, D3DPOOL pPool, TDx9_3DVertexBuffer* pVertexBuffer ) { // Original Function Definition // HRESULT CreateVertexBuffer( // UINT Length, // DWORD Usage, // DWORD FVF, // D3DPOOL Pool, // LPDIRECT3DVERTEXBUFFER9* ppVertexBuffer, // HANDLE* pHandle // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreateVertexBuffer()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->CreateVertexBuffer( (UINT) pLength, (DWORD) pUsage, (DWORD) pFVF, pPool, (pVertexBuffer==NULL) ? NULL : pVertexBuffer->Internal_LPDIRECT3DVERTEXBUFFER9_Ptr, NULL ); // Translate Data returned from Function if (pVertexBuffer!=NULL) pVertexBuffer->Internal_LPDIRECT3DVERTEXBUFFER9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateVertexBuffer()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: CreateVertexDeclaration() // Description: The TDx9_3DDevice::CreateVertexDeclaration() method will // create a vertex shader declaration from the device settings // and vertex elements. // // Vertex streams are expressed in TD3DVertexElement's, // replacing the FVF codes used in previous DirectX versions. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when invalid parameters are provided. // Params: pVertexElements - // The VertexElements parameter references the TD3DVertexElement // component holding the vertex element array. // pDecl - // The Decl parameter will reference the new // TDx9_3DVertexDeclaration when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::CreateVertexDeclaration( TD3DVertexElement* pVertexElements, TDx9_3DVertexDeclaration* pDecl ) { // Original Function Definition // HRESULT CreateVertexDeclaration( // LPD3DVERTEXELEMENT9 pVertexElements, // LPDIRECT3DVERTEXDECLARATION9* ppDecl // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreateVertexDeclaration()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function //fErrorValue = (uint) fLPDIRECT3DDEVICE9->CreateVertexDeclaration( (pVertexElements==NULL) ? NULL : pVertexElements->Internal__D3DVERTEXELEMENT9_Ptr, (pDecl==NULL) ? NULL : pDecl->Internal_LPDIRECT3DVERTEXDECLARATION9_Ptr ); // Translate Data returned from Function //if (pVertexElements!=NULL) pVertexElements->Internal__D3DVERTEXELEMENT9_Update(); if (pDecl!=NULL) pDecl->Internal_LPDIRECT3DVERTEXDECLARATION9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateVertexDeclaration()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: CreateVertexShader() // Description: The TDx9_3DDevice::CreateVertexShader() method will create a // vertex shader from an array of tokens representing the vertex // shader properties. // // TDx9_3D::CreateDevice->BehaviourFlags specifies hardware, // software or both processing for vertices. Switching between // software and hardware processing on a mixed mode device is // accomplished via // TDx9_3DDevice::SetSoftwareVertexProcessing(). // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when invalid parameters are provided. // D3DERR_OUTOFVIDEOMEMORY if not enough display memory was // available for the operation. // E_OUTOFMEMORY if not enough memory could be allocated to // complete the call. // Params: pFunction - // The Function parameter references the token array // representing the vertex shader, including embedded debug and // symbol table information. // // This array could be created in several ways, including: // Use the D3DXCompileShader function of the TDx9_3DX_Library on // a high level shader language (HLSL) shader. // Use the D3DXAssembleShader function of the TDx9_3DX_Library // on an assembly language shader. // Use TDx9_3DX::EffectCompiler() on an effect. // pShader - // The Shader parameter will reference the new // TDx9_3DVertexShader when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::CreateVertexShader( dword* pFunction, TDx9_3DVertexShader* pShader ) { // Original Function Definition // HRESULT CreateVertexShader( // const DWORD *pFunction, // LPDIRECT3DVERTEXSHADER9* ppShader // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreateVertexShader()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->CreateVertexShader( (const DWORD*) pFunction, (pShader==NULL) ? NULL : pShader->Internal_LPDIRECT3DVERTEXSHADER9_Ptr ); // Translate Data returned from Function if (pShader!=NULL) pShader->Internal_LPDIRECT3DVERTEXSHADER9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateVertexShader()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: CreateVolumeTexture() // Description: The TDx9_3DDevice::CreateVolumeTexture() method will create a // volume texture. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when invalid parameters are provided. // D3DERR_OUTOFVIDEOMEMORY if not enough display memory was // available for the operation. // E_OUTOFMEMORY if not enough memory could be allocated to // complete the call. // Params: pWidth - // The Width parameter specifies the width of the top level of // the volume texture. // // TD3DCaps->MaxVolumeExtent defines the maximum supported // value. // If TD3DCaps->TextureCaps->D3DPTEXTURECAPS_VOLUMEMAP_POW2 is // set, this value must be a power of two. // Each level is half the size of the previous one, rounded // down, but with a minimum dimension of 1. // pHeight - // The Height parameter specifies the height of the top level of // the volume texture. // // TD3DCaps->MaxVolumeExtent defines the maximum supported // value. // If TD3DCaps->TextureCaps->D3DPTEXTURECAPS_VOLUMEMAP_POW2 is // set, this value must be a power of two. // Each level is half the size of the previous one, rounded // down, but with a minimum dimension of 1. // pDepth - // The Depth parameter specifies the depth, in pixels, of the // top level of the volume texture. // // TD3DCaps->MaxVolumeExtent defines the maximum supported // value. // If TD3DCaps->TextureCaps->D3DPTEXTURECAPS_VOLUMEMAP_POW2 is // set, this value must be a power of two. // Each level is half the size of the previous one, rounded // down, but with a minimum dimension of 1. // pLevels - // The Levels parameter specifies how many mipmap levels the // volume texture should have. // // Setting 0 results in levels being generated all the way down // to 1 pixel size if the hardware supports mimmaped volume // textures. // Call TDx9_3DCubeTexture::GetLevelCount() of the returned // volume texture to find out how many levels were generated. // pUsage - // The Usage parameter specifies the usage parameters for the // volume texture, as values of the D3DUSAGE constant. // // Setting 0 is allowed, otherwise D3DUSAGE_DYNAMIC or // D3DUSAGE_SOFTWAREPROCESSING are valid values. // pFormat - // The Format parameter specifies the format to be used for all // levels of the volume texture, as a value of the D3DFORMAT // enumerated type. // pPool - // The Pool parameter indicates what class memory the volume // texture should use, as a value of the TD3DPOOL enumerated // type. // pVolumeTexture - // The VolumeTexture parameter will reference the created // TDx9_3DVolumeTexture when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::CreateVolumeTexture( uint pWidth, uint pHeight, uint pDepth, uint pLevels, dword pUsage, D3DFORMAT pFormat, D3DPOOL pPool, TDx9_3DVolumeTexture* pVolumeTexture ) { // Original Function Definition // HRESULT CreateVolumeTexture( // UINT Width, // UINT Height, // UINT Depth, // UINT Levels, // DWORD Usage, // D3DFORMAT Format, // D3DPOOL Pool, // LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture, // HANDLE* pHandle // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::CreateVolumeTexture()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->CreateVolumeTexture( (UINT) pWidth, (UINT) pHeight, (UINT) pDepth, (UINT) pLevels, (DWORD) pUsage, pFormat, pPool, (pVolumeTexture==NULL) ? NULL : pVolumeTexture->Internal_LPDIRECT3DVOLUMETEXTURE9_Ptr, NULL ); // Translate Data returned from Function if (pVolumeTexture!=NULL) pVolumeTexture->Internal_LPDIRECT3DVOLUMETEXTURE9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::CreateVolumeTexture()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: DeletePatch() // Description: The TDx9_3DDevice::DeletePatch() method will free a cached // higher order patch. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Handle is invalid. // Params: pHandle - // The Handle parameter indicates which cached higher order // patch to delete. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::DeletePatch( uint pHandle ) { // Original Function Definition // HRESULT DeletePatch( // UINT Handle // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::DeletePatch()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->DeletePatch( (UINT) pHandle ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DeletePatch()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Destroy() // Description: The Destroy() method is used to automatically destroy the // internal LPDIRECT3DDEVICE9 interface used in the // TDx9_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 TDx9_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 (fLPDIRECT3DDEVICE9==NULL) { fErrorValue = TDX_ERROR; if (FOnError) FOnError( this, Name+"::Destroy()", "TDX_ERROR", "The "+Name+" component's internal LPDIRECT3DDEVICE9 is NULL. Aborting the Destroy()." ); return false; } try { fLPDIRECT3DDEVICE9->Release(); } catch (...) { fErrorValue = TDX_ERROR; if (FOnError) FOnError( this, Name+"::Destroy()", "TDX_ERROR", "An exception occurred in LPDIRECT3DDEVICE9->Release(). Check you are destroying all components in reverse order of creation." ); } // successful destruction fLPDIRECT3DDEVICE9 = NULL; fCreated = false; return true; } // -------------------------------------------------------------------------- // Method: DrawIndexedPrimitive() // Description: The TDx9_3DDevice::DrawIndexedPrimitive() method will render // the specified geometric primitive into an array of vertices // using indexing. // // The primitives drawn come from the current set of data input // streams. The MinIndex and all indices of the index stream are // relative to the BaseVertexIndex offset. // MinIndex and NumVertices specify the range of vertex indices // to use for each call of this method. This sequential vertex // range is processed prior to indexing into that range, thus // helping to optimise the operation. Attempting to use any // vertices outside the specified range or having no index array // set will cause the method to fail. // // Add a TDx9_3DDevice::SetFVF() call before making any draw // calls if you are converting fixed function legacy code from // previous versions of DirectX. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pType - // The Type parameter specifies the type of primitive to render, // as a value of the D3DPRIMITIVETYPE enumerated type. // // D3DPT_POINTLIST is not a valid value for this method. // pBaseVertexIndex - // The BaseVertexIndex parameter specifies the offset from the // start of the vertex buffer to the first vertex. // pMinIndex - // The MinIndex parameter defines the minumum vertex index for // vertices used during this call. // The index is zero based relative to BaseVertexIndex. // pNumVertices - // The NumVertices parameter indicates how many vertices to use, // starting from BaseVertexIndex + MinIndex. // pStartIndex - // The StartIndex parameter specifies the index of the index to // start indexing vertices from the vertex buffer. // pPrimitiveCount - // The PrimitiveCount parameter indicates how many primitives // are to be rendered. // This value and the primitive Type determine how many vertices // are needed. For example, D3DPT_TRIANGLELIST would need 3 // times PrimitiveCount vertices. // TD3DCaps->MaxPrimitiveCount denotes the maximum value allowed // for this parameter. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::DrawIndexedPrimitive( D3DPRIMITIVETYPE pType, int pBaseVertexIndex, uint pMinIndex, uint pNumVertices, uint pStartIndex, uint pPrimitiveCount ) { // Original Function Definition // HRESULT DrawIndexedPrimitive( // D3DPRIMITIVETYPE Type, // INT BaseVertexIndex, // UINT MinIndex, // UINT NumVertices, // UINT StartIndex, // UINT PrimitiveCount // ); // 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 = (uint) fLPDIRECT3DDEVICE9->DrawIndexedPrimitive( pType, (INT) pBaseVertexIndex, (UINT) pMinIndex, (UINT) pNumVertices, (UINT) pStartIndex, (UINT) pPrimitiveCount ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DrawIndexedPrimitive()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: DrawIndexedPrimitiveUP() // Description: The TDx9_3DDevice::DrawIndexedPrimitiveUP() method will // render the specified geometric primitive from application // defined data using indexing. // // The primitives drawn come from index and vertex data // referenced by user defined pointers. // Primarily intended for applications that are unable to store // vertex buffers, this method only supports a single vertex // stream which must be declared as stream 0. // After the call, the stream 0 settings, referenced by // TDx9_3DDevice::GetStreamSource(), and the index buffer // setting, from TDx9_3DDevice::SetIndices(), will be set to // NULL. // The vertex data used in the call can safely be released // afterwards. Direct3D completes its access to that data prior // to returning. // // Add a TDx9_3DDevice::SetFVF() call before making any draw // calls if you are converting fixed function legacy code from // previous versions of DirectX. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pPrimitiveType - // The PrimitiveType parameter specifies the type of primitive // to render, as a value of the D3DPRIMITIVETYPE enumerated // type. // pMinVertexIndex - // The MinVertexIndex parameter defines the minimum index of the // vertices used during this call. // The index is zero based. // pNumVertexIndices - // The NumVertices parameter indicates how many vertices to use, // starting from MinVertexIndex. // pPrimitiveCount - // The PrimitiveCount parameter indicates how many primitives // are to be rendered. // // This value and the primitive Type determine how many vertices // are needed. For example, D3DPT_TRIANGLELIST would need 3 // times PrimitiveCount vertices. // TD3DCaps->MaxPrimitiveCount denotes the maximum value allowed // for this parameter. // pIndexData - // The IndexData parameter references the application defined // index data. // pIndexDataFormat - // The IndexDataFormat parameter specifies the index data // format, as a value of the D3DFORMAT enumerated type. // // This value can be D3DFMT_INDEX16 or D3DFMT_INDEX32. // pVertexStreamZeroData - // The VertexStreamZeroData parameter references the application // defined vertex data. // // The referenced vertex data must be in stream 0. // pVertexStreamZeroStride - // The VertexStreamZeroStride parameter indicates the size, in // bytes, of each vertex. // // This value cannot be 0. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::DrawIndexedPrimitiveUP( D3DPRIMITIVETYPE pPrimitiveType, uint pMinVertexIndex, uint pNumVertexIndices, uint pPrimitiveCount, void* pIndexData, D3DFORMAT pIndexDataFormat, void* pVertexStreamZeroData, uint pVertexStreamZeroStride ) { // Original Function Definition // HRESULT DrawIndexedPrimitiveUP( // D3DPRIMITIVETYPE PrimitiveType, // UINT MinVertexIndex, // UINT NumVertexIndices, // UINT PrimitiveCount, // const void *pIndexData, // D3DFORMAT IndexDataFormat, // CONST void* pVertexStreamZeroData, // UINT VertexStreamZeroStride // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::DrawIndexedPrimitiveUP()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Check Parameters for Accuracy if (pVertexStreamZeroStride==0) { fErrorValue = TDX_BADPARAMS; if (FOnError) FOnError( this, Name+"::DrawIndexedPrimitiveUP()", "TDX_BADPARAMS", "'pVertexStreamZeroStride' cannot be '0'"); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->DrawIndexedPrimitiveUP( pPrimitiveType, (UINT) pMinVertexIndex, (UINT) pNumVertexIndices, (UINT) pPrimitiveCount, (const void*) pIndexData, pIndexDataFormat, (CONST void*) pVertexStreamZeroData, (UINT) pVertexStreamZeroStride ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DrawIndexedPrimitiveUP()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: DrawPrimitive() // Description: The TDx9_3DDevice::DrawPrimitive() method will render the // specified non indexed geometric primitives into an array of // vertices. // // The primitives drawn come from the current set of data input // streams. // Add a TDx9_3DDevice::SetFVF() call before making any draw // calls if you are converting fixed function legacy code from // previous versions of DirectX. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pPrimitiveType - // The PrimitiveType parameter specifies the type of primitive // to render, as a value of the D3DPRIMITIVETYPE enumerated // type. // pStartVertex - // The StartVertex parameter defines the index of the first // vertex to be used during this call. // pPrimitiveCount - // The PrimitiveCount parameter indicates how many primitives // are to be rendered. // // This value and the PrimitiveType determine how many vertices // are needed. For example, D3DPT_TRIANGLELIST would need 3 // times PrimitiveCount vertices. // TD3DCaps->MaxPrimitiveCount denotes the maximum value allowed // for this parameter. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::DrawPrimitive( D3DPRIMITIVETYPE pPrimitiveType, uint pStartVertex, uint pPrimitiveCount ) { // Original Function Definition // HRESULT DrawPrimitive( // D3DPRIMITIVETYPE PrimitiveType, // UINT StartVertex, // UINT PrimitiveCount // ); // 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 = (uint) fLPDIRECT3DDEVICE9->DrawPrimitive( pPrimitiveType, (UINT) pStartVertex, (UINT) pPrimitiveCount ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DrawPrimitive()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: DrawPrimitiveUP() // Description: The TDx9_3DDevice::DrawPrimitiveUP() method will render the // specified non indexed geometric primitives into an array of // vertices. // // The primitives drawn come from vertex data referenced by a // user defined pointer. // Primarily intended for applications that are unable to store // vertex buffers, this method only supports a single vertex // stream which must be declared as stream 0. // After the call, the stream 0 settings, referenced by // TDx9_3DDevice::GetStreamSource() will be set to NULL. // The vertex data used in the call can safely be released // afterwards. Direct3D completes its access to that data prior // to returning. // // Add a TDx9_3DDevice::SetFVF() call before making any draw // calls if you are converting fixed function legacy code from // previous versions of DirectX. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pPrimitiveType - // The PrimitiveType parameter specifies the type of primitive // to render, as a value of the D3DPRIMITIVETYPE enumerated // type. // pPrimitiveCount - // The PrimitiveCount parameter indicates how many primitives // are to be rendered. // // This value and the PrimitiveType determine how many vertices // are needed. For example, D3DPT_TRIANGLELIST would need 3 // times PrimitiveCount vertices. // TD3DCaps->MaxPrimitiveCount denotes the maximum value allowed // for this parameter. // pVertexStreamZeroData - // The VertexStreamZeroData parameter references the application // defined vertex data. // // The referenced vertex data must be in stream 0. // pVertexStreamZeroStride - // The VertexStreamZeroStride parameter indicates the size, in // bytes, of each vertex. // // This value cannot be 0. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::DrawPrimitiveUP( D3DPRIMITIVETYPE pPrimitiveType, uint pPrimitiveCount, void* pVertexStreamZeroData, uint pVertexStreamZeroStride ) { // Original Function Definition // HRESULT DrawPrimitiveUP( // D3DPRIMITIVETYPE PrimitiveType, // UINT PrimitiveCount, // const void *pVertexStreamZeroData, // UINT VertexStreamZeroStride // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::DrawPrimitiveUP()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Check Parameters for Accuracy if (pVertexStreamZeroStride==0) { fErrorValue = TDX_BADPARAMS; if (FOnError) FOnError( this, Name+"::DrawPrimitiveUP()", "TDX_BADPARAMS", "'pVertexStreamZeroStride' cannot be '0'"); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->DrawPrimitiveUP( pPrimitiveType, (UINT) pPrimitiveCount, (const void*) pVertexStreamZeroData, (UINT) pVertexStreamZeroStride ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DrawPrimitiveUP()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: DrawRectPatch() // Description: The TDx9_3DDevice::DrawRectPatch() method will draw a // rectangular higher order patch. // // If the patch is static, you set the vertex shader and // appropriate streams, fill the TD3DRectPatch_Info referenced // by RectPatchInfo with patch information, set a handle and // perform the call. This has the effect of caching the patch. // Then call this method again with RectPatchInfo set to NULL to // efficiently draw the patch, changing NumSegs if needed. // Cached patches ignore the current data streams but the same // vertex shader must be set as when the patch was originally // cached. // Calling this method to cache a patch with the same handle as // a previous call will invalidate the handle to the previously // cached patch. // // Dynamic patches should not be cached, so set Handle to 0. The // patch will be drawn using the current streams and NumSegs // value. RectPatchInfo cannot be NULL for dynamic patches. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pHandle - // The Handle parameter specifies the handle of the rectangular // patch to store or draw. // pNumSegs - // The NumSegs parameter indicates how many segments each edge // of the patch should be divided into when tessellated, as an // array of 4 floating point values. // pRectPatchInfo - // The RectPatchInfo parameter references a TD3DRectPatch_Info // component describing the rectangular patch to draw or store. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::DrawRectPatch( uint pHandle, float* pNumSegs, D3DRECTPATCH_INFO* pRectPatchInfo ) { // Original Function Definition // HRESULT DrawRectPatch( // UINT Handle, // const float* pNumSegs, // const D3DRECTPATCH_INFO* pRectPatchInfo // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::DrawRectPatch()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->DrawRectPatch( (UINT) pHandle, (const float*) pNumSegs, (const D3DRECTPATCH_INFO*) pRectPatchInfo ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DrawRectPatch()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: DrawTriPatch() // Description: The TDx9_3DDevice::DrawTriPatch() method will draw a // triangular higher order patch. // // If the patch is static, you set the vertex shader and // appropriate streams, fill the TD3DTriPatch_Info referenced by // TriPatchInfo with patch information, set a handle and perform // the call. This has the effect of caching the patch. Then call // this method again with TriPatchInfo set to NULL to // efficiently draw the patch, changing NumSegs if needed. // Cached patches ignore the current data streams but the same // vertex shader must be set as when the patch was originally // cached. // Calling this method to cache a patch with the same handle as // a previous call will invalidate the handle to the previously // cached patch. // // Dynamic patches should not be cached, so set Handle to 0. The // patch will be drawn using the current streams and NumSegs // value. TriPatchInfo cannot be NULL for dynamic patches. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pHandle - // The Handle parameter specifies the handle of the triangular // patch to store or draw. // pNumSegs - // The NumSegs parameter indicates how many segments each edge // of the patch should be divided into when tessellated, as an // array of 3 floating point values. // pTriPatchInfo - // The TriPatchInfo parameter references a TD3DTriPatch_Info // component describing the triangular patch to draw or store. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::DrawTriPatch( uint pHandle, float* pNumSegs, D3DTRIPATCH_INFO* pTriPatchInfo ) { // Original Function Definition // HRESULT DrawTriPatch( // UINT Handle, // const float* pNumSegs, // const D3DTRIPATCH_INFO* pTriPatchInfo // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::DrawTriPatch()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->DrawTriPatch( (UINT) pHandle, (const float*) pNumSegs, (const D3DTRIPATCH_INFO*) pTriPatchInfo ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::DrawTriPatch()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: EndScene() // Description: The TDx9_3DDevice::EndScene() method ends a scene, queuing it // for rendering by the driver. // // Attempts to render outside a TDx9_3DDevice::BeginScene() and // TDx9_3DDevice::EndScene() pair will fail and only one pair // should be called between TDx9_3DDevice::Present or // TDx9_3DSwapChain::Present() calls. This call will fail if // TDx9_3DDevice::BeginScene() failed. // // When this method returns, the scene has been sent to the // driver for rendering, but rendering is not neccessarily // complete, so its a good idea to call TDx9_3DDevice::Present // or TDx9_3DSwapChain::Present() as long after this call as // possible to allow optimal parrallelism between the CPU and // the graphics accelerator, thus giving time for rendering to // complete before presentation and minimising waiting time. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if TDx9_3DDevice::BeginScene() failed or // has not been called. // -------------------------------------------------------------------------- bool __fastcall TDx9_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 = (uint) fLPDIRECT3DDEVICE9->EndScene( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::EndScene()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: EndStateBlock() // Description: The TDx9_3DDevice::EndStateBlock() method tells Direct3D to // cease recording various device settings and return a // TDx9_3DStateBlock pointer. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pSB - // The SB parameter references a TDx9_3DStateBlock representing // the captured device state when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::EndStateBlock( TDx9_3DStateBlock* pSB ) { // Original Function Definition // HRESULT EndStateBlock( // LPDIRECT3DSTATEBLOCK9* ppSB // ); // 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 = (uint) fLPDIRECT3DDEVICE9->EndStateBlock( (pSB==NULL) ? NULL : pSB->Internal_LPDIRECT3DSTATEBLOCK9_Ptr ); // Translate Data returned from Function if (pSB!=NULL) pSB->Internal_LPDIRECT3DSTATEBLOCK9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::EndStateBlock()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: EvictManagedResources() // Description: The TDx9_3DDevice::EvictManagedResources() method will evict // all Direct3D and driver managed resources. // // Only the D3DPOOL_DEFAULT copy is evicted, the system memory // resource copy is retained. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_OUTOFVIDEOMEMORY if not enough display memory was // available for the operation. // D3DERR_COMMAND_UNPARSED when the driver could not parse the // command. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::EvictManagedResources() { // Original Function Definition // HRESULT EvictManagedResources(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::EvictManagedResources()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->EvictManagedResources( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::EvictManagedResources()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetAvailableTextureMem() // Description: The TDx9_3DDevice::GetAvailableTextureMem() method will // return the estimated available texture memory. // // The estimate is rounded to the nearest MB, as alignment and // other resource consumption issues make a precise judgement // difficult. Use this method for large scale resource decisions // such as how many mimmap levels to use, as opposed to checking // to see if another resource could possibly be squeezed into // display memory. // -------------------------------------------------------------------------- UINT __fastcall TDx9_3DDevice::GetAvailableTextureMem() { // Original Function Definition // UINT GetAvailableTextureMem(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetAvailableTextureMem()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return fErrorValue; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetAvailableTextureMem( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetAvailableTextureMem()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return fErrorValue; } // Success! return fErrorValue; } // -------------------------------------------------------------------------- // Method: GetBackBuffer() // Description: The TDx9_3DDevice::GetBackBuffer() method will retrieve a // specified back buffer from the swap chain. // // This call will increase the reference count of the returned // TDx9_3DSurface, so release it when you are done. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if BackBuffer >= number of back buffers. // Params: pSwapChain - // The SwapChain parameter indicates from which swap chain the // back buffer is to be retrieved. // pBackBuffer - // The BackBuffer parameter defines the index of the back buffer // to be retrieved. // // A value of 0 retrieves the first back buffer, not the front // buffer. TDx9_3DDevice::GetFrontBufferData() can be used to // get a copy of front buffer data. // pBackBufferSurface - // The BackBufferSurface parameter will reference the specified // TDx9_3DSurface when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetBackBuffer( uint pSwapChain, uint pBackBuffer, TDx9_3DSurface* pBackBufferSurface ) { // Original Function Definition // HRESULT GetBackBuffer( // UINT iSwapChain, // UINT BackBuffer, // D3DBACKBUFFER_TYPE Type, // LPDIRECT3DSURFACE9* ppBackBuffer // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetBackBuffer()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetBackBuffer( (UINT) pSwapChain, (UINT) pBackBuffer, D3DBACKBUFFER_TYPE_MONO, (pBackBufferSurface==NULL) ? NULL : pBackBufferSurface->Internal_LPDIRECT3DSURFACE9_Ptr ); // Translate Data returned from Function if (pBackBufferSurface!=NULL) pBackBufferSurface->Internal_LPDIRECT3DSURFACE9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetBackBuffer()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetClipPlane() // Description: The TDx9_3DDevice::GetClipPlane() method will retrieve the // coefficients of a user defined clipping plane. // // This method will not work for D3DCREATE_PUREDEVICE's. // The returned coefficients take the form of the general plane // equation. Labelling the Plane elements A, B, C and D, the // equation would be Ax + By + Cz + Dw =0. A homogenous // coordinate point (x, y, z, w) is visible if Ax + By + Cz + Dw // >= 0, othewise it is clipped from the scene. The returned // plane equation exists in world space and will have been // previously set by a TDx9_3DDevice::SetClipPlane() call. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Index > maximum supported clipping // plane index or the Plane array is too small for four floating // point values. // Params: pIndex - // The Index parameter specifies the index of the clipping plane // to be retrieved. // pPlane - // The Plane parameter references the clipping plane // coefficients, as 4 floating point array elements, when the // method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetClipPlane( dword pIndex, float* pPlane ) { // Original Function Definition // HRESULT GetClipPlane( // DWORD Index, // float *pPlane // ); // 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 = (uint) fLPDIRECT3DDEVICE9->GetClipPlane( (DWORD) pIndex, pPlane ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetClipPlane()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetClipStatus() // Description: The TDx9_3DDevice::GetClipStatus() method will retrieve the // current clip status. // // Clip status is used for software vertex processing so this // method will not work on hardware vertex processing devices. // Since TDx9_3DDevice::DrawRectPatch() and // TDx9_3DDevice::DrawTriPatch() are hardware only methods, clip // status will not be updated by those calls. // // When vertices are being processed a clip code is computed for // each one. The clip code is a combination of D3DCS_*** bits, // the relevant bit being set when the vertex falls outsite a // particular clipping plane. The clip status is maintained // using TD3DClipStatus->ClipUnion and // TD3DClipStatus->ClipIntersection, ClipUnion is initially 0 // and is a bitwise OR of all vertex clip codes and // ClipIntersection is initially 0xFFFFFFFF being a bitwise AND // of all vertex clip codes. Both are set to 0 if D3DRS_CLIPPING // is FALSE. The TD3DClipStatus is updated during drawing calls, // so to compute a particular objects clip status, initialize // ClipUnion and ClipIntersection and continue drawing. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if the argument is invalid. // Params: pClipStatus - // The ClipStatus parameter references the TD3DClipStatus // component describing the current clip status when the method // returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetClipStatus( D3DCLIPSTATUS9* pClipStatus ) { // Original Function Definition // HRESULT GetClipStatus( // D3DCLIPSTATUS9 *pClipStatus // ); // 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 = (uint) fLPDIRECT3DDEVICE9->GetClipStatus( pClipStatus ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetClipStatus()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetCreationParameters() // Description: The TDx9_3DDevice::GetCreationParameters() method will // retrieve the parameters used when this device was created. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if the argument is invalid. // Params: pParameters - // The Parameters parameter will reference the // TD3DDevice_Creation_Parameters component holding the // retrieved creation parameters when the method returns. // // TD3DDevice_Creation_Parameters->AdapterOrdinal will contain // the ordinal of the adapter represented by this device. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetCreationParameters( D3DDEVICE_CREATION_PARAMETERS* pParameters ) { // Original Function Definition // HRESULT GetCreationParameters( // D3DDEVICE_CREATION_PARAMETERS *pParameters // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetCreationParameters()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetCreationParameters( pParameters ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetCreationParameters()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetCurrentTexturePalette() // Description: The TDx9_3DDevice::GetCurrentTexturePalette() method will // retrieve the current texture palette. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if PaletteNumber is an invalid pointer. // Params: pPaletteNumber - // The PaletteNumber parameter will reference a value // identifying the current texture palette when the method // returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetCurrentTexturePalette( uint* pPaletteNumber ) { // Original Function Definition // HRESULT GetCurrentTexturePalette( // UINT *pPaletteNumber // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetCurrentTexturePalette()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetCurrentTexturePalette( (UINT*) pPaletteNumber ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetCurrentTexturePalette()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetDepthStencilSurface() // Description: The TDx9_3DDevice::GetDepthStencilSurface() method will // retrieve the depth stencil surface for this device. // // This call increases the reference count of the returned // TDx9_3DSurface, so release it when you are done. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if ZStencilSurface is an invalid pointer. // D3DERR_NOTFOUND when there is no depth stencil buffer for // this device. // Params: pZStencilSurface - // The ZStencilSurface parameter will reference the // TDx9_3DSurface representing the depth stencil buffer when the // method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetDepthStencilSurface( TDx9_3DSurface* pZStencilSurface ) { // Original Function Definition // HRESULT GetDepthStencilSurface( // LPDIRECT3DSURFACE9* ppZStencilSurface // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetDepthStencilSurface()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetDepthStencilSurface( (pZStencilSurface==NULL) ? NULL : pZStencilSurface->Internal_LPDIRECT3DSURFACE9_Ptr ); // Translate Data returned from Function if (pZStencilSurface!=NULL) pZStencilSurface->Internal_LPDIRECT3DSURFACE9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetDepthStencilSurface()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetDeviceCaps() // Description: The TDx9_3DDevice::GetDeviceCaps() method will retrieve the // capabilties of the rendering device. // // This method will retrieve the software vertex pipeline // capabilities if the device is being used in software vertex // processing mode. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Caps is an invalid pointer. // Params: pCaps - // The Caps parameter will reference a TD3DCaps component // holding the retrieved device capabilties when the method // returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetDeviceCaps( D3DCAPS9* pCaps ) { // Original Function Definition // HRESULT GetDeviceCaps( // D3DCAPS9 *pCaps // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetDeviceCaps()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetDeviceCaps( pCaps ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetDeviceCaps()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetDirect3D() // Description: The TDx9_3DDevice::GetDirect3D() method will retrieve the // TDx9_3D that created this device. // // This call increases the reference count of the returned // TDx9_3D, so release it when you are done. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if D3D9 is an invalid pointer. // Params: pD3D9 - // The D3D9 parameter will reference the TDx9_3D that created // this device when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetDirect3D( TDx9_3D* pD3D9 ) { // Original Function Definition // HRESULT GetDirect3D( // LPDIRECT3D9* ppD3D9 // ); // 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 = (uint) fLPDIRECT3DDEVICE9->GetDirect3D( (pD3D9==NULL) ? NULL : pD3D9->Internal_LPDIRECT3D9_Ptr ); // Translate Data returned from Function if (pD3D9!=NULL) pD3D9->Internal_LPDIRECT3D9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetDirect3D()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetDisplayMode() // Description: The TDx9_3DDevice::GetDisplayMode() method will retrieve the // spatial and color resolutions and the refresh frequency of // the display mode set for a specified swap chain. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Mode is an invalid pointer or SwapChain // >= number of swap chains. // Params: pSwapChain - // The SwapChain parameter specifies for which swap chain the // display mode should be retrieved. // pMode - // The Mode parameter will reference a TD3DDisplayMode component // holding the retrieved display mode of the adapter when the // method returns. // // This is the adapter display mode, not the device. The device // display mode may be inactive if not in full screen mode. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetDisplayMode( uint pSwapChain, D3DDISPLAYMODE* pMode ) { // Original Function Definition // HRESULT GetDisplayMode( // UINT iSwapChain, // D3DDISPLAYMODE *pMode // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetDisplayMode()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetDisplayMode( (UINT) pSwapChain, pMode ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetDisplayMode()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetFVF() // Description: The TDx9_3DDevice::GetFVF() method will retrieve the fixed // vertex function declaration. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if FVF is not a valid pointer. // Params: pFVF - // The FVF parameter references the fixed vertex function type, // as values of the D3DFVF constant. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetFVF( dword* pFVF ) { // Original Function Definition // HRESULT GetFVF( // DWORD *pFVF // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetFVF()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetFVF( (DWORD*) pFVF ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetFVF()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetFrontBufferData() // Description: The TDx9_3DDevice::GetFrontBufferData() method will retrieve // a copy of the front buffer into an application allocated // system memory buffer. // // This is the only way an antialiased screen shot can be // captured. This method is slow by design so don't use it in // performance critical paths. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_DRIVERINTERNALERROR when an internal driver error // occurs. Your application should probably shut down if this // error is recieved. // D3DERR_DEVICELOST if the device has been lost and cannot be // reset for now. // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pSwapChain - // The SwapChain parameter specifies for which swap chain the // front buffer data should be retrieved. // pDestSurface - // The DestSurface parameter references an application allocated // TDx9_3DSurface for holding the retrieved front buffer data in // system memory when the method returns. // // The returned data is converted into the standard 32 bits per // pixel format D3DFMT_A8R8G8B8. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetFrontBufferData( uint pSwapChain, TDx9_3DSurface* pDestSurface ) { // Original Function Definition // HRESULT GetFrontBufferData( // UINT iSwapChain, // LPDIRECT3DSURFACE9 pDestSurface // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetFrontBufferData()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetFrontBufferData( (UINT) pSwapChain, (pDestSurface==NULL) ? NULL : pDestSurface->Internal_LPDIRECT3DSURFACE9 ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetFrontBufferData()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetGammaRamp() // Description: The TDx9_3DDevice::GetGammaRamp() method will retrieve the // gamma correction ramp for a specified swap chain. // // Params: pSwapChain - // The SwapChain parameter specifies which swap chains gamma // correction ramp should be retrieved. // pRamp - // The Ramp parameter references a TD3DGammaRamp holding the // gamma correction ramp to be retrieved for the specified swap // chain. // -------------------------------------------------------------------------- void __fastcall TDx9_3DDevice::GetGammaRamp( uint pSwapChain, D3DGAMMARAMP* pRamp ) { // Original Function Definition // void GetGammaRamp( // UINT iSwapChain, // D3DGAMMARAMP *pRamp // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetGammaRamp()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return; } // Call Original Function fLPDIRECT3DDEVICE9->GetGammaRamp( (UINT) pSwapChain, pRamp ); fErrorValue = 0; // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetGammaRamp()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return; } // Success! return; } // -------------------------------------------------------------------------- // Method: GetIndices() // Description: The TDx9_3DDevice::GetIndices() method will retrieve the // TDx9_3DIndexBuffer for this device. // // This call increases the reference count of the returned // TDx9_3DIndexBuffer, so release it when you are done. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if IndexData is not a valid pointer or // there is no index. // Params: pIndexData - // The IndexData parameter will reference a TDx9_3DIndexBuffer // representing the retrieved index data when the method // returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetIndices( TDx9_3DIndexBuffer* pIndexData ) { // Original Function Definition // HRESULT GetIndices( // LPDIRECT3DINDEXBUFFER9* ppIndexData // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetIndices()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetIndices( (pIndexData==NULL) ? NULL : pIndexData->Internal_LPDIRECT3DINDEXBUFFER9_Ptr ); // Translate Data returned from Function if (pIndexData!=NULL) pIndexData->Internal_LPDIRECT3DINDEXBUFFER9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetIndices()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetLight() // Description: The TDx9_3DDevice::GetLight() method will retrieve the // lighting properties of a specified light for this device. // // This method will not work for D3DCREATE_PUREDEVICE's. // Use TDx9_3DDevice::SetLight() to create and define the light // source and then TDx9_3DDevice::LightEnable() can be used to // activate light sources in a scene. New lights are disabled by // default. // TD3DCaps->MaxActiveLights defines how many lights can be // active for this device. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Index >= number of lights or Light is // not a valid pointer. // Params: pIndex - // The Index parameter specifies which light source properties // are to be retrieved. // pLight - // The Light parameter references a TD3DLight for holding the // retrieved lighting properties when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetLight( dword pIndex, D3DLIGHT9* pLight ) { // Original Function Definition // HRESULT GetLight( // DWORD Index, // D3DLIGHT9 *pLight // ); // 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 = (uint) fLPDIRECT3DDEVICE9->GetLight( (DWORD) pIndex, pLight ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetLight()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetLightEnable() // Description: The TDx9_3DDevice::GetLightEnable() method will indicate // whether a specified light is active or not. // // This method will not work for D3DCREATE_PUREDEVICE's. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Index >= number of lights or Enable is // not a valid pointer. // Params: pIndex - // The Index parameter specifies which light source's status is // to be retrieved. // pEnable - // The Enable parameter will references a value indicating the // status of the specified light when the method returns. // // A value of 0 indicates the light is disabled, otherwise the // light is active. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetLightEnable( dword pIndex, bool* pEnable ) { // Original Function Definition // HRESULT GetLightEnable( // DWORD Index, // BOOL *pEnable // ); // 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 = (uint) fLPDIRECT3DDEVICE9->GetLightEnable( (DWORD) pIndex, (BOOL*) pEnable ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetLightEnable()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetMaterial() // Description: The TDx9_3DDevice::GetMaterial() method will retrieve the // current material properties for this device. // // This method will not work for D3DCREATE_PUREDEVICE's. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Material is not a valid pointer. // Params: pMaterial - // The Material parameter references a TD3DMaterial component // for holding the retrieved material properties when the method // returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetMaterial( D3DMATERIAL9* pMaterial ) { // Original Function Definition // HRESULT GetMaterial( // D3DMATERIAL9 *pMaterial // ); // 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 = (uint) fLPDIRECT3DDEVICE9->GetMaterial( pMaterial ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetMaterial()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetNPatchMode() // Description: The TDx9_3DDevice::GetNPatchMode() method will return how // many subdivision segments are set for this device. // // A return value less than 1.0 indicates N patches are // disabled. The default value is 0.0. // -------------------------------------------------------------------------- FLOAT __fastcall TDx9_3DDevice::GetNPatchMode() { // Original Function Definition // FLOAT GetNPatchMode(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetNPatchMode()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return (float) fErrorValue; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetNPatchMode( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetNPatchMode()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return (float) fErrorValue; } // Success! return (float) fErrorValue; } // -------------------------------------------------------------------------- // Method: GetNumberOfSwapChains() // Description: The TDx9_3DDevice::GetNumberOfSwapChains() method will return // how many implicit swap chains were created in the // TDx9_3D::CreateDevice() call that created this device. // // TDx9_3DDevice::CreateAdditionalSwapChain() can be used to // create extra swap chains. // -------------------------------------------------------------------------- UINT __fastcall TDx9_3DDevice::GetNumberOfSwapChains() { // Original Function Definition // UINT GetNumberOfSwapChains(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetNumberOfSwapChains()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return fErrorValue; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetNumberOfSwapChains( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetNumberOfSwapChains()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return fErrorValue; } // Success! return fErrorValue; } // -------------------------------------------------------------------------- // Method: GetPaletteEntries() // Description: The TDx9_3DDevice::GetPaletteEntries() method will retrieve // the elements of a specified palette. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Entries is not a valid pointer. // Params: pPaletteNumber - // The PaletteNumber parameter specifies which palette to // retrieve. // pEntries - // The Entries parameter references a TD3DPaletteEntry component // for holding the retrieved palette entries when the method // returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetPaletteEntries( uint pPaletteNumber, PALETTEENTRY* pEntries ) { // Original Function Definition // HRESULT GetPaletteEntries( // UINT PaletteNumber, // PALETTEENTRY *pEntries // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetPaletteEntries()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetPaletteEntries( (UINT) pPaletteNumber, pEntries ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetPaletteEntries()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetPixelShader() // Description: The TDx9_3DDevice::GetPixelShader() method will retrieve the // TDx9_3DPixelShader currently set for this device. // // This method will not work for D3DCREATE_PUREDEVICE's. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Shader is not a valid pointer. // Params: pShader - // The Shader parameter will reference the current // TDx9_3DPixelShader for this device when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetPixelShader( TDx9_3DPixelShader* pShader ) { // Original Function Definition // HRESULT GetPixelShader( // LPDIRECT3DPIXELSHADER9* ppShader // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetPixelShader()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetPixelShader( (pShader==NULL) ? NULL : pShader->Internal_LPDIRECT3DPIXELSHADER9_Ptr ); // Translate Data returned from Function if (pShader!=NULL) pShader->Internal_LPDIRECT3DPIXELSHADER9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetPixelShader()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetPixelShaderConstantB() // Description: The TDx9_3DDevice::GetPixelShaderConstantB() method will // retrieve boolean pixel shader constants. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStartRegister - // The StartRegister parameter specifies the register number of // the first boolean constant to retrieve. // pConstantData - // The ConstantData parameter references an array for holding // the retrieved boolean constants when the method returns. // pBoolCount - // The BoolCount parameter indicates how many boolean values are // are in the ConstantData array. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetPixelShaderConstantB( uint pStartRegister, bool* pConstantData, uint pBoolCount ) { // Original Function Definition // HRESULT GetPixelShaderConstantB( // UINT StartRegister, // BOOL *pConstantData, // UINT BoolCount // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetPixelShaderConstantB()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetPixelShaderConstantB( (UINT) pStartRegister, (BOOL*) pConstantData, (UINT) pBoolCount ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetPixelShaderConstantB()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetPixelShaderConstantF() // Description: The TDx9_3DDevice::GetPixelShaderConstantF() method will // retrieve floating point pixel shader constants. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStartRegister - // The StartRegister parameter specifies the register number of // the first floating point constant to retrieve. // pConstantData - // The ConstantData parameter references an array for holding // the retrieved floating point constants when the method // returns. // pVector4fCount - // The Vector4fCount parameter indicates how many four floating // point vectors are in the ConstantData array. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetPixelShaderConstantF( uint pStartRegister, float* pConstantData, uint pVector4fCount ) { // Original Function Definition // HRESULT GetPixelShaderConstantF( // UINT StartRegister, // float *pConstantData, // UINT Vector4fCount // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetPixelShaderConstantF()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetPixelShaderConstantF( (UINT) pStartRegister, pConstantData, (UINT) pVector4fCount ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetPixelShaderConstantF()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetPixelShaderConstantI() // Description: The TDx9_3DDevice::GetPixelShaderConstantI() method will // retrieve integer pixel shader constants. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStartRegister - // The StartRegister parameter specifies the register number of // the first integer constant to retrieve. // pConstantData - // The ConstantData parameter references an array for holding // the retrieved integer constants when the method returns. // pVector4iCount - // The Vector4fCount parameter indicates how many four integer // vectors are in the ConstantData array. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetPixelShaderConstantI( uint pStartRegister, int* pConstantData, uint pVector4iCount ) { // Original Function Definition // HRESULT GetPixelShaderConstantI( // UINT StartRegister, // int *pConstantData, // UINT Vector4iCount // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetPixelShaderConstantI()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetPixelShaderConstantI( (UINT) pStartRegister, pConstantData, (UINT) pVector4iCount ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetPixelShaderConstantI()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetRasterStatus() // Description: The TDx9_3DDevice::GetRasterStatus() method will retrieve the // status of the monitor being used by the specified swap chain. // // This method will not work for D3DCREATE_PUREDEVICE's. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if RasterStatus is an invalid pointer or // TD3DCaps->Caps->D3DCAPS_READ_SCANLINE is not available. // Params: pSwapChain - // The SwapChain parameter specifies for which swap chain the // raster status should be retrieved. // pRasterStatus - // The RasterStatus parameter references a TD3DRaster_Status // component for holding the retrieved raster status information // when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetRasterStatus( uint pSwapChain, D3DRASTER_STATUS* pRasterStatus ) { // Original Function Definition // HRESULT GetRasterStatus( // UINT iSwapChain, // D3DRASTER_STATUS *pRasterStatus // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetRasterStatus()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetRasterStatus( (UINT) pSwapChain, pRasterStatus ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetRasterStatus()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetRenderState() // Description: The TDx9_3DDevice::GetRenderState() method will retrieve the // current value of a specified render state type. // // This method will not work for D3DCREATE_PUREDEVICE's. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pState - // The State parameter specifies for which render state type, as // a value of the D3DRENDERSTATE enumerated type, the value // should be retrieved. // pValue - // The Value parameter will reference the value of the specified // render state type when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetRenderState( D3DRENDERSTATETYPE pState, dword* pValue ) { // Original Function Definition // HRESULT GetRenderState( // D3DRENDERSTATETYPE State, // DWORD *pValue // ); // 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 = (uint) fLPDIRECT3DDEVICE9->GetRenderState( pState, (DWORD*) pValue ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetRenderState()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetRenderTarget() // Description: The TDx9_3DDevice::GetRenderTarget() method will retrieve the // specified render target TDx9_3DSurface. // // Multiple render targets are now supported, to a maximum of // TD3DCaps->NumSumultaneousRTs. // This call increases the reference count of the returned // TDx9_3DSurface, so release it when you are done. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // D3DERR_NOTFOUND if there is no render target for the // specified RenderTargetIndex. // Params: pRenderTargetIndex - // The RenderTargetIndex parameter specifies the index of the // render target to retrieve. // pRenderTarget - // The RenderTarget parameter will reference the specified // render target TDx9_3DSurface when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetRenderTarget( dword pRenderTargetIndex, TDx9_3DSurface* pRenderTarget ) { // Original Function Definition // HRESULT GetRenderTarget( // DWORD RenderTargetIndex, // LPDIRECT3DSURFACE9* ppRenderTarget // ); // 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 = (uint) fLPDIRECT3DDEVICE9->GetRenderTarget( (DWORD) pRenderTargetIndex, (pRenderTarget==NULL) ? NULL : pRenderTarget->Internal_LPDIRECT3DSURFACE9_Ptr ); // Translate Data returned from Function if (pRenderTarget!=NULL) pRenderTarget->Internal_LPDIRECT3DSURFACE9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetRenderTarget()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetRenderTargetData() // Description: The TDx9_3DDevice::GetRenderTargetData() method will retrieve // a copy of the data from a specified render target. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_DRIVERINTERNALERROR when an internal driver error // occurs. Your application should probably shut down if this // error is recieved. // D3DERR_DEVICELOST if the device has been lost and cannot be // reset for now. // D3DERR_INVALIDCALL if the format and/or size of the source // and destination surfaces do not match or it is a multisampled // render target. // Params: pRenderTarget - // The RenderTarget parameter references the render target // TDx9_3DSurface to copy. // // This surface must be a regular render target or render target // texture level created with POOL_DEFAULT. // pDestSurface - // The DestSurface parameter references the TDx9_3DSurface for // holding the copied surface data when the method returns. // // This surface must be an off-screen plain surface or texture // level created with D3DPOOL_SYSTEMMEM. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetRenderTargetData( TDx9_3DSurface* pRenderTarget, TDx9_3DSurface* pDestSurface ) { // Original Function Definition // HRESULT GetRenderTargetData( // LPDIRECT3DSURFACE9 pRenderTarget, // LPDIRECT3DSURFACE9 pDestSurface // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetRenderTargetData()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetRenderTargetData( (pRenderTarget==NULL) ? NULL : pRenderTarget->Internal_LPDIRECT3DSURFACE9, (pDestSurface==NULL) ? NULL : pDestSurface->Internal_LPDIRECT3DSURFACE9 ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetRenderTargetData()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetSamplerState() // Description: The TDx9_3DDevice::GetSamplerState() method will retrieve the // sampler state value for a specified sampler stage. // // This method will not work for D3DCREATE_PUREDEVICE's. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pSampler - // The Sampler parameter specifies the index of the sampler // stage to retrieve. // pType - // The Type parameter indicates the type of sampler state to // retrieve, as a value of the D3DSAMPLERSTATETYPE enumerated // type. // pValue - // The Value parameter will reference the retrieved sampler // state value when the method returns. // // The actual meaning of this value depends on the Type setting. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetSamplerState( dword pSampler, D3DSAMPLERSTATETYPE pType, dword* pValue ) { // Original Function Definition // HRESULT GetSamplerState( // DWORD Sampler, // D3DSAMPLERSTATETYPE Type, // DWORD* pValue // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetSamplerState()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetSamplerState( (DWORD) pSampler, pType, (DWORD*) pValue ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetSamplerState()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetScissorRect() // Description: The TDx9_3DDevice::GetScissorRect() method will retrieve the // scissor rectangle used as a clipping region for this device // if scissor testing is enabled. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Rect is an invalid pointer or there is // no scissor rectangle. // Params: pRect - // The Rect parameter will reference the retrieved rectangle // when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetScissorRect( TRect* pRect ) { // Original Function Definition // HRESULT GetScissorRect( // CONST RECT* pRect // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetScissorRect()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function //fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetScissorRect( (CONST RECT*) pRect ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetScissorRect()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetSoftwareVertexProcessing() // Description: The TDx9_3DDevice::GetSoftwareVertexProcessing() method will // return TRUE if software vertex processing mode is enabled and // FALSE otherwise. // // For a mixed mode device, you can switch between hardware and // software vertex processing with // TDx9_3DDevice::SetSoftwareVertexProcessing(). // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetSoftwareVertexProcessing() { // Original Function Definition // BOOL GetSoftwareVertexProcessing(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetSoftwareVertexProcessing()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetSoftwareVertexProcessing( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetSoftwareVertexProcessing()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetStreamSource() // Description: The TDx9_3DDevice::GetStreamSource() method will retrieve the // TDx9_3DVertexBuffer() that is bound to a specified data // stream. // // This call increases the reference count of the returned // TDx9_3DVertexBuffer, so release it when you are done. // Streams are uniform arrays of component data, with each // component consisting of one or more values representing // information such as position, normal or color. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStreamNumber - // The StreamNumber parameter specifies which stream's vertex // buffer is to be retrieved. // // This is a value between 0 and the number of streams - 1. // pStreamData - // The StreamData parameter will reference the // TDx9_3DVertexBuffer bound to the specified data stream when // the method returns. // pOffsetInBytes - // The OffsetInBytes parameter will indicate the offset, in // bytes, from the start of the stream to the first vertex when // the method returns. // pStride - // The Stride parameter will reference the stride of the // retrieved vertex buffer when the method returns. // // A flexible vertex format (FVF) vertex shader's vertex stream // Stride must match the vertex size as computed from the FVF. // If using a declaration, Stride should be >= than the stream // size computed from the declaration. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetStreamSource( uint pStreamNumber, TDx9_3DVertexBuffer* pStreamData, uint* pOffsetInBytes, uint* pStride ) { // Original Function Definition // HRESULT GetStreamSource( // UINT StreamNumber, // LPDIRECT3DVERTEXBUFFER9* ppStreamData, // UINT *pOffsetInBytes, // UINT *pStride // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetStreamSource()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetStreamSource( (UINT) pStreamNumber, (pStreamData==NULL) ? NULL : pStreamData->Internal_LPDIRECT3DVERTEXBUFFER9_Ptr, (UINT*) pOffsetInBytes, (UINT*) pStride ); // Translate Data returned from Function if (pStreamData!=NULL) pStreamData->Internal_LPDIRECT3DVERTEXBUFFER9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetStreamSource()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetStreamSourceFreq() // Description: The TDx9_3DDevice::GetStreamSourceFreq() method will retrieve // the value of a specified steam source's frequency divider. // // Vertex shaders can now be invoked more than once per vertex. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStreamNumber - // The StreamNumber parameter specifies which stream's frequency // divider number is to be retrieved. // // This is a value between 0 and the number of streams - 1. // pDivider - // The Divider parameter will reference the frequency divider // value for the specified stream when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetStreamSourceFreq( uint pStreamNumber, uint* pDivider ) { // Original Function Definition // HRESULT GetStreamSourceFreq( // UINT StreamNumber, // UINT* pDivider // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetStreamSourceFreq()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetStreamSourceFreq( (UINT) pStreamNumber, (UINT*) pDivider ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetStreamSourceFreq()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetSwapChain() // Description: The TDx9_3DDevice::GetSwapChain() method will retrieve a copy // of a specified TDx9_3DSwapChain. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pSwapChain - // The SwapChain parameter specifies the ordinal of the // TDx9_3DSwapChain to be copied. // pSwapChainPointer - // The SwapChainPointer parameter references the // TDx9_3DSwapChain that is to hold the copied swap chain when // the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetSwapChain( uint pSwapChain, TDx9_3DSwapChain* pSwapChainPointer ) { // Original Function Definition // HRESULT GetSwapChain( // UINT iSwapChain, // LPDIRECT3DSWAPCHAIN9* ppSwapChain // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetSwapChain()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetSwapChain( (UINT) pSwapChain, (pSwapChainPointer==NULL) ? NULL : pSwapChainPointer->Internal_LPDIRECT3DSWAPCHAIN9_Ptr ); // Translate Data returned from Function if (pSwapChainPointer!=NULL) pSwapChainPointer->Internal_LPDIRECT3DSWAPCHAIN9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetSwapChain()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetTexture() // Description: The TDx9_3DDevice::GetTexture() method will retrieve the // TDx9_3DTexture bound to the specified texture stage. // // This call increases the reference count of the returned // TDx9_3DTexture, so release it when you are done. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStage - // The Stage parameter specifies from which texture stage the // texture is to be retrieved. // // This will be a value between 0 and the number of texture // stages - 1. As a device may have a maximum of 8 set textures, // the maximum stage identifier is 7. // pTexture - // The Texture parameter will reference the retrieved // TDx9_3DTexture when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetTexture( dword pStage, TDx9_3DBaseTexture* pTexture ) { // Original Function Definition // HRESULT GetTexture( // DWORD Stage, // LPDIRECT3DBASETEXTURE9* ppTexture // ); // 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 = (uint) fLPDIRECT3DDEVICE9->GetTexture( (DWORD) pStage, (pTexture==NULL) ? NULL : pTexture->Internal_LPDIRECT3DBASETEXTURE9_Ptr ); // Translate Data returned from Function if (pTexture!=NULL) pTexture->Internal_LPDIRECT3DBASETEXTURE9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetTexture()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetTextureStageState() // Description: The TDx9_3DDevice::GetTextureStageState() method will // retrieve the state value for a specified texture stage. // // This method will not work for D3DCREATE_PUREDEVICE's. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStage - // The Stage parameter specifies from which texture stage the // state value is to be retrieved. // // This will be a value between 0 and the number of texture // stages - 1. As a device may have a maximum of 8 set textures, // the maximum value here is 7. // pType - // The Type parameter indicates the type of texture state to // retrieve, as a value of the D3DTEXTURESTAGESTATETYPE // enumerated type. // pValue - // The Value parameter will reference the retrieved texture // state value when the method returns. // // The actual meaning of this value depends on the Type setting. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetTextureStageState( dword pStage, D3DTEXTURESTAGESTATETYPE pType, dword* pValue ) { // Original Function Definition // HRESULT GetTextureStageState( // DWORD Stage, // D3DTEXTURESTAGESTATETYPE Type, // DWORD *pValue // ); // 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 = (uint) fLPDIRECT3DDEVICE9->GetTextureStageState( (DWORD) pStage, pType, (DWORD*) pValue ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetTextureStageState()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetTransform() // Description: The TDx9_3DDevice::GetTransform() method will retrieve a // transformation state matrix. // // This method will not work for D3DCREATE_PUREDEVICE's. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pState - // The State parameter indicates the transform type to retrieve, // as a value of the D3DTRANSFORMSTATETYPE enumerated type or // the D3DTS_WORLDMATRIX macro. // pMatrix - // The Matrix parameter will reference a TD3DMatrix component // for holding the retrieved transform matrix when the method // returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetTransform( D3DTRANSFORMSTATETYPE pState, D3DMATRIX* pMatrix ) { // Original Function Definition // HRESULT GetTransform( // D3DTRANSFORMSTATETYPE State, // D3DMATRIX *pMatrix // ); // 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 = (uint) fLPDIRECT3DDEVICE9->GetTransform( pState, pMatrix ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetTransform()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetVertexDeclaration() // Description: The TDx9_3DDevice::GetVertexDeclaration() method will // retrieve the vertex shader declaration for this device. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pDecl - // The Decl parameter will reference a TDx9_3DVertexDeclaration // component representing the vertex shader declaration for this // device when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetVertexDeclaration( TDx9_3DVertexDeclaration* pDecl ) { // Original Function Definition // HRESULT GetVertexDeclaration( // LPDIRECT3DVERTEXDECLARATION9* ppDecl // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetVertexDeclaration()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetVertexDeclaration( (pDecl==NULL) ? NULL : pDecl->Internal_LPDIRECT3DVERTEXDECLARATION9_Ptr ); // Translate Data returned from Function if (pDecl!=NULL) pDecl->Internal_LPDIRECT3DVERTEXDECLARATION9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetVertexDeclaration()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetVertexShader() // Description: The TDx9_3DDevice::GetVertexShader() method will retrieve the // TDx9_3DVertexShader currently set for this device. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Shader is not a valid pointer. // Params: pShader - // The Shader parameter will reference the current // TDx9_3DVertexShader for this device when the method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetVertexShader( TDx9_3DVertexShader* pShader ) { // Original Function Definition // HRESULT GetVertexShader( // LPDIRECT3DVERTEXSHADER9* ppShader // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetVertexShader()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetVertexShader( (pShader==NULL) ? NULL : pShader->Internal_LPDIRECT3DVERTEXSHADER9_Ptr ); // Translate Data returned from Function if (pShader!=NULL) pShader->Internal_LPDIRECT3DVERTEXSHADER9_Update(); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetVertexShader()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetVertexShaderConstantB() // Description: The TDx9_3DDevice::GetVertexShaderConstantB() method will // retrieve boolean vertex shader constants. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStartRegister - // The StartRegister parameter specifies the register number of // the first boolean constant to retrieve. // pConstantData - // The ConstantData parameter references an array for holding // the retrieved boolean constants when the method returns. // pBoolCount - // The BoolCount parameter indicates how many boolean values are // are in the ConstantData array. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetVertexShaderConstantB( uint pStartRegister, bool* pConstantData, uint pBoolCount ) { // Original Function Definition // HRESULT GetVertexShaderConstantB( // UINT StartRegister, // BOOL *pConstantData, // UINT BoolCount // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetVertexShaderConstantB()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetVertexShaderConstantB( (UINT) pStartRegister, (BOOL*) pConstantData, (UINT) pBoolCount ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetVertexShaderConstantB()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetVertexShaderConstantF() // Description: The TDx9_3DDevice::GetVertexShaderConstantF() method will // retrieve floating point vertex shader constants. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStartRegister - // The StartRegister parameter specifies the register number of // the first floating point constant to retrieve. // pConstantData - // The ConstantData parameter references an array for holding // the retrieved floating point constants when the method // returns. // pVector4fCount - // The Vector4fCount parameter indicates how many four floating // point vectors are in the ConstantData array. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetVertexShaderConstantF( uint pStartRegister, float* pConstantData, uint pVector4fCount ) { // Original Function Definition // HRESULT GetVertexShaderConstantF( // UINT StartRegister, // float *pConstantData, // UINT Vector4fCount // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetVertexShaderConstantF()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetVertexShaderConstantF( (UINT) pStartRegister, pConstantData, (UINT) pVector4fCount ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetVertexShaderConstantF()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetVertexShaderConstantI() // Description: The TDx9_3DDevice::GetVertexShaderConstantI() method will // retrieve integer vertex shader constants. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStartRegister - // The StartRegister parameter specifies the register number of // the first integer constant to retrieve. // pConstantData - // The ConstantData parameter references an array for holding // the retrieved integer constants when the method returns. // pVector4iCount - // The Vector4fCount parameter indicates how many four integer // vectors are in the ConstantData array. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetVertexShaderConstantI( uint pStartRegister, int* pConstantData, uint pVector4iCount ) { // Original Function Definition // HRESULT GetVertexShaderConstantI( // UINT StartRegister, // int *pConstantData, // UINT Vector4iCount // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetVertexShaderConstantI()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->GetVertexShaderConstantI( (UINT) pStartRegister, pConstantData, (UINT) pVector4iCount ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetVertexShaderConstantI()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetViewport() // Description: The TDx9_3DDevice::GetViewport() method will retrieve the // current viewport parameters of this device. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Viewport is an invalid pointer. // Params: pViewport - // The Viewport parameter references a TD3DViewport component // that will hold the retrieved viewport parameters when the // method returns. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::GetViewport( D3DVIEWPORT9* pViewport ) { // Original Function Definition // HRESULT GetViewport( // D3DVIEWPORT9 *pViewport // ); // 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 = (uint) fLPDIRECT3DDEVICE9->GetViewport( pViewport ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::GetViewport()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: LightEnable() // Description: The TDx9_3DDevice::LightEnable() method will enable or // disable a specified set of lighting parameters. // // When LightIndex specifies a non existent light, a new one // will be created and set to the status in Enable. // The TD3DLight properties for the new light will be as // follows: // Type: D3DLIGHT_DIRECTIONAL // Diffuse: (R:1, G:1, B:1, A:0) // Specular: (R:0, G:0, B:0, A:0) // Ambient: (R:0, G:0, B:0, A:0) // Position: (0, 0, 0) // Direction: (0, 0, 1) // Range: 0 // Falloff: 0 // Attenuation0: 0 // Attenuation1: 0 // Attenuation2: 0 // Theta: 0 // Phi: 0 // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided or an // additional light cannot be created. // Params: pLightIndex - // The LightIndex parameter specifies which lights status to // change. // pEnable - // The Enable parameter defines the specified lights enable // status. // // TRUE to enable and FALSE to disable. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::LightEnable( dword pLightIndex, bool pEnable ) { // Original Function Definition // HRESULT LightEnable( // DWORD LightIndex, // 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; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->LightEnable( (DWORD) pLightIndex, (BOOL) pEnable ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::LightEnable()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: MultiplyTransform() // Description: The TDx9_3DDevice::MultiplyTransform() method will multiply // the world, view or projection matrix by an application // defined matrix. // // The order of operation is Matrix times State. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when invalid parameters are provided. // Params: pState - // The State parameter indicates the transform type to multiply, // as a value of the D3DTRANSFORMSTATETYPE enumerated type or // the D3DTS_WORLDMATRIX macro. // pMatrix - // The Matrix parameter references a TD3DMatrix component // holding the matrix to be used in the multiplication. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::MultiplyTransform( D3DTRANSFORMSTATETYPE pState, D3DMATRIX* pMatrix ) { // Original Function Definition // HRESULT MultiplyTransform( // D3DTRANSFORMSTATETYPE State, // CONST D3DMATRIX *pMatrix // ); // 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 = (uint) fLPDIRECT3DDEVICE9->MultiplyTransform( pState, (CONST D3DMATRIX*) pMatrix ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::MultiplyTransform()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Present() // Description: The TDx9_3DDevice::Present() method will present the contents // of the next back buffer in the swap chain to the front // buffer. // // If SourceRect and DestRect are different sizes, a stretch // operation will be applied. // For those familiar with older versions of DirectX, this // operation is somewhat similar to a Flip call. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_DEVICELOST if the device is lost and cannot be reset // right now. // D3DERR_DRIVERINTERNALERROR when there was an internal driver // error. Your application should probably shut down if this // error is returned. // D3DERR_INVALIDCALL if invalid parameters are provided or the // call falls between BeginScene and EndScene (exception: render // target is not the current render target) // Params: pSourceRect - // The SourceRect parameter specifies the source rectangle for // the presentation. // // A setting of NULL indicates the entire source surface is // presented and NULL must be set unless the swap chain was // created with D3DSWAPEFFECT_COPY. // Should SourceRect exceed the size of the source surface, it // will be clipped to the size of the source surface. // pDestRect - // The DestRect parameter specifies the destination rectangle, // in window client coordinates, for the presentation. // // A setting of NULL indicates the entire client area is filled // and NULL must be set unless the swap chain was created with // D3DSWAPEFFECT_COPY. // Should DestRect exceed the size of the destination client // area, it will be clipped to the size of the client area. // pDestWindowOverride - // The DestWindowOverride parameter references a destination // window whose client area will be the target for the // presentation. // // Set NULL to use the value of // TD3DPresent_Parameters->WndDeviceWindow as the destination. // pDirtyRegion - // The DirtyRegion parameter specifies a set of regions // representing the minimal set of pixels that need updating. // // This can help optimise the presentation by copying only those // pixels, but should not be relied upon to copy the region // exactly. // This value must be NULL unless the swap chain was created // with D3DSWAPEFFECT_COPY. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::Present( TRect* pSourceRect, TRect* pDestRect, HWND pDestWindowOverride, RGNDATA* pDirtyRegion ) { // Original Function Definition // HRESULT Present( // CONST RECT *pSourceRect, // CONST RECT *pDestRect, // HWND hDestWindowOverride, // CONST RGNDATA *pDirtyRegion // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Present()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->Present( (CONST RECT*) pSourceRect, (CONST RECT*) pDestRect, pDestWindowOverride, (CONST RGNDATA*) pDirtyRegion ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Present()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: ProcessVertices() // Description: The TDx9_3DDevice::ProcessVertices() method will process the // input data steams using a vertex shader and place the // resulting interleaved vertex data into the destination vertex // buffer. // // The order of operations performed is: // Vertices are transformed into projection space using the // world + view + projection matrix // Viewport settings are used to compute screen coordinates // If enabled, clipping codes are computed and put into an // internal buffer associated with the destination vertex // buffer. If a vertex is inside the viewing frustrum its screen // coordinates are calculated, otherwise it is stored in the // destination vertex buffer in projection space coordinates. // There is no user access to the internal clip code buffer and // no clipping of triangles or other primitives is done. // // If the output texture coordinate format defines more // coordinates than are copied, transformed or generated, // Direct3D does not change those extra components. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL when invalid parameters are provided. // Params: pSrcStartIndex - // The SrcStartIndex parameter specifies which vertex to start // from in the input stream. // pDestIndex - // The DestIndex parameter specifies where to start storing the // processed vertices in the destination vertex buffer. // pVertexCount - // The VertexCount parameter indicates how many vertices are to // be processed. // pDestBuffer - // The DestBuffer parameter references the TDx9_3DVertexBuffer // that will represent the interleaved vertex data produced by // this method. // // TDx9_3DDevice::CreateVertexBuffer->FVF cannot have been zero // when this vertex buffer was created as this FVF value // dictates the vertex elements present in the destination // vertex buffer. // pVertexDecl - // The VertexDecl parameter references the // TDx9_3DVertexDeclaration representing the output vertex data // declaration. // // When using vertex shader 3.0 or above, this vertex // declaration must be present. // pFlags - // The Flags parameter can be set to 0 for default processing or // D3DPV_DONOTCOPYDATA combined with one or more values of the // D3DLOCK constant appropriate to the destination vertex // buffer. // // Setting D3DPV_DONOTCOPYDATA means that only vertices affected // by the vertex operation will be copied into the destination // vertex buffer. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::ProcessVertices( uint pSrcStartIndex, uint pDestIndex, uint pVertexCount, TDx9_3DVertexBuffer* pDestBuffer, TDx9_3DVertexDeclaration* pVertexDecl, dword pFlags ) { // Original Function Definition // HRESULT ProcessVertices( // UINT SrcStartIndex, // UINT DestIndex, // UINT VertexCount, // LPDIRECT3DVERTEXBUFFER9 pDestBuffer, // LPDIRECT3DVERTEXDECLARATION9 pVertexDecl, // DWORD Flags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::ProcessVertices()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->ProcessVertices( (UINT) pSrcStartIndex, (UINT) pDestIndex, (UINT) pVertexCount, (pDestBuffer==NULL) ? NULL : pDestBuffer->Internal_LPDIRECT3DVERTEXBUFFER9, (pVertexDecl==NULL) ? NULL : pVertexDecl->Internal_LPDIRECT3DVERTEXDECLARATION9, (DWORD) pFlags ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::ProcessVertices()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Reset() // Description: The TDx9_3DDevice::Reset() method will redefine the type, // size and format of the swap chain. // // The call must be made on the same thread as created the // device. // All explicit render targets, depth stencil surfaces, state // blocks, extra swap chains and D3DPOOL_DEFAULT resources // associated with the device should be released prior to // calling this method. // This call loses all texture memory surfaces and state // information and flushes managed textures from video memory // but pixel and vertex shaders will survive and need not be // explicitly recreated. // // If the new swap chain settings indicate it is full screen, // the adapter will be placed into the display mode matching the // new size. Only one full screen swap chain is allowed per // device and full screen mode requires the back buffer format // be specified. // D3DFMT_UNKNOWN can be specified as the windowed mode back // buffer format in calls to this method, // TDx9_3D::CreateDevice() and TDx9_3DDevice::Reset(), so you // dont need to retrieve the current desktop format before // making this call for windowed mode. // // Until this call returns, avoid making any Direct3D calls and // your application can expect messages to be sent to it during // the call. // When this method fails the device is put into the "lost" // state unless its already "not reset". // TDx9_3DDevice::TestCooperativeLevel() can be used to check // for these states, returning D3DERR_DEVICELOST or // D3DERR_DEVICENOTRESET respectively. // After this method fails, only TDx9_3DDevice::Reset(), // TDx9_3DDevice::TestCooperativeLevel() and the various Release // member functions can be used. Attempting to call any other // method may generate an exception, with potentially fatal // results for your application. // // If reseting multiple adapters in a group, // PresentationParameters should reference a // TD3DPresent_Parameters component holding one set of // presentation parameters for each display in the adapter // group. For multihead devices created with // D3DCREATE_ADAPTERGROUP_DEVICE, these presentation parameters // must each specify full screen display, windowed mode is only // accessible by destroying the device and recreating a non // multihead device in windowed mode. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_DEVICELOST if the device is lost and cannot be reset // right now. // D3DERR_DRIVERINTERNALERROR when there was an internal driver // error. Your application should probably shut down if this // error is returned. // D3DERR_INVALIDCALL if invalid parameters are provided. // D3DERR_OUTOFVIDEOMEMORY if not enough display memory was // available for the operation. // E_OUTOFMEMORY if not enough memory could be allocated to // complete the call. // Params: pPresentationParameters - // The PresentationParameters parameter references a // TD3DPresent_Parameters component holding the new presentation // parameters. // // TD3DPresent_Parameters->BackBufferCount = 0 results in one // back buffer. // // For multihead device's there must be several sets of new // presentation parameters in the TD3DPresent_Parameters, one // for each head, all specifying full screen mode. // // When the method returns the // TD3DPresent_Parameters->BackBufferCount, // TD3DPresent_Parameters->BackBufferWidth and // TD3DPresent_Parameters->BackBufferHeight will all be set to // 0. // TD3DPresent_Parameters->BackBufferFormat is D3DFMT_UNKNOWN // for windowed mode only. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::Reset( D3DPRESENT_PARAMETERS* pPresentationParameters ) { // Original Function Definition // HRESULT Reset( // D3DPRESENT_PARAMETERS* pPresentationParameters // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Reset()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Check Parameters for Accuracy if (pPresentationParameters==NULL) { fErrorValue = TDX_BADPARAMS; if (FOnError) FOnError( this, Name+"::Reset()", "TDX_BADPARAMS", "'pPresentationParameters' cannot be 'NULL'"); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->Reset( pPresentationParameters ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::Reset()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetClipPlane() // Description: The TDx9_3DDevice::SetClipPlane() method will define the // coefficients of a user defined clipping plane. // // Set the corresponding bit in the DWORD applied to the // D3DRS_CLIPPLANEENABLE render state to enable the clipping // plane being defined here. // // The set coefficients take the form of the general plane // equation. Labelling the Plane elements A, B, C and D, the // equation would be Ax + By + Cz + Dw =0. A homogenous // coordinate point (x, y, z, w) is visible if Ax + By + Cz + Dw // >= 0, othewise it is clipped from the scene. // For fixed function pipelines the plane equations are assumed // to be in world space and for programmable pipelines they are // assumed to be in clipping space, which is the same space as // the output vertices. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Index > maximum supported clipping // planes or the Plane array is too small for four floating // point values. // Params: pIndex - // The Index parameter specifies the index of the clipping plane // to be defined. // pPlane - // The Plane parameter references the clipping plane // coefficients, as 4 floating point array elements, in the form // of the general plane equation that will be set. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetClipPlane( dword pIndex, float* pPlane ) { // Original Function Definition // HRESULT SetClipPlane( // DWORD Index, // const float *pPlane // ); // 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 = (uint) fLPDIRECT3DDEVICE9->SetClipPlane( (DWORD) pIndex, (const float*) pPlane ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetClipPlane()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetClipStatus() // Description: The TDx9_3DDevice::SetClipStatus() method will set the clip // status. // // Clip status is used for software vertex processing so this // method will not work on hardware vertex processing devices. // Since TDx9_3DDevice::DrawRectPatch() and // TDx9_3DDevice::DrawTriPatch() are hardware only methods, clip // status will not be updated by those calls. // // When vertices are being processed a clip code is computed for // each one. The clip code is a combination of D3DCS_*** bits, // the relevant bit being set when the vertex falls outsite a // particular clipping plane. The clip status is maintained // using TD3DClipStatus->ClipUnion and // TD3DClipStatus->ClipIntersection, ClipUnion is initially 0 // and is a bitwise OR of all vertex clip codes and // ClipIntersection is initially 0xFFFFFFFF being a bitwise AND // of all vertex clip codes. Both are set to 0 if D3DRS_CLIPPING // is FALSE. The TD3DClipStatus is updated during drawing calls, // so to compute a particular objects clip status, initialize // ClipUnion and ClipIntersection and continue drawing. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if ClipStatus is invalid. // Params: pClipStatus - // The ClipStatus parameter references the TD3DClipStatus // component describing the clip status that is to be set. // -------------------------------------------------------------------------- HRESULT __fastcall TDx9_3DDevice::SetClipStatus( D3DCLIPSTATUS9* pClipStatus ) { // Original Function Definition // HRESULT SetClipStatus( // const D3DCLIPSTATUS9* pClipStatus // ); // 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 fErrorValue; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetClipStatus( (const D3DCLIPSTATUS9*) pClipStatus ); // Success! return fErrorValue; } // -------------------------------------------------------------------------- // Method: SetCurrentTexturePalette() // Description: The TDx9_3DDevice::SetCurrentTexturePalette() method will // define which texture palette the device should use. // // There is one logical texture palette per device that is // shared by all texture stages. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if PaletteNumber is an invalid pointer. // Params: pPaletteNumber - // The PaletteNumber parameter indicates which texture palette // should be set as the current one for this device. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetCurrentTexturePalette( uint pPaletteNumber ) { // Original Function Definition // HRESULT SetCurrentTexturePalette( // UINT PaletteNumber // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetCurrentTexturePalette()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetCurrentTexturePalette( (UINT) pPaletteNumber ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetCurrentTexturePalette()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetCursorPosition() // Description: The TDx9_3DDevice::SetCursorPosition() method will define the // current cursor position and update options. // // Full screen space coordinates are back buffer coordinates // scaled to the current display mode. Windowed screen space // coordinates are the desktop coordinates. // The cursor will be drawn at the specified position minus the // hotspot settings from TDx9_3DDevice::SetCursorProperties() // unless hidden by TDx9_3DDevice::ShowCursor(). // Params: pX - // The X parameter defines the cursors new x axis position in // virtual desktop coordinates. // pY - // The Y parameter defines the cursors new y axis position in // virtual desktop coordinates. // pFlags - // The Flags parameter indicates when the cursor should be // updated. // // Setting no flag indicates the cursor should be updated on the // next TDx9_3DDevice::Present() call. // This usually results in better performance so unless Present // calls are widely enough spaced for users to notice a delay in // cursor update, this is usually the best option. // Flags: // D3DCURSOR_IMMEDIATE_UPDATE - // Update the cursor at the refresh rate. // // The actual refresh rate is: rate/2 <= update >= rate. // This flag is meaningless for windowed mode applications // and hardware color cursors. // -------------------------------------------------------------------------- void __fastcall TDx9_3DDevice::SetCursorPosition( int pX, int pY, dword pFlags ) { // Original Function Definition // void SetCursorPosition( // INT X, // INT Y, // DWORD Flags // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetCursorPosition()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return; } // Call Original Function fLPDIRECT3DDEVICE9->SetCursorPosition( (INT) pX, (INT) pY, (DWORD) pFlags ); fErrorValue = 0; // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetCursorPosition()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return; } // Success! return; } // -------------------------------------------------------------------------- // Method: SetCursorProperties() // Description: The TDx9_3DDevice::SetCursorProperties() method can define // the image and hotspot for the cursor. // // An emulated cursor is used unless // TD3DCaps->CursorCaps->D3DCURSORCAPS_COLOR is set and the // cursor is 32x32 OR the application is in windowed mode, in // which case an operating system cursor is created and used. // Emulated cursors are moved with // TDx9_3DDevice::SetCursorPosition(). // // Generally its best if your application traps WM_MOUSEMOVE // events and calls the DXSetCursorPosition function. // // Hardware cursor support can be determined by checking // TD3DCaps->CursorCaps. Usually hardware and system cursors are // 32x32 only, so if you provide a different image size in this // call, the image and hotspot will be scaled to 32x32. // // Losing the device loses the cursor, so call this method again // after a TDx9_3DDevice::Reset(). // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pXHotSpot - // The XHotSpot parameter defines an X axis offset, in pixels, // marking the center of the cursor relative to the left side of // the cursor. // // The cusor image will be offset by subtracting this amount // from the position coordinate. // pYHotSpot - // The YHotSpot parameter defines an Y axis offset, in pixels, // marking the center of the cursor relative to the top side of // the cursor. // // The cusor image will be offset by subtracting this amount // from the position coordinate. // pCursorBitmap - // The CursorBitmap parameter references a TDx9_3DSurface // holding the cursor image to use. // // This must be a D3DFMT_A8R8G8B8 surface with alpa set to 0.0 // or 1.0, smaller than the display mode and with dimensions // that are powers of two, though not neccessarily equal. // The image will be copied to an internal buffer from which the // cursor is displayed. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetCursorProperties( uint pXHotSpot, uint pYHotSpot, TDx9_3DSurface* pCursorBitmap ) { // Original Function Definition // HRESULT SetCursorProperties( // UINT XHotSpot, // UINT YHotSpot, // LPDIRECT3DSURFACE9 pCursorBitmap // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetCursorProperties()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetCursorProperties( (UINT) pXHotSpot, (UINT) pYHotSpot, (pCursorBitmap==NULL) ? NULL : pCursorBitmap->Internal_LPDIRECT3DSURFACE9 ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetCursorProperties()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetDepthStencilSurface() // Description: The TDx9_3DDevice::SetSepthStencilSurface() method will set // the depth stencil surface for this device. // // The multisample type must match and the format be compatible // with that of the render target. The depth stencil surface // must be at least as large as the render target. // TDx9_3D::CheckDepthStencilMatch() can help check the formats // are compatible. // It is up to the application to enforce these requirements // unless the debug runtime is being used, in which case the // restrictions will be validated when Drawing calls are made. // // As cube textures represent a collection of surfaces, you must // retrieve individual face surfaces with // TDx9_3DCubeTexture::GetCubeMapSurface() then call this method // with the returned surface. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if NewZStencil is not NULL and references // an invalid surface. // Params: pZStencilSurface - // The ZStencilSurface parameter references the TDx9_3DSurface // that will represent the depth stencil buffer. // // Set NULL to disable the depth stencil operation. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetDepthStencilSurface( TDx9_3DSurface* pZStencilSurface ) { // Original Function Definition // HRESULT SetDepthStencilSurface( // LPDIRECT3DSURFACE9 pZStencilSurface // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetDepthStencilSurface()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetDepthStencilSurface( (pZStencilSurface==NULL) ? NULL : pZStencilSurface->Internal_LPDIRECT3DSURFACE9 ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetDepthStencilSurface()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetDialogBoxMode() // Description: The TDx9_3DDevice::SetDialogBoxMode() method will enable the // use of Graphics Device Interface (GDI) dialog boxes in full // screen applications. // // Create the dialog boxes from the same thread as created the // device, as child to the device window. // In windowed mode there will be no effect, but the specified // setting will be retained if the device is reset into full // screen mode, though when that occurs, the restrictions listed // below still apply. // All of the swap chains back buffers will be discarded and // need to be refreshed after this call. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL unless ALL of these conditions are met: // Not between TDx9_3DDevice::BeginScene and // TDx9_3DDevice::EndScene, GDI compatible back buffer format // (D3DFMT_X1R5G5B5, D3DFMT_R5G6B5 or D3DFMT_X8R8G8B8), no // multisampling, D3DSWAPEFFECT_DISCARD and // D3DPRESENTFLAG_LOCKABLE_BACKBUFFER are set and // D3DCREATE_ADAPTERGROUP_DEVICE is not set. // Params: pEnableDialogs - // The EnableDialogs parameter indicates whether GDI dialog // boxes should be enabled. // // Set TRUE to enable, FALSE to disable. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetDialogBoxMode( bool pEnableDialogs ) { // Original Function Definition // HRESULT SetDialogBoxMode( // BOOL bEnableDialogs // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetDialogBoxMode()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetDialogBoxMode( (BOOL) pEnableDialogs ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetDialogBoxMode()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetFVF() // Description: The TDx9_3DDevice::SetFVF() method will define the fixed // vertex function declaration. // // To set a fixed-function vertex shader, release any defined // programmable shader with a NULL call to // TDx9_3DDevice::SetVertexShader(), then call this method with // the fixed function vertex format. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if FVF is not a valid pointer. // Params: pFVF - // The FVF parameter defines the fixed vertex function type, as // values of the D3DFVF constant. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetFVF( dword pFVF ) { // Original Function Definition // HRESULT SetFVF( // DWORD FVF // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetFVF()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetFVF( (DWORD) pFVF ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetFVF()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetGammaRamp() // Description: The TDx9_3DDevice::SetGammaRamp() method will define the // gamma correction ramp for a specified swap chain. // // The gamma ramp will affect the whole screen even in windowed // mode and take immediate effect without waiting for a vertical // sync. // No error will be returned if gamma ramps are unsupported. // Check TD3DCaps->Caps2 for the D3DCAPS2_FULLSCREENGAMMA and // D3DCAPS2_CANCALIBRATEGAMMA capabilties. // TDx9_3DSwapChain::Present() can be used for windowed gamma // correction presentation if hardware support exists for the // feature. // Params: pSwapChain - // The SwapChain parameter specifies which swap chains gamma // correction ramp should be defined. // pFlags - // The Flags parameter indicates whether calibration should be // used. // // Gamma correction can result in more consistent display but // incurs some performance penalty. Short effects should not be // calibrated but longer duration gamma changes should be // calibrated. // Flags: // D3DSGR_CALIBRATE - // Modify the ramp to account for system and monitor // response curves before sending it to the device. // If no gamma calibrator is installed the ramp gets // passed directly to the device. // D3DSGR_NO_CALIBRATION - // Send the ramp directly to the device without // calibrating. // pRamp - // The Ramp parameter references a TD3DGammaRamp holding the // gamma correction ramp to be set for the specified swap chain. // -------------------------------------------------------------------------- void __fastcall TDx9_3DDevice::SetGammaRamp( uint pSwapChain, dword pFlags, D3DGAMMARAMP* pRamp ) { // Original Function Definition // void SetGammaRamp( // UINT iSwapChain, // DWORD Flags, // CONST D3DGAMMARAMP *pRamp // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetGammaRamp()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return; } // Call Original Function fLPDIRECT3DDEVICE9->SetGammaRamp( (UINT) pSwapChain, (DWORD) pFlags, (CONST D3DGAMMARAMP*) pRamp ); fErrorValue = 0; // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetGammaRamp()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return; } // Success! return; } // -------------------------------------------------------------------------- // Method: SetIndices() // Description: The TDx9_3DDevice::SetIndices() method will define the // current index array for this device. // // This set of indices will be used to index all steams. // When all references to the TDx9_3DIndexBuffer are released, // it is freed. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if IndexData is not a valid pointer or // there is no index. // Params: pIndexData - // The IndexData parameter references a TDx9_3DIndexBuffer // representing the index data to be set for this device. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetIndices( TDx9_3DIndexBuffer* pIndexData ) { // Original Function Definition // HRESULT SetIndices( // LPDIRECT3DINDEXBUFFER9 pIndexData // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetIndices()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetIndices( (pIndexData==NULL) ? NULL : pIndexData->Internal_LPDIRECT3DINDEXBUFFER9 ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetIndices()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetLight() // Description: The TDx9_3DDevice::SetLight() method will define the lighting // properties of a specified light for this device. // // Create and/or define the light source with this method and // then TDx9_3DDevice::LightEnable() can be used to activate // light sources in a scene. New lights are disabled by default. // TD3DCaps->MaxActiveLights defines how many lights can be // simultaneously enabled for the device. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pIndex - // The Index parameter specifies which light source properties // are to be defined. // // If lighting properties already exist at this index, they will // be overwritten with the new properties. // pLight - // The Light parameter references a TD3DLight holding the // lighting properties to be set for the specified light. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetLight( dword pIndex, D3DLIGHT9* pLight ) { // Original Function Definition // HRESULT SetLight( // DWORD Index, // CONST D3DLIGHT9 *pLight // ); // 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 = (uint) fLPDIRECT3DDEVICE9->SetLight( (DWORD) pIndex, (CONST D3DLIGHT9*) pLight ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetLight()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetMaterial() // Description: The TDx9_3DDevice::SetMaterial() method will define the // material properties for this device. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Material is not valid. // Params: pMaterial - // The Material parameter references a TD3DMaterial component // holding the material properties to be set. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetMaterial( D3DMATERIAL9* pMaterial ) { // Original Function Definition // HRESULT SetMaterial( // CONST D3DMATERIAL9 *pMaterial // ); // 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 = (uint) fLPDIRECT3DDEVICE9->SetMaterial( (CONST D3DMATERIAL9*) pMaterial ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetMaterial()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetNPatchMode() // Description: The TDx9_3DDevice::SetNPatchMode() method will define how // many subdivision segments to set for this device. // Params: pSegments - // The Segments parameter specifies the number of subdivision // segments. // // A value less than 1.0 indicates N patches are disabled. The // default value is 0.0. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetNPatchMode( float pSegments ) { // Original Function Definition // HRESULT SetNPatchMode( // float nSegments // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetNPatchMode()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetNPatchMode( pSegments ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetNPatchMode()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetPaletteEntries() // Description: The TDx9_3DDevice::SetPaletteEntries() method will define the // elements of a specified palette. // // There is one logical palette per device that is shared by all // stages. // If TD3DCaps->TextureCaps->3DPTEXTURECAPS_ALPHAPALETTE is not // set, every palette entry must have alpha set to 1.0, // otherwise any alpha value is allowed though the debug runtime // will warn if all palette entries have an alpha of 0. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided // Params: pPaletteNumber - // The PaletteNumber parameter specifies which palette to // define. // pEntries - // The Entries parameter references a TD3DPaletteEntry component // holding the palette entries to be set. // // There are assumed to be 256 palette entries in the // TD3DPaletteEntry component. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetPaletteEntries( uint pPaletteNumber, PALETTEENTRY* pEntries ) { // Original Function Definition // HRESULT SetPaletteEntries( // UINT PaletteNumber, // const PALETTEENTRY *pEntries // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetPaletteEntries()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetPaletteEntries( (UINT) pPaletteNumber, (const PALETTEENTRY*) pEntries ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetPaletteEntries()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetPixelShader() // Description: The TDx9_3DDevice::SetPixelShader() method will assign a // previously defined TDx9_3DPixelShader to this device. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Shader is invalid. // Params: pShader - // The Shader parameter references the TDx9_3DPixelShader to // assign to the device. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetPixelShader( TDx9_3DPixelShader* pShader ) { // Original Function Definition // HRESULT SetPixelShader( // LPDIRECT3DPIXELSHADER9 pShader // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetPixelShader()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetPixelShader( (pShader==NULL) ? NULL : pShader->Internal_LPDIRECT3DPIXELSHADER9 ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetPixelShader()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetPixelShaderConstantB() // Description: The TDx9_3DDevice::SetPixelShaderConstantB() method will // define boolean pixel shader constants. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStartRegister - // The StartRegister parameter specifies the register number of // the first boolean constant to define. // pConstantData - // The ConstantData parameter references an array holding the // boolean constants to be defined. // pBoolCount - // The BoolCount parameter indicates how many boolean values are // are in the ConstantData array. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetPixelShaderConstantB( uint pStartRegister, bool* pConstantData, uint pBoolCount ) { // Original Function Definition // HRESULT SetPixelShaderConstantB( // UINT StartRegister, // CONST BOOL *pConstantData, // UINT BoolCount // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetPixelShaderConstantB()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetPixelShaderConstantB( (UINT) pStartRegister, (CONST BOOL*) pConstantData, (UINT) pBoolCount ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetPixelShaderConstantB()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetPixelShaderConstantF() // Description: The TDx9_3DDevice::SetPixelShaderConstantF() method will // define floating point pixel shader constants. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStartRegister - // The StartRegister parameter specifies the register number of // the first floating point constant to define. // pConstantData - // The ConstantData parameter references an array holding the // floating point constants to be defined. // pVector4fCount - // The Vector4fCount parameter indicates how many four floating // point vectors are in the ConstantData array. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetPixelShaderConstantF( uint pStartRegister, float* pConstantData, uint pVector4fCount ) { // Original Function Definition // HRESULT SetPixelShaderConstantF( // UINT StartRegister, // CONST float *pConstantData, // UINT Vector4fCount // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetPixelShaderConstantF()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetPixelShaderConstantF( (UINT) pStartRegister, (CONST float*) pConstantData, (UINT) pVector4fCount ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetPixelShaderConstantF()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetPixelShaderConstantI() // Description: The TDx9_3DDevice::SetPixelShaderConstantI() method will // define integer pixel shader constants. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStartRegister - // The StartRegister parameter specifies the register number of // the first integer constant to define. // pConstantData - // The ConstantData parameter references an array holding the // integer constants to be defined. // pVector4iCount - // The Vector4fCount parameter indicates how many four integer // vectors are in the ConstantData array. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetPixelShaderConstantI( uint pStartRegister, int* pConstantData, uint pVector4iCount ) { // Original Function Definition // HRESULT SetPixelShaderConstantI( // UINT StartRegister, // CONST int *pConstantData, // UINT Vector4iCount // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetPixelShaderConstantI()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetPixelShaderConstantI( (UINT) pStartRegister, (CONST int*) pConstantData, (UINT) pVector4iCount ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetPixelShaderConstantI()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetRenderState() // Description: The TDx9_3DDevice::SetRenderState() method will define the // value of a specified render state type. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pState - // The State parameter specifies for which render state type, as // a value of the D3DRENDERSTATE enumerated type, the value // should be defined. // pValue - // The Value parameter specifies what value the specified render // state type should have. // // The meaning of this value depends on the State setting. // For example, if State was D3DRS_SHADEMODE then this value // should be a value of the D3DSHADEMODE enumerated type. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetRenderState( D3DRENDERSTATETYPE pState, dword pValue ) { // Original Function Definition // HRESULT SetRenderState( // D3DRENDERSTATETYPE State, // DWORD Value // ); // 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 = (uint) fLPDIRECT3DDEVICE9->SetRenderState( pState, (DWORD) pValue ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetRenderState()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetRenderTarget() // Description: The TDx9_3DDevice::SetRenderTarget() method will define the // specified render targets TDx9_3DSurface. // // Multiple render targets are now supported, to a maximum of // TD3DCaps->NumSumultaneousRTs. // In debug builds, some hardware tests depth stencil buffer / // render target compatibility. // // The multisample type must match and the format be compatible // with that of the depth stencil surface. The depth stencil // surface must be at least as large as the render target. // TDx9_3D::CheckDepthStencilMatch() can help check the formats // are compatible. // It is up to the application to enforce these requirements // unless the debug runtime is being used, in which case the // restrictions will be validated when Drawing calls are made. // // As cube textures represent a collection of surfaces, you must // retrieve individual face surfaces with // TDx9_3DCubeTexture::GetCubeMapSurface() then call this method // with the returned surface. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if RenderTargetIndex is 0 and RenderTarget // is NULL or the provided TDx9_3DSurface is invalid. // Params: pRenderTargetIndex - // The RenderTargetIndex parameter specifies the index of the // render target to define. // pRenderTarget - // The RenderTarget parameter references the TDx9_3DSurface to // be used as a render target. // // Set NULL to disable the specified RenderTargetIndex. // This TDx9_3DSurface must have at least D3DUSAGE_RENDERTARGET // set. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetRenderTarget( dword pRenderTargetIndex, TDx9_3DSurface* pRenderTarget ) { // Original Function Definition // HRESULT SetRenderTarget( // DWORD RenderTargetIndex, // LPDIRECT3DSURFACE9 pRenderTarget // ); // 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 = (uint) fLPDIRECT3DDEVICE9->SetRenderTarget( (DWORD) pRenderTargetIndex, (pRenderTarget==NULL) ? NULL : pRenderTarget->Internal_LPDIRECT3DSURFACE9 ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetRenderTarget()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetSamplerState() // Description: The TDx9_3DDevice::SetSamplerState() method will define the // sampler state value for a specified sampler stage. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pSampler - // The Sampler parameter specifies the index of the sampler // stage to define. // pType - // The Type parameter indicates the type of sampler state to // define, as a value of the D3DSAMPLERSTATETYPE enumerated // type. // pValue - // The Value parameter defines the sampler state value to be // set. // // The actual meaning of this value depends on the Type setting. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetSamplerState( dword pSampler, D3DSAMPLERSTATETYPE pType, dword pValue ) { // Original Function Definition // HRESULT SetSamplerState( // DWORD Sampler, // D3DSAMPLERSTATETYPE Type, // DWORD Value // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetSamplerState()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetSamplerState( (DWORD) pSampler, pType, (DWORD) pValue ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetSamplerState()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetScissorRect() // Description: The TDx9_3DDevice::SetScissorRect() method will define the // scissor rectangle used as a clipping region for this device // if scissor testing is enabled. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Rect is invalid. // Params: pRect - // The Rect parameter references the rectangle to set as the // scissor rectangle. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetScissorRect( TRect* pRect ) { // Original Function Definition // HRESULT SetScissorRect( // CONST RECT *pRect // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetScissorRect()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetScissorRect( (CONST RECT*) pRect ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetScissorRect()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetSoftwareVertexProcessing() // Description: The TDx9_3DDevice::SetSoftwareVertexProcessing() method will // switch between hardware and software vertex processing on a // mixed mode device. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL unless the device was created with // D3DCREATE_MIXED_VERTEXPROCESSING. // Params: pSoftware - // The Software parameter indicates whether software vertex // processing should be used. // // Set TRUE to enable software vertex processing, FALSE for // hardware vertex processing. // On creation of a mixed mode device, the default is FALSE. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetSoftwareVertexProcessing( bool pSoftware ) { // Original Function Definition // HRESULT SetSoftwareVertexProcessing( // BOOL bSoftware // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetSoftwareVertexProcessing()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetSoftwareVertexProcessing( (BOOL) pSoftware ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetSoftwareVertexProcessing()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetStreamSource() // Description: The TDx9_3DDevice::SetStreamSource() method will bind a // TDx9_3DVertexBuffer to a specified data stream. // // When all references to the TDx9_3DVertexBuffer are released, // it is freed. // Streams are uniform arrays of component data, with each // component consisting of one or more values representing // information such as position, normal or color. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStreamNumber - // The StreamNumber parameter specifies which stream's vertex // buffer is to be set. // // This must be a value between 0 and the number of streams - 1. // pStreamData - // The StreamData parameter references the TDx9_3DVertexBuffer // to be bound to the specified data stream. // pOffsetInBytes - // The OffsetInBytes parameter indicates the offset, in bytes, // from the start of the stream to the first vertex. // // If TD3DCaps->DevCaps2 has D3DDEVCAPS2_STREAMOFFSET set, // stream offsets are supported. // pStride - // The Stride parameter specifies the stride of the vertex // buffer. // // A flexible vertex format (FVF) vertex shader's vertex stream // Stride must match the vertex size as computed from the FVF. // If using a declaration, Stride should be >= than the stream // size computed from the declaration. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetStreamSource( uint pStreamNumber, TDx9_3DVertexBuffer* pStreamData, uint pOffsetInBytes, uint pStride ) { // Original Function Definition // HRESULT SetStreamSource( // UINT StreamNumber, // LPDIRECT3DVERTEXBUFFER9 pStreamData, // UINT OffsetInBytes, // UINT Stride // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetStreamSource()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetStreamSource( (UINT) pStreamNumber, (pStreamData==NULL) ? NULL : pStreamData->Internal_LPDIRECT3DVERTEXBUFFER9, (UINT) pOffsetInBytes, (UINT) pStride ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetStreamSource()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetStreamSourceFreq() // Description: The TDx9_3DDevice::SetStreamSourceFreq() method will define // the value of a specified steam source's frequency divider. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStreamNumber - // The StreamNumber parameter specifies which stream's frequency // divider number is to be defined. // // This must be a value between 0 and the number of streams - 1. // pDivider - // The Divider parameter defines the frequency divider value for // the specified stream. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetStreamSourceFreq( uint pStreamNumber, uint pDivider ) { // Original Function Definition // HRESULT SetStreamSourceFreq( // UINT StreamNumber, // UINT Divider // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetStreamSourceFreq()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetStreamSourceFreq( (UINT) pStreamNumber, (UINT) pDivider ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetStreamSourceFreq()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetTexture() // Description: The TDx9_3DDevice::SetTexture() method will bind a // TDx9_3DBaseTexture to the specified texture stage. // // D3DPOOL_SCRATCH textures cannot be used with this method and // D3DPOOL_SYSTEMMEM textures are only allowed if // TD3DCaps->DevCaps has D3DDEVCAPS_TEXTURESYSTEMMEMORY set. // // Textures are bound to samplers defining sample state such as // filtering mode and address wrapping mode. // Programmable shaders reference textures by sampler number and // the number accessible depends on the shader version. // Fixed function piplelines reference textures by texture // stage. // The maximum number of samplers is determined by the values of // TD3DCaps->MaxSimultaneousTextures and // TD3DCaps->MaxTextureBlendStages. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pSampler - // The Sampler parameter specifies to which sampler the texture // is to be bound. // // This is a zero based index. // There are two special case values possible in addition to the // normal values. // D3DDDMAPSAMPLER is used for displacement mapping. // D3DVERTEXTEXTURESAMPLER is used by a programmable vertex // shader when accessing vertex textures in vs_3_0. // pTexture - // The Texture parameter references the TDx9_3DBaseTexture to // bind to the specified sampler. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetTexture( dword pSampler, TDx9_3DBaseTexture* pTexture ) { // Original Function Definition // HRESULT SetTexture( // DWORD Stage, // LPDIRECT3DBASETEXTURE9 pTexture // ); // 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 = (uint) fLPDIRECT3DDEVICE9->SetTexture( (DWORD) pSampler, (pTexture==NULL) ? NULL : pTexture->Internal_LPDIRECT3DBASETEXTURE9 ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetTexture()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetTextureStageState() // Description: The TDx9_3DDevice::SetTextureStageState() method will define // the state value for a specified texture stage. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStage - // The Stage parameter specifies for which texture stage the // state value is to be defined. // // This will be a value between 0 and the number of texture // stages - 1. As a device may have a maximum of 8 set textures, // the maximum value here is 7. // pType - // The Type parameter indicates the type of texture state to // define, as a value of the D3DTEXTURESTAGESTATETYPE enumerated // type. // pValue - // The Value parameter defines the value to set for the // specified texture stage. // // The actual meaning of this value depends on the Type setting. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetTextureStageState( dword pStage, D3DTEXTURESTAGESTATETYPE pType, dword pValue ) { // Original Function Definition // HRESULT SetTextureStageState( // DWORD Stage, // D3DTEXTURESTAGESTATETYPE Type, // DWORD Value // ); // 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 = (uint) fLPDIRECT3DDEVICE9->SetTextureStageState( (DWORD) pStage, pType, (DWORD) pValue ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetTextureStageState()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetTransform() // Description: The TDx9_3DDevice::SetTransform() method will define the // matrix for a specified tranformation state. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pState - // The State parameter indicates the transform stage type to // define, as a value of the D3DTRANSFORMSTATETYPE enumerated // type or the D3DTS_WORLDMATRIX macro. // pMatrix - // The Matrix parameter references a TD3DMatrix component // holding the matrix to set for the specified transformation // stage type. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetTransform( D3DTRANSFORMSTATETYPE pState, D3DMATRIX* pMatrix ) { // Original Function Definition // HRESULT SetTransform( // D3DTRANSFORMSTATETYPE State, // CONST D3DMATRIX *pMatrix // ); // 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 = (uint) fLPDIRECT3DDEVICE9->SetTransform( pState, (CONST D3DMATRIX*) pMatrix ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetTransform()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetVertexDeclaration() // Description: The TDx9_3DDevice::SetVertexDeclaration() method will define // the vertex shader declaration for this device. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pDecl - // The Decl parameter references the TDx9_3DVertexDeclaration to // be set for this device. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetVertexDeclaration( TDx9_3DVertexDeclaration* pDecl ) { // Original Function Definition // HRESULT SetVertexDeclaration( // LPDIRECT3DVERTEXDECLARATION9 pDecl // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetVertexDeclaration()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetVertexDeclaration( (pDecl==NULL) ? NULL : pDecl->Internal_LPDIRECT3DVERTEXDECLARATION9 ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetVertexDeclaration()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetVertexShader() // Description: The TDx9_3DDevice::SetVertexShader() method will define the // TDx9_3DVertexShader for this device. // // To set a fixed-function vertex shader, release any defined // programmable shader with a NULL call to this method, then // call TDx9_3DDevice::SetFVF() with the fixed function vertex // format. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pShader - // The Shader parameter references the TDx9_3DVertexShader to // set for this device. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetVertexShader( TDx9_3DVertexShader* pShader ) { // Original Function Definition // HRESULT SetVertexShader( // LPDIRECT3DVERTEXSHADER9 pShader // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetVertexShader()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetVertexShader( (pShader==NULL) ? NULL : pShader->Internal_LPDIRECT3DVERTEXSHADER9 ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetVertexShader()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetVertexShaderConstantB() // Description: The TDx9_3DDevice::SetVertexShaderConstantB() method will // define boolean vertex shader constants. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStartRegister - // The StartRegister parameter specifies the register number of // the first boolean constant to define. // pConstantData - // The ConstantData parameter references an array holding the // boolean constants to be set. // pBoolCount - // The BoolCount parameter indicates how many boolean values are // are in the ConstantData array. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetVertexShaderConstantB( uint pStartRegister, bool* pConstantData, uint pBoolCount ) { // Original Function Definition // HRESULT SetVertexShaderConstantB( // UINT StartRegister, // CONST BOOL *pConstantData, // UINT BoolCount // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetVertexShaderConstantB()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetVertexShaderConstantB( (UINT) pStartRegister, (CONST BOOL*) pConstantData, (UINT) pBoolCount ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetVertexShaderConstantB()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetVertexShaderConstantF() // Description: The TDx9_3DDevice::SetVertexShaderConstantF() method will // define floating point vertex shader constants. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStartRegister - // The StartRegister parameter specifies the register number of // the first floating point constant to define. // pConstantData - // The ConstantData parameter references an array holding the // floating point constants to set. // pVector4fCount - // The Vector4fCount parameter indicates how many four floating // point vectors are in the ConstantData array. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetVertexShaderConstantF( uint pStartRegister, float* pConstantData, uint pVector4fCount ) { // Original Function Definition // HRESULT SetVertexShaderConstantF( // UINT StartRegister, // CONST float *pConstantData, // UINT Vector4fCount // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetVertexShaderConstantF()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetVertexShaderConstantF( (UINT) pStartRegister, (CONST float*) pConstantData, (UINT) pVector4fCount ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetVertexShaderConstantF()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetVertexShaderConstantI() // Description: The TDx9_3DDevice::SetVertexShaderConstantI() method will // define integer vertex shader constants. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pStartRegister - // The StartRegister parameter specifies the register number of // the first integer constant to define. // pConstantData - // The ConstantData parameter references an array holding the // integer constants to be set. // pVector4iCount - // The Vector4fCount parameter indicates how many four integer // vectors are in the ConstantData array. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetVertexShaderConstantI( uint pStartRegister, int* pConstantData, uint pVector4iCount ) { // Original Function Definition // HRESULT SetVertexShaderConstantI( // UINT StartRegister, // CONST int *pConstantData, // UINT Vector4iCount // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::SetVertexShaderConstantI()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->SetVertexShaderConstantI( (UINT) pStartRegister, (CONST int*) pConstantData, (UINT) pVector4iCount ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetVertexShaderConstantI()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: SetViewport() // Description: The TDx9_3DDevice::SetViewport() method will define the // viewport parameters for this device. // // You can use this method to draw on only part of the screen or // to draw multiple views within a scene by calling it multiple // times with different viewport settings. // Just make sure this call is made before any geometry is drawn // so the settings will take effect. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if Viewport is invalid or defines an // impossible render target region. // Params: pViewport - // The Viewport parameter references a TD3DViewport component // holding the viewport parameters to be set for this device. // // The default TD3DViewport property values are: // X = 0 // Y = 0 // Width = RenderTarget Width // Height = RenderTarget Height // MinZ = 0.0f // MaxZ = 1.0f // // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::SetViewport( D3DVIEWPORT9* pViewport ) { // Original Function Definition // HRESULT SetViewport( // CONST D3DVIEWPORT9 *pViewport // ); // 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 = (uint) fLPDIRECT3DDEVICE9->SetViewport( (CONST D3DVIEWPORT9*) pViewport ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::SetViewport()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: ShowCursor() // Description: The TDx9_3DDevice::ShowCursor() method will display or hide // the cursor. // // This method will return the previous cursor setting. // // Depending on hardware, Direct3D uses the Graphics Device // Interface (GDI) or software emulation for cursors. // Generally its best if your application traps WM_MOUSEMOVE // events and calls the DXSetCursorPosition function. // Params: pShow - // The Show parameter indicates whether the cursor should be // visible or not. // // Set TRUE for visible, FALSE for hidden. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::ShowCursor( bool pShow ) { // Original Function Definition // BOOL ShowCursor( // BOOL bShow // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::ShowCursor()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->ShowCursor( (BOOL) pShow ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::ShowCursor()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: StretchRect() // Description: The TDx9_3DDevice::StretchRect() method will make a stretched // and filtered copy from a source rectangle to a destination // rectangle. // // The surface and format combinations usable with this method // depend on a lot of factors including the surface type, driver // DirectX version and whether the call involves different // source and destination rectangle sizes. // // Both SourceSurface and DestSurface must be D3DPOOL_DEFAULT // and they must both reference different TDx9_3DSurface's. // Neither surface can be in a compressed format if stretching // or shrinking is required. // DestSurface cannot be a plain offscreen surface if // SourceSurface is not or stretching is required. // Filtering will fail unless TD3DCaps->StretchRectFilterCaps // indicates the specified filtering is available. Specifying // D3DTEXF_NONE means the driver will choose a filtering // algorithm. // Color space conversion can only be done from YUV to RGBA if // supported. TDx9_3D::CheckDeviceFormatConversion() can check // for color conversion support. There is no emulation for color // conversion. // // TDx9_3DDevice::StretchRect() calls on textures will only work // for DirectX 9 drivers that set // TD3DCaps->DevCaps2->D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES. // // TDx9_3DDevice::StretchRect() calls on depth and stencil // surfaces will only work if both SourceSurface and DestSurface // were created with TDx9_3DDevice::CreateDepthStencilSurface(), // have the same format, are the same size and the whole surface // is copied. The call cannot fall between a BeginScene/EndScene // pair, neither surface can be a mip level of a depth stencil // texture or created as discardable and // TD3DCaps->DevCaps2->D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES // must be set. // // When using this method to copy from one render target to // another, a multisampled SourceSurface can be downsampled to a // non multisampled DestSurface. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pSourceSurface - // The SourceSurface parameter references the TDx9_3DSurface // that is to be the source of the copy operation. // pSourceRect - // The SourceRect parameter defines a rectangle on the source // surface to be copied. // // Set NULL to specify the whole surface. // pDestSurface - // The DestSurface parameter references the TDx9_3DSurface that // is to be the destination of the copy operation. // pDestRect - // The DestRect parameter defines a rectangle on the destination // surface as the copy target. // // Set NULL to specify the whole surface. // pFilter - // The Filter parameter indicates which filter type to use, as a // value of the D3DTEXTUREFILTERTYPE. // // Valid values are D3DTEXF_NONE, D3DTEXF_POINT or // D3DTEXF_LINEAR. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::StretchRect( TDx9_3DSurface* pSourceSurface, TRect* pSourceRect, TDx9_3DSurface* pDestSurface, TRect* pDestRect, D3DTEXTUREFILTERTYPE pFilter ) { // Original Function Definition // HRESULT StretchRect( // LPDIRECT3DSURFACE9 pSourceSurface, // CONST RECT *pSourceRect, // LPDIRECT3DSURFACE9 pDestSurface, // CONST RECT *pDestRect, // D3DTEXTUREFILTERTYPE Filter // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::StretchRect()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->StretchRect( (pSourceSurface==NULL) ? NULL : pSourceSurface->Internal_LPDIRECT3DSURFACE9, (CONST RECT*) pSourceRect, (pDestSurface==NULL) ? NULL : pDestSurface->Internal_LPDIRECT3DSURFACE9, (CONST RECT*) pDestRect, pFilter ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::StretchRect()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: TestCooperativeLevel() // Description: The TDx9_3DDevice::TestCooperativeLevel() method will report // the device's coopertative level status. // // The call must be on the same thread that created the device. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_DEVICELOST if the device is lost but cannot be reset // at the moment. Call this method occasionally until // D3DERR_DEVICENOTRESET is returned. // D3DERR_DEVICENOTRESET if the device is lost but can be reset. // Try TDx9_Device::Reset(), if it works, restore resources and // resume normal operation. // D3DERR_DRIVERINTERNALERROR when there was an internal driver // error. Your application should probably shut down if this // error is returned. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::TestCooperativeLevel() { // Original Function Definition // HRESULT TestCooperativeLevel(); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::TestCooperativeLevel()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->TestCooperativeLevel( ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::TestCooperativeLevel()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: UpdateSurface() // Description: The TDx9_3DDevice::UpdateSurface() method will copy a // specified rectangle of pixels from one surface to another. // // SourceSurface must be D3DPOOL_SYSMEM, DestSurface must be // D3DPOOL_DEFAULT. // Neither surface can be locked, holding a DC or be a depth // stencil format. // Both surfaces must be D3DMULTISAMPLE_NONE and have the same // format. // SourceRect must fit within the source and destination // surfaces. // // A D3DPOOL_DEFAULT render target can be copied to a // D3DPOOL_SYSTEMMEM surface with // TDx9_3DDevice::GetRenderTargetData(). // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pSourceSurface - // The SourceSurface parameter references the TDx9_3DSurface // that is to be the source of the copy operation. // pSourceRect - // The SourceRect parameter defines a rectangle on the source // surface as the copy source. // // Set NULL to specify the whole surface. // pDestinationSurface - // The DestSurface parameter references the TDx9_3DSurface that // is to be the destination of the copy operation. // pDestinationPoint - // The DestinationPoint parameter specifies the upper left // corner of the destination rectangle. // // Set NULL to specify the whole surface. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::UpdateSurface( TDx9_3DSurface* pSourceSurface, TRect* pSourceRect, TDx9_3DSurface* pDestinationSurface, POINT* pDestinationPoint ) { // Original Function Definition // HRESULT UpdateSurface( // LPDIRECT3DSURFACE9 pSourceSurface, // CONST RECT* pSourceRect, // LPDIRECT3DSURFACE9 pDestinationSurface, // CONST POINT* pDestinationPoint // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::UpdateSurface()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->UpdateSurface( (pSourceSurface==NULL) ? NULL : pSourceSurface->Internal_LPDIRECT3DSURFACE9, (CONST RECT*) pSourceRect, (pDestinationSurface==NULL) ? NULL : pDestinationSurface->Internal_LPDIRECT3DSURFACE9, (CONST POINT*) pDestinationPoint ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::UpdateSurface()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: UpdateTexture() // Description: The TDx9_3DDevice::UpdateTexture() method will update the // dirty portions of a texture. // // Texture subsections can get marked as dirty when they are // locked or TDx9_3DCubeTexture::AddDirtyRect(), // TDx9_3DTexture::AddDirtyRect(), // TDx9_3DVolumeTexture::AddDirtyBox() or // TDx9_3DDevice::UpdateSurface() is called. If // D3DLOCK_NO_DIRTY_UPDATE or D3DLOCK_READONLY is set, then no // dirty region will be added. // Only the 0 texture level dirty regions are recorded, sub // level dirty regions are scaled appropriately from that. // This method calculates the dirty regions that have // accumulated since the last TDx9_3DDevice::UpdateTexture() // call and you can choose to only update those regions to the // destination texture to minimise the neccessary data transfer. // // The SourceTexture and DestinationTexture must be the same // type, have the same bottom level buffer size and matching // level sizes and have the same format. // SourceTexture must have at least as many levels as // DestinationTexture. Should DestinationTexture have fewer // levels, only the matching levels will be updated. // // If DestinationTexture is an autogenerated mipmap, only the // top level of SourceTexture will be updated. // DestinationTexture's sublevels will be regenerated from the // updated top level. SourceTexture can be autogenerated or not // in this case. // DestinationTexture must be autogenerated if SourceTexture is. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_INVALIDCALL if invalid parameters are provided. // Params: pSourceTexture - // The SourceTexture parameter references the TDx9_3DBaseTexture // that is the source of the update operation. // // This must be a D3DPOOL_SYSTEMMEM texture. // pDestinationTexture - // The DestinationTexture parameter references the // TDx9_3DBaseTexture that is the destination of the update // operation. // // This must be a D3DPOOL_DEFAULT texture. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::UpdateTexture( TDx9_3DBaseTexture* pSourceTexture, TDx9_3DBaseTexture* pDestinationTexture ) { // Original Function Definition // HRESULT UpdateTexture( // LPDIRECT3DBASETEXTURE9 pSourceTexture, // LPDIRECT3DBASETEXTURE9 pDestinationTexture // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::UpdateTexture()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPDIRECT3DDEVICE9->UpdateTexture( (pSourceTexture==NULL) ? NULL : pSourceTexture->Internal_LPDIRECT3DBASETEXTURE9, (pDestinationTexture==NULL) ? NULL : pDestinationTexture->Internal_LPDIRECT3DBASETEXTURE9 ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::UpdateTexture()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: ValidateDevice() // Description: The TDx9_3DDevice::ValidateDevice() method will analyse the // device's capability to render the current texture blending // operations and arguments in a single pass. // // Primarily used when other ways of finding out are deficient. // Most capabilities can be determined by checking the // appropriate TD3DCaps properties. For example, // TD3DCaps->MaxTextureBlendStages and // TD3DCaps->MaxSimultaneousTextures can be used to tell if // multistage texturing is possible. // Ideally you should only use this method at initialization // time, never as part of a rendering loop. // // Since the hardware will not neccessarily implement all // possible operation/argument combinations, you can set up your // desired settings then make this call to see if will work // properly. // As this call uses the current settings, changing those // settings will invalidate the previous result. // // It is better if the texture (D3DTA_TEXTURE) is specified as // the first argument for a stage rather than the second. // // Most hardware doesn't support diffuse iterated values as an // argument or operation. For example, // D3DTA_DIFFUSED3DTOP_BLENDDIFFUSEALPHA is rarely supported so // far. In most cases the hardware can only introduce iterated // color data at the last texture operation stage. // Many cards don't support diffuse or scalar values at any // stage but the first or last stage. // Many cards have a limited blending unit associated with the // first texture that can only replicate alpha to color channels // or invert the input. For this reason you may need to only use // the second texture stage if you can. In the case of this // limitation, the first unit assumes a default state of // D3DTA_TEXTURE color argument and D3DTOP_SELECTARG1 operation. // Output alpha operations that are intricate or substantially // different relative to the color operations are less likely to // be supported. // Sometimes the simultaneous use of D3DTA_TFACTOR and // D3DTA_DIFFUSE is not supported. // Many cards will not support simultaneous mipmapped trilinear // filtering and multi texture blending. Try revalidating with // trilinear off. Multipass rendering may be the best solution // if this is the case. // // If the method call fails, the OnError event will be triggered // with one of the following values: // D3DERR_CONFLICTINGRENDERSTATE for incompatible render states. // D3DERR_CONFLICTINGTEXTUREFILTER for incompatible texture // filters. // D3DERR_DEVICELOST if the device is lost and cannot be reset // right now. // D3DERR_DRIVERINTERNALERROR when there was an internal driver // error. Your application should probably shut down if this // error is returned. // D3DERR_TOOMANYOPERATIONS if more texture filtering operations // are requested than are supported. // D3DERR_UNSUPPORTEDALPHAARG if the alpha channel texture // blending argument is unsupported. // D3DERR_UNSUPPORTEDALPHAOPERATION if the alpha channel texture // blending operation is unsupported. // D3DERR_UNSUPPORTEDCOLORARG when the color value texture // blending argument is unsupported. // D3DERR_UNSUPPORTEDCOLOROPERATION when the color value texture // blending operation is unsupported. // D3DERR_UNSUPPORTEDFACTORVALUE when the texture factor value // is unsupported. // D3DERR_UNSUPPORTEDTEXTUREFILTER when the texture filter is // unsupported. // D3DERR_WRONGTEXTUREFORMAT if the texture surface's pixel // format is invalid. // Params: pNumPasses - // The NumPasses parameter will reference a value indicating how // many rendering passes the current settings would take using // multipass rendering. // -------------------------------------------------------------------------- bool __fastcall TDx9_3DDevice::ValidateDevice( dword* pNumPasses ) { // Original Function Definition // HRESULT ValidateDevice( // DWORD *pNumPasses // ); // 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 = (uint) fLPDIRECT3DDEVICE9->ValidateDevice( (DWORD*) pNumPasses ); // Handle any Known Results if (fErrorValue!=D3D_OK) { // Failure. if (FOnError) FOnError( this, Name+"::ValidateDevice()", TDx9_Graphics_Library_ErrorString(fErrorValue), TDx9_Graphics_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Internal Interface Access // -------------------------------------------------------------------------- LPDIRECT3DDEVICE9 __fastcall TDx9_3DDevice::FGetInternal_LPDIRECT3DDEVICE9() { return fLPDIRECT3DDEVICE9; } // -------------------------------------------------------------------------- LPDIRECT3DDEVICE9* __fastcall TDx9_3DDevice::FGetInternal_LPDIRECT3DDEVICE9_Ptr() { return &fLPDIRECT3DDEVICE9; } // -------------------------------------------------------------------------- void __fastcall TDx9_3DDevice::FSetInternal_LPDIRECT3DDEVICE9( LPDIRECT3DDEVICE9 pLPDIRECT3DDEVICE9 ) { if (!fCreated) { fLPDIRECT3DDEVICE9 = pLPDIRECT3DDEVICE9; fCreated = (fLPDIRECT3DDEVICE9!=NULL); } } // -------------------------------------------------------------------------- void __fastcall TDx9_3DDevice::Internal_LPDIRECT3DDEVICE9_Update() { fCreated = (fLPDIRECT3DDEVICE9!=NULL); } // --------------------------------------------------------------------------