diff --git a/src/Components/Modules/D3D9Ex.cpp b/src/Components/Modules/D3D9Ex.cpp index c32d8714..7fbb6f09 100644 --- a/src/Components/Modules/D3D9Ex.cpp +++ b/src/Components/Modules/D3D9Ex.cpp @@ -2,22 +2,630 @@ namespace Components { +#pragma region D3D9Device - myIDirect3DDevice9::myIDirect3DDevice9(IDirect3DDevice9* pOriginal) + HRESULT D3D9Ex::D3D9Device::QueryInterface(REFIID riid, void** ppvObj) { - m_pIDirect3DDevice9 = pOriginal; // store the pointer to original object - } - - myIDirect3DDevice9::~myIDirect3DDevice9(void) - { - } - - HRESULT myIDirect3DDevice9::QueryInterface(REFIID riid, void** ppvObj) - { - // check if original dll can provide interface. then send *our* address *ppvObj = NULL; HRESULT hRes = m_pIDirect3DDevice9->QueryInterface(riid, ppvObj); + if (hRes == NOERROR) *ppvObj = this; + return hRes; + } + + ULONG D3D9Ex::D3D9Device::AddRef(void) + { + return m_pIDirect3DDevice9->AddRef(); + } + + ULONG D3D9Ex::D3D9Device::Release(void) + { + ULONG count = m_pIDirect3DDevice9->Release(); + if (!count) delete this; + return count; + } + + HRESULT D3D9Ex::D3D9Device::TestCooperativeLevel(void) + { + return m_pIDirect3DDevice9->TestCooperativeLevel(); + } + + UINT D3D9Ex::D3D9Device::GetAvailableTextureMem(void) + { + return m_pIDirect3DDevice9->GetAvailableTextureMem(); + } + + HRESULT D3D9Ex::D3D9Device::EvictManagedResources(void) + { + return m_pIDirect3DDevice9->EvictManagedResources(); + } + + HRESULT D3D9Ex::D3D9Device::GetDirect3D(IDirect3D9** ppD3D9) + { + return m_pIDirect3DDevice9->GetDirect3D(ppD3D9); + } + + HRESULT D3D9Ex::D3D9Device::GetDeviceCaps(D3DCAPS9* pCaps) + { + return m_pIDirect3DDevice9->GetDeviceCaps(pCaps); + } + + HRESULT D3D9Ex::D3D9Device::GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode) + { + return m_pIDirect3DDevice9->GetDisplayMode(iSwapChain, pMode); + } + + HRESULT D3D9Ex::D3D9Device::GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters) + { + return m_pIDirect3DDevice9->GetCreationParameters(pParameters); + } + + HRESULT D3D9Ex::D3D9Device::SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) + { + return m_pIDirect3DDevice9->SetCursorProperties(XHotSpot, YHotSpot, pCursorBitmap); + } + + void D3D9Ex::D3D9Device::SetCursorPosition(int X, int Y, DWORD Flags) + { + return m_pIDirect3DDevice9->SetCursorPosition(X, Y, Flags); + } + + BOOL D3D9Ex::D3D9Device::ShowCursor(BOOL bShow) + { + return m_pIDirect3DDevice9->ShowCursor(bShow); + } + + HRESULT D3D9Ex::D3D9Device::CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain) + { + return m_pIDirect3DDevice9->CreateAdditionalSwapChain(pPresentationParameters, pSwapChain); + } + + HRESULT D3D9Ex::D3D9Device::GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) + { + return m_pIDirect3DDevice9->GetSwapChain(iSwapChain, pSwapChain); + } + + UINT D3D9Ex::D3D9Device::GetNumberOfSwapChains(void) + { + return m_pIDirect3DDevice9->GetNumberOfSwapChains(); + } + + HRESULT D3D9Ex::D3D9Device::Reset(D3DPRESENT_PARAMETERS* pPresentationParameters) + { + return m_pIDirect3DDevice9->Reset(pPresentationParameters); + } + + HRESULT D3D9Ex::D3D9Device::Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion) + { + return m_pIDirect3DDevice9->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); + } + + HRESULT D3D9Ex::D3D9Device::GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) + { + return m_pIDirect3DDevice9->GetBackBuffer(iSwapChain, iBackBuffer, Type, ppBackBuffer); + } + + HRESULT D3D9Ex::D3D9Device::GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) + { + return m_pIDirect3DDevice9->GetRasterStatus(iSwapChain, pRasterStatus); + } + + HRESULT D3D9Ex::D3D9Device::SetDialogBoxMode(BOOL bEnableDialogs) + { + return m_pIDirect3DDevice9->SetDialogBoxMode(bEnableDialogs); + } + + void D3D9Ex::D3D9Device::SetGammaRamp(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) + { + return m_pIDirect3DDevice9->SetGammaRamp(iSwapChain, Flags, pRamp); + } + + void D3D9Ex::D3D9Device::GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp) + { + return m_pIDirect3DDevice9->GetGammaRamp(iSwapChain, pRamp); + } + + HRESULT D3D9Ex::D3D9Device::CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) + { + if (Pool == D3DPOOL_MANAGED) { Pool = D3DPOOL_DEFAULT; Usage |= D3DUSAGE_DYNAMIC; } + + return m_pIDirect3DDevice9->CreateTexture(Width, Height, Levels, Usage, Format, Pool, ppTexture, pSharedHandle); + } + + HRESULT D3D9Ex::D3D9Device::CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) + { + if (Pool == D3DPOOL_MANAGED) { Pool = D3DPOOL_DEFAULT; Usage |= D3DUSAGE_DYNAMIC; } + + return m_pIDirect3DDevice9->CreateVolumeTexture(Width, Height, Depth, Levels, Usage, Format, Pool, ppVolumeTexture, pSharedHandle); + } + + HRESULT D3D9Ex::D3D9Device::CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) + { + if (Pool == D3DPOOL_MANAGED) { Pool = D3DPOOL_DEFAULT; Usage |= D3DUSAGE_DYNAMIC; } + + return m_pIDirect3DDevice9->CreateCubeTexture(EdgeLength, Levels, Usage, Format, Pool, ppCubeTexture, pSharedHandle); + } + + HRESULT D3D9Ex::D3D9Device::CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) + { + if (Pool == D3DPOOL_MANAGED) { Pool = D3DPOOL_DEFAULT; Usage |= D3DUSAGE_DYNAMIC; } + + return m_pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle); + } + + HRESULT D3D9Ex::D3D9Device::CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) + { + if (Pool == D3DPOOL_MANAGED) { Pool = D3DPOOL_DEFAULT; Usage |= D3DUSAGE_DYNAMIC; } + + return m_pIDirect3DDevice9->CreateIndexBuffer(Length, Usage, Format, Pool, ppIndexBuffer, pSharedHandle); + } + + HRESULT D3D9Ex::D3D9Device::CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) + { + return m_pIDirect3DDevice9->CreateRenderTarget(Width, Height, Format, MultiSample, MultisampleQuality, Lockable, ppSurface, pSharedHandle); + } + + HRESULT D3D9Ex::D3D9Device::CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) + { + return m_pIDirect3DDevice9->CreateDepthStencilSurface(Width, Height, Format, MultiSample, MultisampleQuality, Discard, ppSurface, pSharedHandle); + } + + HRESULT D3D9Ex::D3D9Device::UpdateSurface(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) + { + return m_pIDirect3DDevice9->UpdateSurface(pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint); + } + + HRESULT D3D9Ex::D3D9Device::UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) + { + return m_pIDirect3DDevice9->UpdateTexture(pSourceTexture, pDestinationTexture); + } + + HRESULT D3D9Ex::D3D9Device::GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) + { + return m_pIDirect3DDevice9->GetRenderTargetData(pRenderTarget, pDestSurface); + } + + HRESULT D3D9Ex::D3D9Device::GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface) + { + return m_pIDirect3DDevice9->GetFrontBufferData(iSwapChain, pDestSurface); + } + + HRESULT D3D9Ex::D3D9Device::StretchRect(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) + { + return m_pIDirect3DDevice9->StretchRect(pSourceSurface, pSourceRect, pDestSurface, pDestRect, Filter); + } + + HRESULT D3D9Ex::D3D9Device::ColorFill(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) + { + return m_pIDirect3DDevice9->ColorFill(pSurface, pRect, color); + } + + HRESULT D3D9Ex::D3D9Device::CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) + { + if (Pool == D3DPOOL_MANAGED) { Pool = D3DPOOL_DEFAULT; } + + return m_pIDirect3DDevice9->CreateOffscreenPlainSurface(Width, Height, Format, Pool, ppSurface, pSharedHandle); + } + + HRESULT D3D9Ex::D3D9Device::SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) + { + return m_pIDirect3DDevice9->SetRenderTarget(RenderTargetIndex, pRenderTarget); + } + + HRESULT D3D9Ex::D3D9Device::GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) + { + return m_pIDirect3DDevice9->GetRenderTarget(RenderTargetIndex, ppRenderTarget); + } + + HRESULT D3D9Ex::D3D9Device::SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil) + { + return m_pIDirect3DDevice9->SetDepthStencilSurface(pNewZStencil); + } + + HRESULT D3D9Ex::D3D9Device::GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface) + { + return m_pIDirect3DDevice9->GetDepthStencilSurface(ppZStencilSurface); + } + + HRESULT D3D9Ex::D3D9Device::BeginScene(void) + { + return m_pIDirect3DDevice9->BeginScene(); + } + + HRESULT D3D9Ex::D3D9Device::EndScene(void) + { + return m_pIDirect3DDevice9->EndScene(); + } + + HRESULT D3D9Ex::D3D9Device::Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) + { + return m_pIDirect3DDevice9->Clear(Count, pRects, Flags, Color, Z, Stencil); + } + + HRESULT D3D9Ex::D3D9Device::SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) + { + return m_pIDirect3DDevice9->SetTransform(State, pMatrix); + } + + HRESULT D3D9Ex::D3D9Device::GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) + { + return m_pIDirect3DDevice9->GetTransform(State, pMatrix); + } + + HRESULT D3D9Ex::D3D9Device::MultiplyTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) + { + return m_pIDirect3DDevice9->MultiplyTransform(State, pMatrix); + } + + HRESULT D3D9Ex::D3D9Device::SetViewport(CONST D3DVIEWPORT9* pViewport) + { + return m_pIDirect3DDevice9->SetViewport(pViewport); + } + + HRESULT D3D9Ex::D3D9Device::GetViewport(D3DVIEWPORT9* pViewport) + { + return m_pIDirect3DDevice9->GetViewport(pViewport); + } + + HRESULT D3D9Ex::D3D9Device::SetMaterial(CONST D3DMATERIAL9* pMaterial) + { + return m_pIDirect3DDevice9->SetMaterial(pMaterial); + } + + HRESULT D3D9Ex::D3D9Device::GetMaterial(D3DMATERIAL9* pMaterial) + { + return m_pIDirect3DDevice9->GetMaterial(pMaterial); + } + + HRESULT D3D9Ex::D3D9Device::SetLight(DWORD Index, CONST D3DLIGHT9* pLight) + { + return m_pIDirect3DDevice9->SetLight(Index, pLight); + } + + HRESULT D3D9Ex::D3D9Device::GetLight(DWORD Index, D3DLIGHT9* pLight) + { + return m_pIDirect3DDevice9->GetLight(Index, pLight); + } + + HRESULT D3D9Ex::D3D9Device::LightEnable(DWORD Index, BOOL Enable) + { + return m_pIDirect3DDevice9->LightEnable(Index, Enable); + } + + HRESULT D3D9Ex::D3D9Device::GetLightEnable(DWORD Index, BOOL* pEnable) + { + return m_pIDirect3DDevice9->GetLightEnable(Index, pEnable); + } + + HRESULT D3D9Ex::D3D9Device::SetClipPlane(DWORD Index, CONST float* pPlane) + { + return m_pIDirect3DDevice9->SetClipPlane(Index, pPlane); + } + + HRESULT D3D9Ex::D3D9Device::GetClipPlane(DWORD Index, float* pPlane) + { + return m_pIDirect3DDevice9->GetClipPlane(Index, pPlane); + } + + HRESULT D3D9Ex::D3D9Device::SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) + { + return m_pIDirect3DDevice9->SetRenderState(State, Value); + } + + HRESULT D3D9Ex::D3D9Device::GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue) + { + return m_pIDirect3DDevice9->GetRenderState(State, pValue); + } + + HRESULT D3D9Ex::D3D9Device::CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB) + { + return m_pIDirect3DDevice9->CreateStateBlock(Type, ppSB); + } + + HRESULT D3D9Ex::D3D9Device::BeginStateBlock(void) + { + return m_pIDirect3DDevice9->BeginStateBlock(); + } + + HRESULT D3D9Ex::D3D9Device::EndStateBlock(IDirect3DStateBlock9** ppSB) + { + return m_pIDirect3DDevice9->EndStateBlock(ppSB); + } + + HRESULT D3D9Ex::D3D9Device::SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus) + { + return m_pIDirect3DDevice9->SetClipStatus(pClipStatus); + } + + HRESULT D3D9Ex::D3D9Device::GetClipStatus(D3DCLIPSTATUS9* pClipStatus) + { + return m_pIDirect3DDevice9->GetClipStatus(pClipStatus); + } + + HRESULT D3D9Ex::D3D9Device::GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture) + { + return m_pIDirect3DDevice9->GetTexture(Stage, ppTexture); + } + + HRESULT D3D9Ex::D3D9Device::SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture) + { + return m_pIDirect3DDevice9->SetTexture(Stage, pTexture); + } + + HRESULT D3D9Ex::D3D9Device::GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) + { + return m_pIDirect3DDevice9->GetTextureStageState(Stage, Type, pValue); + } + + HRESULT D3D9Ex::D3D9Device::SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) + { + return m_pIDirect3DDevice9->SetTextureStageState(Stage, Type, Value); + } + + HRESULT D3D9Ex::D3D9Device::GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) + { + return m_pIDirect3DDevice9->GetSamplerState(Sampler, Type, pValue); + } + + HRESULT D3D9Ex::D3D9Device::SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) + { + return m_pIDirect3DDevice9->SetSamplerState(Sampler, Type, Value); + } + + HRESULT D3D9Ex::D3D9Device::ValidateDevice(DWORD* pNumPasses) + { + return m_pIDirect3DDevice9->ValidateDevice(pNumPasses); + } + + HRESULT D3D9Ex::D3D9Device::SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY* pEntries) + { + return m_pIDirect3DDevice9->SetPaletteEntries(PaletteNumber, pEntries); + } + + HRESULT D3D9Ex::D3D9Device::GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries) + { + return m_pIDirect3DDevice9->GetPaletteEntries(PaletteNumber, pEntries); + } + + HRESULT D3D9Ex::D3D9Device::SetCurrentTexturePalette(UINT PaletteNumber) + { + return m_pIDirect3DDevice9->SetCurrentTexturePalette(PaletteNumber); + } + + HRESULT D3D9Ex::D3D9Device::GetCurrentTexturePalette(UINT *PaletteNumber) + { + return m_pIDirect3DDevice9->GetCurrentTexturePalette(PaletteNumber); + } + + HRESULT D3D9Ex::D3D9Device::SetScissorRect(CONST RECT* pRect) + { + return m_pIDirect3DDevice9->SetScissorRect(pRect); + } + + HRESULT D3D9Ex::D3D9Device::GetScissorRect(RECT* pRect) + { + return m_pIDirect3DDevice9->GetScissorRect(pRect); + } + + HRESULT D3D9Ex::D3D9Device::SetSoftwareVertexProcessing(BOOL bSoftware) + { + return m_pIDirect3DDevice9->SetSoftwareVertexProcessing(bSoftware); + } + + BOOL D3D9Ex::D3D9Device::GetSoftwareVertexProcessing(void) + { + return m_pIDirect3DDevice9->GetSoftwareVertexProcessing(); + } + + HRESULT D3D9Ex::D3D9Device::SetNPatchMode(float nSegments) + { + return m_pIDirect3DDevice9->SetNPatchMode(nSegments); + } + + float D3D9Ex::D3D9Device::GetNPatchMode(void) + { + return m_pIDirect3DDevice9->GetNPatchMode(); + } + + HRESULT D3D9Ex::D3D9Device::DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) + { + return m_pIDirect3DDevice9->DrawPrimitive(PrimitiveType, StartVertex, PrimitiveCount); + } + + HRESULT D3D9Ex::D3D9Device::DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) + { + return m_pIDirect3DDevice9->DrawIndexedPrimitive(PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); + } + + HRESULT D3D9Ex::D3D9Device::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) + { + return m_pIDirect3DDevice9->DrawPrimitiveUP(PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride); + } + + HRESULT D3D9Ex::D3D9Device::DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) + { + return m_pIDirect3DDevice9->DrawIndexedPrimitiveUP(PrimitiveType, MinVertexIndex, NumVertices, PrimitiveCount, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride); + } + + HRESULT D3D9Ex::D3D9Device::ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) + { + return m_pIDirect3DDevice9->ProcessVertices(SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags); + } + + HRESULT D3D9Ex::D3D9Device::CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) + { + return m_pIDirect3DDevice9->CreateVertexDeclaration(pVertexElements, ppDecl); + } + + HRESULT D3D9Ex::D3D9Device::SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl) + { + return m_pIDirect3DDevice9->SetVertexDeclaration(pDecl); + } + + HRESULT D3D9Ex::D3D9Device::GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl) + { + return m_pIDirect3DDevice9->GetVertexDeclaration(ppDecl); + } + + HRESULT D3D9Ex::D3D9Device::SetFVF(DWORD FVF) + { + return m_pIDirect3DDevice9->SetFVF(FVF); + } + + HRESULT D3D9Ex::D3D9Device::GetFVF(DWORD* pFVF) + { + return m_pIDirect3DDevice9->GetFVF(pFVF); + } + + HRESULT D3D9Ex::D3D9Device::CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) + { + return m_pIDirect3DDevice9->CreateVertexShader(pFunction, ppShader); + } + + HRESULT D3D9Ex::D3D9Device::SetVertexShader(IDirect3DVertexShader9* pShader) + { + return m_pIDirect3DDevice9->SetVertexShader(pShader); + } + + HRESULT D3D9Ex::D3D9Device::GetVertexShader(IDirect3DVertexShader9** ppShader) + { + return m_pIDirect3DDevice9->GetVertexShader(ppShader); + } + + HRESULT D3D9Ex::D3D9Device::SetVertexShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) + { + return m_pIDirect3DDevice9->SetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount); + } + + HRESULT D3D9Ex::D3D9Device::GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) + { + return m_pIDirect3DDevice9->GetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount); + } + + HRESULT D3D9Ex::D3D9Device::SetVertexShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) + { + return m_pIDirect3DDevice9->SetVertexShaderConstantI(StartRegister, pConstantData, Vector4iCount); + } + + HRESULT D3D9Ex::D3D9Device::GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) + { + return m_pIDirect3DDevice9->GetVertexShaderConstantI(StartRegister, pConstantData, Vector4iCount); + } + + HRESULT D3D9Ex::D3D9Device::SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) + { + return m_pIDirect3DDevice9->SetVertexShaderConstantB(StartRegister, pConstantData, BoolCount); + } + + HRESULT D3D9Ex::D3D9Device::GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) + { + return m_pIDirect3DDevice9->GetVertexShaderConstantB(StartRegister, pConstantData, BoolCount); + } + + HRESULT D3D9Ex::D3D9Device::SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) + { + return m_pIDirect3DDevice9->SetStreamSource(StreamNumber, pStreamData, OffsetInBytes, Stride); + } + + HRESULT D3D9Ex::D3D9Device::GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride) + { + return m_pIDirect3DDevice9->GetStreamSource(StreamNumber, ppStreamData, OffsetInBytes, pStride); + } + + HRESULT D3D9Ex::D3D9Device::SetStreamSourceFreq(UINT StreamNumber, UINT Divider) + { + return m_pIDirect3DDevice9->SetStreamSourceFreq(StreamNumber, Divider); + } + + HRESULT D3D9Ex::D3D9Device::GetStreamSourceFreq(UINT StreamNumber, UINT* Divider) + { + return m_pIDirect3DDevice9->GetStreamSourceFreq(StreamNumber, Divider); + } + + HRESULT D3D9Ex::D3D9Device::SetIndices(IDirect3DIndexBuffer9* pIndexData) + { + return m_pIDirect3DDevice9->SetIndices(pIndexData); + } + + HRESULT D3D9Ex::D3D9Device::GetIndices(IDirect3DIndexBuffer9** ppIndexData) + { + return m_pIDirect3DDevice9->GetIndices(ppIndexData); + } + + HRESULT D3D9Ex::D3D9Device::CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) + { + return m_pIDirect3DDevice9->CreatePixelShader(pFunction, ppShader); + } + + HRESULT D3D9Ex::D3D9Device::SetPixelShader(IDirect3DPixelShader9* pShader) + { + return m_pIDirect3DDevice9->SetPixelShader(pShader); + } + + HRESULT D3D9Ex::D3D9Device::GetPixelShader(IDirect3DPixelShader9** ppShader) + { + return m_pIDirect3DDevice9->GetPixelShader(ppShader); + } + + HRESULT D3D9Ex::D3D9Device::SetPixelShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) + { + return m_pIDirect3DDevice9->SetPixelShaderConstantF(StartRegister, pConstantData, Vector4fCount); + } + + HRESULT D3D9Ex::D3D9Device::GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) + { + return m_pIDirect3DDevice9->GetPixelShaderConstantF(StartRegister, pConstantData, Vector4fCount); + } + + HRESULT D3D9Ex::D3D9Device::SetPixelShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) + { + return m_pIDirect3DDevice9->SetPixelShaderConstantI(StartRegister, pConstantData, Vector4iCount); + } + + HRESULT D3D9Ex::D3D9Device::GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) + { + return m_pIDirect3DDevice9->GetPixelShaderConstantI(StartRegister, pConstantData, Vector4iCount); + } + + HRESULT D3D9Ex::D3D9Device::SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) + { + return m_pIDirect3DDevice9->SetPixelShaderConstantB(StartRegister, pConstantData, BoolCount); + } + + HRESULT D3D9Ex::D3D9Device::GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) + { + return m_pIDirect3DDevice9->GetPixelShaderConstantB(StartRegister, pConstantData, BoolCount); + } + + HRESULT D3D9Ex::D3D9Device::DrawRectPatch(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) + { + return m_pIDirect3DDevice9->DrawRectPatch(Handle, pNumSegs, pRectPatchInfo); + } + + HRESULT D3D9Ex::D3D9Device::DrawTriPatch(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) + { + return m_pIDirect3DDevice9->DrawTriPatch(Handle, pNumSegs, pTriPatchInfo); + } + + HRESULT D3D9Ex::D3D9Device::DeletePatch(UINT Handle) + { + return m_pIDirect3DDevice9->DeletePatch(Handle); + } + + HRESULT D3D9Ex::D3D9Device::CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) + { + return m_pIDirect3DDevice9->CreateQuery(Type, ppQuery); + } + +#pragma endregion + +#pragma region D3D9 + + HRESULT __stdcall D3D9Ex::D3D9::QueryInterface(REFIID riid, void** ppvObj) + { + *ppvObj = NULL; + + HRESULT hRes = m_pIDirect3D9->QueryInterface(riid, ppvObj); if (hRes == NOERROR) { @@ -27,773 +635,99 @@ namespace Components return hRes; } - ULONG myIDirect3DDevice9::AddRef(void) + ULONG __stdcall D3D9Ex::D3D9::AddRef(void) { - return(m_pIDirect3DDevice9->AddRef()); + return m_pIDirect3D9->AddRef(); } - ULONG myIDirect3DDevice9::Release(void) + ULONG __stdcall D3D9Ex::D3D9::Release(void) { - // ATTENTION: This is a booby-trap ! Watch out ! - // If we create our own sprites, surfaces, etc. (thus increasing the ref counter - // by external action), we need to delete that objects before calling the original - // Release function - - // release/delete own objects - // ..... - - // Calling original function now - ULONG count = m_pIDirect3DDevice9->Release(); - - // now, the Original Object has deleted itself, so do we here - delete(this); // destructor will be called automatically - - return (count); - } - - HRESULT myIDirect3DDevice9::TestCooperativeLevel(void) - { - return(m_pIDirect3DDevice9->TestCooperativeLevel()); - } - - UINT myIDirect3DDevice9::GetAvailableTextureMem(void) - { - return(m_pIDirect3DDevice9->GetAvailableTextureMem()); - } - - HRESULT myIDirect3DDevice9::EvictManagedResources(void) - { - return(m_pIDirect3DDevice9->EvictManagedResources()); - } - - HRESULT myIDirect3DDevice9::GetDirect3D(IDirect3D9** ppD3D9) - { - return(m_pIDirect3DDevice9->GetDirect3D(ppD3D9)); - } - - HRESULT myIDirect3DDevice9::GetDeviceCaps(D3DCAPS9* pCaps) - { - return(m_pIDirect3DDevice9->GetDeviceCaps(pCaps)); - } - - HRESULT myIDirect3DDevice9::GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode) - { - return(m_pIDirect3DDevice9->GetDisplayMode(iSwapChain, pMode)); - } - - HRESULT myIDirect3DDevice9::GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters) - { - return(m_pIDirect3DDevice9->GetCreationParameters(pParameters)); - } - - HRESULT myIDirect3DDevice9::SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) - { - return(m_pIDirect3DDevice9->SetCursorProperties(XHotSpot, YHotSpot, pCursorBitmap)); - } - - void myIDirect3DDevice9::SetCursorPosition(int X, int Y, DWORD Flags) - { - return(m_pIDirect3DDevice9->SetCursorPosition(X, Y, Flags)); - } - - BOOL myIDirect3DDevice9::ShowCursor(BOOL bShow) - { - return(m_pIDirect3DDevice9->ShowCursor(bShow)); - } - - HRESULT myIDirect3DDevice9::CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain) - { - return(m_pIDirect3DDevice9->CreateAdditionalSwapChain(pPresentationParameters, pSwapChain)); - } - - HRESULT myIDirect3DDevice9::GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) - { - return(m_pIDirect3DDevice9->GetSwapChain(iSwapChain, pSwapChain)); - } - - UINT myIDirect3DDevice9::GetNumberOfSwapChains(void) - { - return(m_pIDirect3DDevice9->GetNumberOfSwapChains()); - } - - HRESULT myIDirect3DDevice9::Reset(D3DPRESENT_PARAMETERS* pPresentationParameters) - { - return m_pIDirect3DDevice9->Reset(pPresentationParameters); - } - - HRESULT myIDirect3DDevice9::Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion) - { - return m_pIDirect3DDevice9->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); - } - - HRESULT myIDirect3DDevice9::GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) - { - return(m_pIDirect3DDevice9->GetBackBuffer(iSwapChain, iBackBuffer, Type, ppBackBuffer)); - } - - HRESULT myIDirect3DDevice9::GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) - { - return(m_pIDirect3DDevice9->GetRasterStatus(iSwapChain, pRasterStatus)); - } - - HRESULT myIDirect3DDevice9::SetDialogBoxMode(BOOL bEnableDialogs) - { - return(m_pIDirect3DDevice9->SetDialogBoxMode(bEnableDialogs)); - } - - void myIDirect3DDevice9::SetGammaRamp(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) - { - return(m_pIDirect3DDevice9->SetGammaRamp(iSwapChain, Flags, pRamp)); - } - - void myIDirect3DDevice9::GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp) - { - return(m_pIDirect3DDevice9->GetGammaRamp(iSwapChain, pRamp)); - } - - HRESULT myIDirect3DDevice9::CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) - { - if (Pool == D3DPOOL_MANAGED) { Pool = D3DPOOL_DEFAULT; Usage |= D3DUSAGE_DYNAMIC; } - - return(m_pIDirect3DDevice9->CreateTexture(Width, Height, Levels, Usage, Format, Pool, ppTexture, pSharedHandle)); - } - - HRESULT myIDirect3DDevice9::CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) - { - if (Pool == D3DPOOL_MANAGED) { Pool = D3DPOOL_DEFAULT; Usage |= D3DUSAGE_DYNAMIC; } - - return(m_pIDirect3DDevice9->CreateVolumeTexture(Width, Height, Depth, Levels, Usage, Format, Pool, ppVolumeTexture, pSharedHandle)); - } - - HRESULT myIDirect3DDevice9::CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) - { - if (Pool == D3DPOOL_MANAGED) { Pool = D3DPOOL_DEFAULT; Usage |= D3DUSAGE_DYNAMIC; } - - return(m_pIDirect3DDevice9->CreateCubeTexture(EdgeLength, Levels, Usage, Format, Pool, ppCubeTexture, pSharedHandle)); - } - - HRESULT myIDirect3DDevice9::CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) - { - if (Pool == D3DPOOL_MANAGED) { Pool = D3DPOOL_DEFAULT; Usage |= D3DUSAGE_DYNAMIC; } - - return(m_pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle)); - } - - HRESULT myIDirect3DDevice9::CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) - { - if (Pool == D3DPOOL_MANAGED) { Pool = D3DPOOL_DEFAULT; Usage |= D3DUSAGE_DYNAMIC; } - - return(m_pIDirect3DDevice9->CreateIndexBuffer(Length, Usage, Format, Pool, ppIndexBuffer, pSharedHandle)); - } - - HRESULT myIDirect3DDevice9::CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) - { - return(m_pIDirect3DDevice9->CreateRenderTarget(Width, Height, Format, MultiSample, MultisampleQuality, Lockable, ppSurface, pSharedHandle)); - } - - HRESULT myIDirect3DDevice9::CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) - { - return(m_pIDirect3DDevice9->CreateDepthStencilSurface(Width, Height, Format, MultiSample, MultisampleQuality, Discard, ppSurface, pSharedHandle)); - } - - HRESULT myIDirect3DDevice9::UpdateSurface(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) - { - return(m_pIDirect3DDevice9->UpdateSurface(pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint)); - } - - HRESULT myIDirect3DDevice9::UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) - { - return(m_pIDirect3DDevice9->UpdateTexture(pSourceTexture, pDestinationTexture)); - } - - HRESULT myIDirect3DDevice9::GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) - { - return(m_pIDirect3DDevice9->GetRenderTargetData(pRenderTarget, pDestSurface)); - } - - HRESULT myIDirect3DDevice9::GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface) - { - return(m_pIDirect3DDevice9->GetFrontBufferData(iSwapChain, pDestSurface)); - } - - HRESULT myIDirect3DDevice9::StretchRect(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) - { - return(m_pIDirect3DDevice9->StretchRect(pSourceSurface, pSourceRect, pDestSurface, pDestRect, Filter)); - } - - HRESULT myIDirect3DDevice9::ColorFill(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) - { - return(m_pIDirect3DDevice9->ColorFill(pSurface, pRect, color)); - } - - HRESULT myIDirect3DDevice9::CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) - { - if (Pool == D3DPOOL_MANAGED) { Pool = D3DPOOL_DEFAULT; } - - return(m_pIDirect3DDevice9->CreateOffscreenPlainSurface(Width, Height, Format, Pool, ppSurface, pSharedHandle)); - } - - HRESULT myIDirect3DDevice9::SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) - { - return m_pIDirect3DDevice9->SetRenderTarget(RenderTargetIndex, pRenderTarget); - } - - HRESULT myIDirect3DDevice9::GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) - { - return(m_pIDirect3DDevice9->GetRenderTarget(RenderTargetIndex, ppRenderTarget)); - } - - HRESULT myIDirect3DDevice9::SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil) - { - return(m_pIDirect3DDevice9->SetDepthStencilSurface(pNewZStencil)); - } - - HRESULT myIDirect3DDevice9::GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface) - { - return(m_pIDirect3DDevice9->GetDepthStencilSurface(ppZStencilSurface)); - } - - HRESULT myIDirect3DDevice9::BeginScene(void) - { - return m_pIDirect3DDevice9->BeginScene(); - } - - HRESULT myIDirect3DDevice9::EndScene(void) - { - return m_pIDirect3DDevice9->EndScene(); - } - - HRESULT myIDirect3DDevice9::Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) - { - return(m_pIDirect3DDevice9->Clear(Count, pRects, Flags, Color, Z, Stencil)); - } - - HRESULT myIDirect3DDevice9::SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) - { - return(m_pIDirect3DDevice9->SetTransform(State, pMatrix)); - } - - HRESULT myIDirect3DDevice9::GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) - { - return(m_pIDirect3DDevice9->GetTransform(State, pMatrix)); - } - - HRESULT myIDirect3DDevice9::MultiplyTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) - { - return(m_pIDirect3DDevice9->MultiplyTransform(State, pMatrix)); - } - - HRESULT myIDirect3DDevice9::SetViewport(CONST D3DVIEWPORT9* pViewport) - { - return(m_pIDirect3DDevice9->SetViewport(pViewport)); - } - - HRESULT myIDirect3DDevice9::GetViewport(D3DVIEWPORT9* pViewport) - { - return(m_pIDirect3DDevice9->GetViewport(pViewport)); - } - - HRESULT myIDirect3DDevice9::SetMaterial(CONST D3DMATERIAL9* pMaterial) - { - return(m_pIDirect3DDevice9->SetMaterial(pMaterial)); - } - - HRESULT myIDirect3DDevice9::GetMaterial(D3DMATERIAL9* pMaterial) - { - return(m_pIDirect3DDevice9->GetMaterial(pMaterial)); - } - - HRESULT myIDirect3DDevice9::SetLight(DWORD Index, CONST D3DLIGHT9* pLight) - { - return(m_pIDirect3DDevice9->SetLight(Index, pLight)); - } - - HRESULT myIDirect3DDevice9::GetLight(DWORD Index, D3DLIGHT9* pLight) - { - return(m_pIDirect3DDevice9->GetLight(Index, pLight)); - } - - HRESULT myIDirect3DDevice9::LightEnable(DWORD Index, BOOL Enable) - { - return(m_pIDirect3DDevice9->LightEnable(Index, Enable)); - } - - HRESULT myIDirect3DDevice9::GetLightEnable(DWORD Index, BOOL* pEnable) - { - return(m_pIDirect3DDevice9->GetLightEnable(Index, pEnable)); - } - - HRESULT myIDirect3DDevice9::SetClipPlane(DWORD Index, CONST float* pPlane) - { - return(m_pIDirect3DDevice9->SetClipPlane(Index, pPlane)); - } - - HRESULT myIDirect3DDevice9::GetClipPlane(DWORD Index, float* pPlane) - { - return(m_pIDirect3DDevice9->GetClipPlane(Index, pPlane)); - } - - HRESULT myIDirect3DDevice9::SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) - { - return(m_pIDirect3DDevice9->SetRenderState(State, Value)); - } - - HRESULT myIDirect3DDevice9::GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue) - { - return(m_pIDirect3DDevice9->GetRenderState(State, pValue)); - } - - HRESULT myIDirect3DDevice9::CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB) - { - return(m_pIDirect3DDevice9->CreateStateBlock(Type, ppSB)); - } - - HRESULT myIDirect3DDevice9::BeginStateBlock(void) - { - return(m_pIDirect3DDevice9->BeginStateBlock()); - } - - HRESULT myIDirect3DDevice9::EndStateBlock(IDirect3DStateBlock9** ppSB) - { - return(m_pIDirect3DDevice9->EndStateBlock(ppSB)); - } - - HRESULT myIDirect3DDevice9::SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus) - { - return(m_pIDirect3DDevice9->SetClipStatus(pClipStatus)); - } - - HRESULT myIDirect3DDevice9::GetClipStatus(D3DCLIPSTATUS9* pClipStatus) - { - return(m_pIDirect3DDevice9->GetClipStatus(pClipStatus)); - } - - HRESULT myIDirect3DDevice9::GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture) - { - return(m_pIDirect3DDevice9->GetTexture(Stage, ppTexture)); - } - - HRESULT myIDirect3DDevice9::SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture) - { - return(m_pIDirect3DDevice9->SetTexture(Stage, pTexture)); - } - - HRESULT myIDirect3DDevice9::GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) - { - return(m_pIDirect3DDevice9->GetTextureStageState(Stage, Type, pValue)); - } - - HRESULT myIDirect3DDevice9::SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) - { - return(m_pIDirect3DDevice9->SetTextureStageState(Stage, Type, Value)); - } - - HRESULT myIDirect3DDevice9::GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) - { - return(m_pIDirect3DDevice9->GetSamplerState(Sampler, Type, pValue)); - } - - HRESULT myIDirect3DDevice9::SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) - { - return(m_pIDirect3DDevice9->SetSamplerState(Sampler, Type, Value)); - } - - HRESULT myIDirect3DDevice9::ValidateDevice(DWORD* pNumPasses) - { - return(m_pIDirect3DDevice9->ValidateDevice(pNumPasses)); - } - - HRESULT myIDirect3DDevice9::SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY* pEntries) - { - return(m_pIDirect3DDevice9->SetPaletteEntries(PaletteNumber, pEntries)); - } - - HRESULT myIDirect3DDevice9::GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries) - { - return(m_pIDirect3DDevice9->GetPaletteEntries(PaletteNumber, pEntries)); - } - - HRESULT myIDirect3DDevice9::SetCurrentTexturePalette(UINT PaletteNumber) - { - return(m_pIDirect3DDevice9->SetCurrentTexturePalette(PaletteNumber)); - } - - HRESULT myIDirect3DDevice9::GetCurrentTexturePalette(UINT *PaletteNumber) - { - return(m_pIDirect3DDevice9->GetCurrentTexturePalette(PaletteNumber)); - } - - HRESULT myIDirect3DDevice9::SetScissorRect(CONST RECT* pRect) - { - return(m_pIDirect3DDevice9->SetScissorRect(pRect)); - } - - HRESULT myIDirect3DDevice9::GetScissorRect(RECT* pRect) - { - return(m_pIDirect3DDevice9->GetScissorRect(pRect)); - } - - HRESULT myIDirect3DDevice9::SetSoftwareVertexProcessing(BOOL bSoftware) - { - return(m_pIDirect3DDevice9->SetSoftwareVertexProcessing(bSoftware)); - } - - BOOL myIDirect3DDevice9::GetSoftwareVertexProcessing(void) - { - return(m_pIDirect3DDevice9->GetSoftwareVertexProcessing()); - } - - HRESULT myIDirect3DDevice9::SetNPatchMode(float nSegments) - { - return(m_pIDirect3DDevice9->SetNPatchMode(nSegments)); - } - - float myIDirect3DDevice9::GetNPatchMode(void) - { - return(m_pIDirect3DDevice9->GetNPatchMode()); - } - - HRESULT myIDirect3DDevice9::DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) - { - return(m_pIDirect3DDevice9->DrawPrimitive(PrimitiveType, StartVertex, PrimitiveCount)); - } - - HRESULT myIDirect3DDevice9::DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) - { - return(m_pIDirect3DDevice9->DrawIndexedPrimitive(PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount)); - } - - HRESULT myIDirect3DDevice9::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) - { - return(m_pIDirect3DDevice9->DrawPrimitiveUP(PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride)); - } - - HRESULT myIDirect3DDevice9::DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) - { - return(m_pIDirect3DDevice9->DrawIndexedPrimitiveUP(PrimitiveType, MinVertexIndex, NumVertices, PrimitiveCount, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride)); - } - - HRESULT myIDirect3DDevice9::ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) - { - return(m_pIDirect3DDevice9->ProcessVertices(SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags)); - } - - HRESULT myIDirect3DDevice9::CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) - { - return(m_pIDirect3DDevice9->CreateVertexDeclaration(pVertexElements, ppDecl)); - } - - HRESULT myIDirect3DDevice9::SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl) - { - return(m_pIDirect3DDevice9->SetVertexDeclaration(pDecl)); - } - - HRESULT myIDirect3DDevice9::GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl) - { - return(m_pIDirect3DDevice9->GetVertexDeclaration(ppDecl)); - } - - HRESULT myIDirect3DDevice9::SetFVF(DWORD FVF) - { - return(m_pIDirect3DDevice9->SetFVF(FVF)); - } - - HRESULT myIDirect3DDevice9::GetFVF(DWORD* pFVF) - { - return(m_pIDirect3DDevice9->GetFVF(pFVF)); - } - - HRESULT myIDirect3DDevice9::CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) - { - return(m_pIDirect3DDevice9->CreateVertexShader(pFunction, ppShader)); - } - - HRESULT myIDirect3DDevice9::SetVertexShader(IDirect3DVertexShader9* pShader) - { - return(m_pIDirect3DDevice9->SetVertexShader(pShader)); - } - - HRESULT myIDirect3DDevice9::GetVertexShader(IDirect3DVertexShader9** ppShader) - { - return(m_pIDirect3DDevice9->GetVertexShader(ppShader)); - } - - HRESULT myIDirect3DDevice9::SetVertexShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) - { - return(m_pIDirect3DDevice9->SetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount)); - } - - HRESULT myIDirect3DDevice9::GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) - { - return(m_pIDirect3DDevice9->GetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount)); - } - - HRESULT myIDirect3DDevice9::SetVertexShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) - { - return(m_pIDirect3DDevice9->SetVertexShaderConstantI(StartRegister, pConstantData, Vector4iCount)); - } - - HRESULT myIDirect3DDevice9::GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) - { - return(m_pIDirect3DDevice9->GetVertexShaderConstantI(StartRegister, pConstantData, Vector4iCount)); - } - - HRESULT myIDirect3DDevice9::SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) - { - return(m_pIDirect3DDevice9->SetVertexShaderConstantB(StartRegister, pConstantData, BoolCount)); - } - - HRESULT myIDirect3DDevice9::GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) - { - return(m_pIDirect3DDevice9->GetVertexShaderConstantB(StartRegister, pConstantData, BoolCount)); - } - - HRESULT myIDirect3DDevice9::SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) - { - return(m_pIDirect3DDevice9->SetStreamSource(StreamNumber, pStreamData, OffsetInBytes, Stride)); - } - - HRESULT myIDirect3DDevice9::GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride) - { - return(m_pIDirect3DDevice9->GetStreamSource(StreamNumber, ppStreamData, OffsetInBytes, pStride)); - } - - HRESULT myIDirect3DDevice9::SetStreamSourceFreq(UINT StreamNumber, UINT Divider) - { - return(m_pIDirect3DDevice9->SetStreamSourceFreq(StreamNumber, Divider)); - } - - HRESULT myIDirect3DDevice9::GetStreamSourceFreq(UINT StreamNumber, UINT* Divider) - { - return(m_pIDirect3DDevice9->GetStreamSourceFreq(StreamNumber, Divider)); - } - - HRESULT myIDirect3DDevice9::SetIndices(IDirect3DIndexBuffer9* pIndexData) - { - return(m_pIDirect3DDevice9->SetIndices(pIndexData)); - } - - HRESULT myIDirect3DDevice9::GetIndices(IDirect3DIndexBuffer9** ppIndexData) - { - return(m_pIDirect3DDevice9->GetIndices(ppIndexData)); - } - - HRESULT myIDirect3DDevice9::CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) - { - return(m_pIDirect3DDevice9->CreatePixelShader(pFunction, ppShader)); - } - - HRESULT myIDirect3DDevice9::SetPixelShader(IDirect3DPixelShader9* pShader) - { - return(m_pIDirect3DDevice9->SetPixelShader(pShader)); - } - - HRESULT myIDirect3DDevice9::GetPixelShader(IDirect3DPixelShader9** ppShader) - { - return(m_pIDirect3DDevice9->GetPixelShader(ppShader)); - } - - HRESULT myIDirect3DDevice9::SetPixelShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount) - { - return(m_pIDirect3DDevice9->SetPixelShaderConstantF(StartRegister, pConstantData, Vector4fCount)); - } - - HRESULT myIDirect3DDevice9::GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount) - { - return(m_pIDirect3DDevice9->GetPixelShaderConstantF(StartRegister, pConstantData, Vector4fCount)); - } - - HRESULT myIDirect3DDevice9::SetPixelShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount) - { - return(m_pIDirect3DDevice9->SetPixelShaderConstantI(StartRegister, pConstantData, Vector4iCount)); - } - - HRESULT myIDirect3DDevice9::GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount) - { - return(m_pIDirect3DDevice9->GetPixelShaderConstantI(StartRegister, pConstantData, Vector4iCount)); - } - - HRESULT myIDirect3DDevice9::SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount) - { - return(m_pIDirect3DDevice9->SetPixelShaderConstantB(StartRegister, pConstantData, BoolCount)); - } - - HRESULT myIDirect3DDevice9::GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount) - { - return(m_pIDirect3DDevice9->GetPixelShaderConstantB(StartRegister, pConstantData, BoolCount)); - } - - HRESULT myIDirect3DDevice9::DrawRectPatch(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) - { - return(m_pIDirect3DDevice9->DrawRectPatch(Handle, pNumSegs, pRectPatchInfo)); - } - - HRESULT myIDirect3DDevice9::DrawTriPatch(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) - { - return(m_pIDirect3DDevice9->DrawTriPatch(Handle, pNumSegs, pTriPatchInfo)); - } - - HRESULT myIDirect3DDevice9::DeletePatch(UINT Handle) - { - return(m_pIDirect3DDevice9->DeletePatch(Handle)); - } - - HRESULT myIDirect3DDevice9::CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) - { - return(m_pIDirect3DDevice9->CreateQuery(Type, ppQuery)); - } - - - - - - - - - - - - - - - - - - myIDirect3D9::myIDirect3D9(IDirect3D9Ex *pOriginal) - { - m_pIDirect3D9 = pOriginal; - } - - myIDirect3D9::~myIDirect3D9(void) - { - } - - HRESULT __stdcall myIDirect3D9::QueryInterface(REFIID riid, void** ppvObj) - { - *ppvObj = NULL; - - // call this to increase AddRef at original object - // and to check if such an interface is there - - HRESULT hRes = m_pIDirect3D9->QueryInterface(riid, ppvObj); - - if (hRes == NOERROR) // if OK, send our "fake" address - { - *ppvObj = this; - } - - return hRes; - } - - ULONG __stdcall myIDirect3D9::AddRef(void) - { - return(m_pIDirect3D9->AddRef()); - } - - ULONG __stdcall myIDirect3D9::Release(void) - { - // call original routine ULONG count = m_pIDirect3D9->Release(); - - // in case no further Ref is there, the Original Object has deleted itself - // so do we here - if (count == 0) - { - delete(this); - } - - return(count); + if (!count) delete this; + return count; } - HRESULT __stdcall myIDirect3D9::RegisterSoftwareDevice(void* pInitializeFunction) + HRESULT __stdcall D3D9Ex::D3D9::RegisterSoftwareDevice(void* pInitializeFunction) { - return(m_pIDirect3D9->RegisterSoftwareDevice(pInitializeFunction)); + return m_pIDirect3D9->RegisterSoftwareDevice(pInitializeFunction); } - UINT __stdcall myIDirect3D9::GetAdapterCount(void) + UINT __stdcall D3D9Ex::D3D9::GetAdapterCount(void) { - return(m_pIDirect3D9->GetAdapterCount()); + return m_pIDirect3D9->GetAdapterCount(); } - HRESULT __stdcall myIDirect3D9::GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) + HRESULT __stdcall D3D9Ex::D3D9::GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) { - return(m_pIDirect3D9->GetAdapterIdentifier(Adapter, Flags, pIdentifier)); + return m_pIDirect3D9->GetAdapterIdentifier(Adapter, Flags, pIdentifier); } - UINT __stdcall myIDirect3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) + UINT __stdcall D3D9Ex::D3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) { - return(m_pIDirect3D9->GetAdapterModeCount(Adapter, Format)); + return m_pIDirect3D9->GetAdapterModeCount(Adapter, Format); } - HRESULT __stdcall myIDirect3D9::EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) + HRESULT __stdcall D3D9Ex::D3D9::EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) { - return(m_pIDirect3D9->EnumAdapterModes(Adapter, Format, Mode, pMode)); + return m_pIDirect3D9->EnumAdapterModes(Adapter, Format, Mode, pMode); } - HRESULT __stdcall myIDirect3D9::GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) + HRESULT __stdcall D3D9Ex::D3D9::GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) { - return(m_pIDirect3D9->GetAdapterDisplayMode(Adapter, pMode)); + return m_pIDirect3D9->GetAdapterDisplayMode(Adapter, pMode); } - HRESULT __stdcall myIDirect3D9::CheckDeviceType(UINT iAdapter, D3DDEVTYPE DevType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed) + HRESULT __stdcall D3D9Ex::D3D9::CheckDeviceType(UINT iAdapter, D3DDEVTYPE DevType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed) { - return(m_pIDirect3D9->CheckDeviceType(iAdapter, DevType, DisplayFormat, BackBufferFormat, bWindowed)); + return m_pIDirect3D9->CheckDeviceType(iAdapter, DevType, DisplayFormat, BackBufferFormat, bWindowed); } - HRESULT __stdcall myIDirect3D9::CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) + HRESULT __stdcall D3D9Ex::D3D9::CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) { - return(m_pIDirect3D9->CheckDeviceFormat(Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat)); + return m_pIDirect3D9->CheckDeviceFormat(Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat); } - HRESULT __stdcall myIDirect3D9::CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) + HRESULT __stdcall D3D9Ex::D3D9::CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) { - return(m_pIDirect3D9->CheckDeviceMultiSampleType(Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels)); + return m_pIDirect3D9->CheckDeviceMultiSampleType(Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels); } - HRESULT __stdcall myIDirect3D9::CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) + HRESULT __stdcall D3D9Ex::D3D9::CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) { - return(m_pIDirect3D9->CheckDepthStencilMatch(Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat)); + return m_pIDirect3D9->CheckDepthStencilMatch(Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat); } - HRESULT __stdcall myIDirect3D9::CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) + HRESULT __stdcall D3D9Ex::D3D9::CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) { - return(m_pIDirect3D9->CheckDeviceFormatConversion(Adapter, DeviceType, SourceFormat, TargetFormat)); + return m_pIDirect3D9->CheckDeviceFormatConversion(Adapter, DeviceType, SourceFormat, TargetFormat); } - HRESULT __stdcall myIDirect3D9::GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) + HRESULT __stdcall D3D9Ex::D3D9::GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) { - return(m_pIDirect3D9->GetDeviceCaps(Adapter, DeviceType, pCaps)); + return m_pIDirect3D9->GetDeviceCaps(Adapter, DeviceType, pCaps); } - HMONITOR __stdcall myIDirect3D9::GetAdapterMonitor(UINT Adapter) + HMONITOR __stdcall D3D9Ex::D3D9::GetAdapterMonitor(UINT Adapter) { - return(m_pIDirect3D9->GetAdapterMonitor(Adapter)); + return m_pIDirect3D9->GetAdapterMonitor(Adapter); } - HRESULT __stdcall myIDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) + HRESULT __stdcall D3D9Ex::D3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) { - // global var - // we intercept this call and provide our own "fake" Device Object - IDirect3DDevice9* device; - HRESULT hres = m_pIDirect3D9->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, &device); - - // - // Create our own Device object and store it in global pointer - // note: the object will delete itself once Ref count is zero (similar to COM objects) - - // store our pointer (the fake one) for returning it to the calling progam - *ppReturnedDeviceInterface = new myIDirect3DDevice9(device); - - return(hres); + HRESULT hres = m_pIDirect3D9->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface); + *ppReturnedDeviceInterface = (new D3D9Ex::D3D9Device(*ppReturnedDeviceInterface)); + return hres; } +#pragma endregion + IDirect3D9* __stdcall D3D9Ex::Direct3DCreate9Stub(UINT sdk) { if (Dvar::Var("r_useD3D9Ex").Get()) { IDirect3D9Ex* test; Direct3DCreate9Ex(sdk, &test); - return new myIDirect3D9(test); + return (new D3D9Ex::D3D9(test)); } else { @@ -803,13 +737,9 @@ namespace Components D3D9Ex::D3D9Ex() { - Dvar::Register("r_useD3D9Ex", true, Game::dvar_flag::DVAR_FLAG_SAVED/* | Game::dvar_flag::DVAR_FLAG_LATCHED*/, "Use extended d3d9 interface!"); + Dvar::Register("r_useD3D9Ex", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Use extended d3d9 interface!"); + // Hook Interface creation Utils::Hook::Set(0x6D74D0, D3D9Ex::Direct3DCreate9Stub); } - - D3D9Ex::~D3D9Ex() - { - - } } diff --git a/src/Components/Modules/D3D9Ex.hpp b/src/Components/Modules/D3D9Ex.hpp index 2c63beca..8e8bd7a4 100644 --- a/src/Components/Modules/D3D9Ex.hpp +++ b/src/Components/Modules/D3D9Ex.hpp @@ -1,177 +1,171 @@ namespace Components { - - class myIDirect3DDevice9 : public IDirect3DDevice9 - { - public: - myIDirect3DDevice9(IDirect3DDevice9* pOriginal); - virtual ~myIDirect3DDevice9(void); - - // START: The original DX9 function definitions - HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj); - ULONG __stdcall AddRef(void); - ULONG __stdcall Release(void); - HRESULT __stdcall TestCooperativeLevel(void); - UINT __stdcall GetAvailableTextureMem(void); - HRESULT __stdcall EvictManagedResources(void); - HRESULT __stdcall GetDirect3D(IDirect3D9** ppD3D9); - HRESULT __stdcall GetDeviceCaps(D3DCAPS9* pCaps); - HRESULT __stdcall GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode); - HRESULT __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters); - HRESULT __stdcall SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap); - void __stdcall SetCursorPosition(int X, int Y, DWORD Flags); - BOOL __stdcall ShowCursor(BOOL bShow); - HRESULT __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain); - HRESULT __stdcall GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain); - UINT __stdcall GetNumberOfSwapChains(void); - HRESULT __stdcall Reset(D3DPRESENT_PARAMETERS* pPresentationParameters); - HRESULT __stdcall Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion); - HRESULT __stdcall GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer); - HRESULT __stdcall GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus); - HRESULT __stdcall SetDialogBoxMode(BOOL bEnableDialogs); - void __stdcall SetGammaRamp(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp); - void __stdcall GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp); - HRESULT __stdcall CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle); - HRESULT __stdcall CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle); - HRESULT __stdcall CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle); - HRESULT __stdcall CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle); - HRESULT __stdcall CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle); - HRESULT __stdcall CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); - HRESULT __stdcall CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); - HRESULT __stdcall UpdateSurface(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint); - HRESULT __stdcall UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture); - HRESULT __stdcall GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface); - HRESULT __stdcall GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface); - HRESULT __stdcall StretchRect(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter); - HRESULT __stdcall ColorFill(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color); - HRESULT __stdcall CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); - HRESULT __stdcall SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget); - HRESULT __stdcall GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget); - HRESULT __stdcall SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil); - HRESULT __stdcall GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface); - HRESULT __stdcall BeginScene(void); - HRESULT __stdcall EndScene(void); - HRESULT __stdcall Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil); - HRESULT __stdcall SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix); - HRESULT __stdcall GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix); - HRESULT __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix); - HRESULT __stdcall SetViewport(CONST D3DVIEWPORT9* pViewport); - HRESULT __stdcall GetViewport(D3DVIEWPORT9* pViewport); - HRESULT __stdcall SetMaterial(CONST D3DMATERIAL9* pMaterial); - HRESULT __stdcall GetMaterial(D3DMATERIAL9* pMaterial); - HRESULT __stdcall SetLight(DWORD Index, CONST D3DLIGHT9* pLight); - HRESULT __stdcall GetLight(DWORD Index, D3DLIGHT9* pLight); - HRESULT __stdcall LightEnable(DWORD Index, BOOL Enable); - HRESULT __stdcall GetLightEnable(DWORD Index, BOOL* pEnable); - HRESULT __stdcall SetClipPlane(DWORD Index, CONST float* pPlane); - HRESULT __stdcall GetClipPlane(DWORD Index, float* pPlane); - HRESULT __stdcall SetRenderState(D3DRENDERSTATETYPE State, DWORD Value); - HRESULT __stdcall GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue); - HRESULT __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB); - HRESULT __stdcall BeginStateBlock(void); - HRESULT __stdcall EndStateBlock(IDirect3DStateBlock9** ppSB); - HRESULT __stdcall SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus); - HRESULT __stdcall GetClipStatus(D3DCLIPSTATUS9* pClipStatus); - HRESULT __stdcall GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture); - HRESULT __stdcall SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture); - HRESULT __stdcall GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue); - HRESULT __stdcall SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value); - HRESULT __stdcall GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue); - HRESULT __stdcall SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value); - HRESULT __stdcall ValidateDevice(DWORD* pNumPasses); - HRESULT __stdcall SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY* pEntries); - HRESULT __stdcall GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries); - HRESULT __stdcall SetCurrentTexturePalette(UINT PaletteNumber); - HRESULT __stdcall GetCurrentTexturePalette(UINT *PaletteNumber); - HRESULT __stdcall SetScissorRect(CONST RECT* pRect); - HRESULT __stdcall GetScissorRect(RECT* pRect); - HRESULT __stdcall SetSoftwareVertexProcessing(BOOL bSoftware); - BOOL __stdcall GetSoftwareVertexProcessing(void); - HRESULT __stdcall SetNPatchMode(float nSegments); - float __stdcall GetNPatchMode(void); - HRESULT __stdcall DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount); - HRESULT __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount); - HRESULT __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride); - HRESULT __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride); - HRESULT __stdcall ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags); - HRESULT __stdcall CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl); - HRESULT __stdcall SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl); - HRESULT __stdcall GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl); - HRESULT __stdcall SetFVF(DWORD FVF); - HRESULT __stdcall GetFVF(DWORD* pFVF); - HRESULT __stdcall CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader); - HRESULT __stdcall SetVertexShader(IDirect3DVertexShader9* pShader); - HRESULT __stdcall GetVertexShader(IDirect3DVertexShader9** ppShader); - HRESULT __stdcall SetVertexShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount); - HRESULT __stdcall GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount); - HRESULT __stdcall SetVertexShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount); - HRESULT __stdcall GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount); - HRESULT __stdcall SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount); - HRESULT __stdcall GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount); - HRESULT __stdcall SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride); - HRESULT __stdcall GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride); - HRESULT __stdcall SetStreamSourceFreq(UINT StreamNumber, UINT Divider); - HRESULT __stdcall GetStreamSourceFreq(UINT StreamNumber, UINT* Divider); - HRESULT __stdcall SetIndices(IDirect3DIndexBuffer9* pIndexData); - HRESULT __stdcall GetIndices(IDirect3DIndexBuffer9** ppIndexData); - HRESULT __stdcall CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader); - HRESULT __stdcall SetPixelShader(IDirect3DPixelShader9* pShader); - HRESULT __stdcall GetPixelShader(IDirect3DPixelShader9** ppShader); - HRESULT __stdcall SetPixelShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount); - HRESULT __stdcall GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount); - HRESULT __stdcall SetPixelShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount); - HRESULT __stdcall GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount); - HRESULT __stdcall SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount); - HRESULT __stdcall GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount); - HRESULT __stdcall DrawRectPatch(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo); - HRESULT __stdcall DrawTriPatch(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo); - HRESULT __stdcall DeletePatch(UINT Handle); - HRESULT __stdcall CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery); - // END: The original DX9 function definitions - - private: - IDirect3DDevice9 *m_pIDirect3DDevice9; - }; - - - class myIDirect3D9 : public IDirect3D9 - { - public: - myIDirect3D9(IDirect3D9Ex *pOriginal); - virtual ~myIDirect3D9(void); - - // The original DX9 function definitions - HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj); - ULONG __stdcall AddRef(void); - ULONG __stdcall Release(void); - HRESULT __stdcall RegisterSoftwareDevice(void* pInitializeFunction); - UINT __stdcall GetAdapterCount(void); - HRESULT __stdcall GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier); - UINT __stdcall GetAdapterModeCount(UINT Adapter, D3DFORMAT Format); - HRESULT __stdcall EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode); - HRESULT __stdcall GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode); - HRESULT __stdcall CheckDeviceType(UINT iAdapter, D3DDEVTYPE DevType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed); - HRESULT __stdcall CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat); - HRESULT __stdcall CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels); - HRESULT __stdcall CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat); - HRESULT __stdcall CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat); - HRESULT __stdcall GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps); - HMONITOR __stdcall GetAdapterMonitor(UINT Adapter); - HRESULT __stdcall CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface); - // The original DX9 function definitions - - private: - IDirect3D9 *m_pIDirect3D9; - }; - class D3D9Ex : public Component { public: D3D9Ex(); - ~D3D9Ex(); const char* GetName() { return "D3D9Ex"; }; private: + + class D3D9Device : public IDirect3DDevice9 + { + public: + D3D9Device(IDirect3DDevice9* pOriginal) : m_pIDirect3DDevice9(pOriginal) {}; + virtual ~D3D9Device(void) {}; + + HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj); + ULONG __stdcall AddRef(void); + ULONG __stdcall Release(void); + HRESULT __stdcall TestCooperativeLevel(void); + UINT __stdcall GetAvailableTextureMem(void); + HRESULT __stdcall EvictManagedResources(void); + HRESULT __stdcall GetDirect3D(IDirect3D9** ppD3D9); + HRESULT __stdcall GetDeviceCaps(D3DCAPS9* pCaps); + HRESULT __stdcall GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode); + HRESULT __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters); + HRESULT __stdcall SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap); + void __stdcall SetCursorPosition(int X, int Y, DWORD Flags); + BOOL __stdcall ShowCursor(BOOL bShow); + HRESULT __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain); + HRESULT __stdcall GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain); + UINT __stdcall GetNumberOfSwapChains(void); + HRESULT __stdcall Reset(D3DPRESENT_PARAMETERS* pPresentationParameters); + HRESULT __stdcall Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion); + HRESULT __stdcall GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer); + HRESULT __stdcall GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus); + HRESULT __stdcall SetDialogBoxMode(BOOL bEnableDialogs); + void __stdcall SetGammaRamp(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp); + void __stdcall GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp); + HRESULT __stdcall CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle); + HRESULT __stdcall CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle); + HRESULT __stdcall CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle); + HRESULT __stdcall CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle); + HRESULT __stdcall CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle); + HRESULT __stdcall CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); + HRESULT __stdcall CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); + HRESULT __stdcall UpdateSurface(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint); + HRESULT __stdcall UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture); + HRESULT __stdcall GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface); + HRESULT __stdcall GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface); + HRESULT __stdcall StretchRect(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter); + HRESULT __stdcall ColorFill(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color); + HRESULT __stdcall CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); + HRESULT __stdcall SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget); + HRESULT __stdcall GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget); + HRESULT __stdcall SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil); + HRESULT __stdcall GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface); + HRESULT __stdcall BeginScene(void); + HRESULT __stdcall EndScene(void); + HRESULT __stdcall Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil); + HRESULT __stdcall SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix); + HRESULT __stdcall GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix); + HRESULT __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix); + HRESULT __stdcall SetViewport(CONST D3DVIEWPORT9* pViewport); + HRESULT __stdcall GetViewport(D3DVIEWPORT9* pViewport); + HRESULT __stdcall SetMaterial(CONST D3DMATERIAL9* pMaterial); + HRESULT __stdcall GetMaterial(D3DMATERIAL9* pMaterial); + HRESULT __stdcall SetLight(DWORD Index, CONST D3DLIGHT9* pLight); + HRESULT __stdcall GetLight(DWORD Index, D3DLIGHT9* pLight); + HRESULT __stdcall LightEnable(DWORD Index, BOOL Enable); + HRESULT __stdcall GetLightEnable(DWORD Index, BOOL* pEnable); + HRESULT __stdcall SetClipPlane(DWORD Index, CONST float* pPlane); + HRESULT __stdcall GetClipPlane(DWORD Index, float* pPlane); + HRESULT __stdcall SetRenderState(D3DRENDERSTATETYPE State, DWORD Value); + HRESULT __stdcall GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue); + HRESULT __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB); + HRESULT __stdcall BeginStateBlock(void); + HRESULT __stdcall EndStateBlock(IDirect3DStateBlock9** ppSB); + HRESULT __stdcall SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus); + HRESULT __stdcall GetClipStatus(D3DCLIPSTATUS9* pClipStatus); + HRESULT __stdcall GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture); + HRESULT __stdcall SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture); + HRESULT __stdcall GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue); + HRESULT __stdcall SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value); + HRESULT __stdcall GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue); + HRESULT __stdcall SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value); + HRESULT __stdcall ValidateDevice(DWORD* pNumPasses); + HRESULT __stdcall SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY* pEntries); + HRESULT __stdcall GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries); + HRESULT __stdcall SetCurrentTexturePalette(UINT PaletteNumber); + HRESULT __stdcall GetCurrentTexturePalette(UINT *PaletteNumber); + HRESULT __stdcall SetScissorRect(CONST RECT* pRect); + HRESULT __stdcall GetScissorRect(RECT* pRect); + HRESULT __stdcall SetSoftwareVertexProcessing(BOOL bSoftware); + BOOL __stdcall GetSoftwareVertexProcessing(void); + HRESULT __stdcall SetNPatchMode(float nSegments); + float __stdcall GetNPatchMode(void); + HRESULT __stdcall DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount); + HRESULT __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount); + HRESULT __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride); + HRESULT __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride); + HRESULT __stdcall ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags); + HRESULT __stdcall CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl); + HRESULT __stdcall SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl); + HRESULT __stdcall GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl); + HRESULT __stdcall SetFVF(DWORD FVF); + HRESULT __stdcall GetFVF(DWORD* pFVF); + HRESULT __stdcall CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader); + HRESULT __stdcall SetVertexShader(IDirect3DVertexShader9* pShader); + HRESULT __stdcall GetVertexShader(IDirect3DVertexShader9** ppShader); + HRESULT __stdcall SetVertexShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount); + HRESULT __stdcall GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount); + HRESULT __stdcall SetVertexShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount); + HRESULT __stdcall GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount); + HRESULT __stdcall SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount); + HRESULT __stdcall GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount); + HRESULT __stdcall SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride); + HRESULT __stdcall GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride); + HRESULT __stdcall SetStreamSourceFreq(UINT StreamNumber, UINT Divider); + HRESULT __stdcall GetStreamSourceFreq(UINT StreamNumber, UINT* Divider); + HRESULT __stdcall SetIndices(IDirect3DIndexBuffer9* pIndexData); + HRESULT __stdcall GetIndices(IDirect3DIndexBuffer9** ppIndexData); + HRESULT __stdcall CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader); + HRESULT __stdcall SetPixelShader(IDirect3DPixelShader9* pShader); + HRESULT __stdcall GetPixelShader(IDirect3DPixelShader9** ppShader); + HRESULT __stdcall SetPixelShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount); + HRESULT __stdcall GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount); + HRESULT __stdcall SetPixelShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount); + HRESULT __stdcall GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount); + HRESULT __stdcall SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount); + HRESULT __stdcall GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount); + HRESULT __stdcall DrawRectPatch(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo); + HRESULT __stdcall DrawTriPatch(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo); + HRESULT __stdcall DeletePatch(UINT Handle); + HRESULT __stdcall CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery); + + private: + IDirect3DDevice9 *m_pIDirect3DDevice9; + }; + + class D3D9 : public IDirect3D9 + { + public: + D3D9(IDirect3D9Ex *pOriginal) : m_pIDirect3D9(pOriginal) {}; + virtual ~D3D9(void) {}; + + HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj); + ULONG __stdcall AddRef(void); + ULONG __stdcall Release(void); + HRESULT __stdcall RegisterSoftwareDevice(void* pInitializeFunction); + UINT __stdcall GetAdapterCount(void); + HRESULT __stdcall GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier); + UINT __stdcall GetAdapterModeCount(UINT Adapter, D3DFORMAT Format); + HRESULT __stdcall EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode); + HRESULT __stdcall GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode); + HRESULT __stdcall CheckDeviceType(UINT iAdapter, D3DDEVTYPE DevType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed); + HRESULT __stdcall CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat); + HRESULT __stdcall CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels); + HRESULT __stdcall CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat); + HRESULT __stdcall CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat); + HRESULT __stdcall GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps); + HMONITOR __stdcall GetAdapterMonitor(UINT Adapter); + HRESULT __stdcall CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface); + + private: + IDirect3D9 *m_pIDirect3D9; + }; + static IDirect3D9* __stdcall Direct3DCreate9Stub(UINT sdk); }; } diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 385278cc..99a9bfbc 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -76,7 +76,7 @@ namespace Components Utils::Hook::Set(0x45ACE0, 0xC301B0); // fs_basegame - Utils::Hook::Set(0x6431D1, "data"); + Utils::Hook::Set(0x6431D1, "data2"); // UI version string Utils::Hook::Set(0x43F73B, "iw4x IW4x: r" REVISION_STR "-" MILESTONE);