// -------------------------------------------------------------------------- // ========================================================================== // 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(