Path: blob/master/libmupen64plus/D3D8Interceptor/Direct3DDevice8Functions.cpp
2 views
#include "d3d8Wrapper.h"12extern "C"3{4namespace D3D8Wrapper5{6ThreadSafePointerSet IDirect3DDevice8::m_List;78D3D8Wrapper::IDirect3DDevice8::IDirect3DDevice8(D3D8Base::IDirect3DDevice8* realDevice) : IDirect3DUnknown((IUnknown*) realDevice)9{10LOG("IDirect3DDevice8::IDirect3DDevice8( " << realDevice << " )\n");11m_pDevice = realDevice;12}1314D3D8Wrapper::IDirect3DDevice8* D3D8Wrapper::IDirect3DDevice8::GetDirect3DDevice(D3D8Base::IDirect3DDevice8* realDevice)15{16LOG("IDirect3DDevice8::GetDirect3DDevice( " << realDevice << " )\n");17D3D8Wrapper::IDirect3DDevice8* wrappedDevice = (D3D8Wrapper::IDirect3DDevice8*) m_List.GetDataPtr(realDevice);18if(wrappedDevice == NULL)19{20wrappedDevice = new D3D8Wrapper::IDirect3DDevice8(realDevice);21m_List.AddMember(realDevice, wrappedDevice);22return wrappedDevice;23}2425wrappedDevice->m_ulRef++;26return wrappedDevice;27}2829STDMETHODIMP_(ULONG) D3D8Wrapper::IDirect3DDevice8::Release(THIS)30{31LOG("IDirect3DDevice8::Release() [ " << this << " ]\n");32m_pUnk->Release();3334ULONG ulRef = --m_ulRef;3536if(ulRef == 0)37{38m_List.DeleteMember(GetD3D8Device());39delete this;40return NULL;41}42return ulRef;43}444546STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::TestCooperativeLevel()47{48LOG("IDirect3DDevice8::TestCooperativeLevel() [ " << this << " ]\n");49return m_pDevice->TestCooperativeLevel();50}5152STDMETHODIMP_(UINT) D3D8Wrapper::IDirect3DDevice8::GetAvailableTextureMem()53{54LOG("IDirect3DDevice8::GetAvailableTextureMem() [ " << this << " ]\n");55return m_pDevice->GetAvailableTextureMem();56}5758STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::ResourceManagerDiscardBytes(DWORD Bytes)59{60LOG("IDirect3DDevice8::ResourceManagerDiscardBytes( " << Bytes << " ) [ " << this << " ]\n");61return m_pDevice->ResourceManagerDiscardBytes(Bytes);62}6364STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetDirect3D(D3D8Wrapper::IDirect3D8** ppD3D8)65{66LOG("IDirect3DDevice8::GetDirect3D( " << ppD3D8 << " ) [ " << this << " ]\n");6768// Run the function and wrap the result before returning it69D3D8Base::IDirect3D8* realD3D = NULL;7071HRESULT hr = m_pDevice->GetDirect3D(&realD3D);7273D3D8Wrapper::IDirect3D8* wrappedD3D = D3D8Wrapper::IDirect3D8::GetDirect3D(realD3D);7475*ppD3D8 = wrappedD3D;7677return hr;78}7980STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetDeviceCaps(D3D8Base::D3DCAPS8* pCaps)81{82LOG("IDirect3DDevice8::GetDeviceCaps( " << pCaps << " ) [ " << this << " ]\n");83return m_pDevice->GetDeviceCaps(pCaps);84}8586STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetDisplayMode(D3D8Base::D3DDISPLAYMODE* pMode)87{88LOG("IDirect3DDevice8::GetDisplayMode( " << pMode << " ) [ " << this << " ]\n");89return m_pDevice->GetDisplayMode(pMode);90}9192STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetCreationParameters(D3D8Base::D3DDEVICE_CREATION_PARAMETERS *pParameters)93{94LOG("IDirect3DDevice8::GetCreationParameters( " << pParameters << " ) [ " << this << " ]\n");95return m_pDevice->GetCreationParameters(pParameters);96}9798STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetCursorProperties(UINT XHotSpot,UINT YHotSpot,D3D8Wrapper::IDirect3DSurface8* pCursorBitmap)99{100LOG("IDirect3DDevice8::SetCursorProperties( " << XHotSpot << " , " << YHotSpot << " , " << pCursorBitmap << " ) [ " << this << " ]\n");101if (pCursorBitmap == NULL)102{103return m_pDevice->SetCursorProperties(XHotSpot,YHotSpot,NULL);104}105else106{107return m_pDevice->SetCursorProperties(XHotSpot,YHotSpot,pCursorBitmap->GetSurface());108}109}110111STDMETHODIMP_(void) D3D8Wrapper::IDirect3DDevice8::SetCursorPosition(int X,int Y,DWORD Flags)112{113LOG("IDirect3DDevice8::SetCursorPosition( " << X << " , " << Y << " , " << Flags << " ) [ " << this << " ]\n");114m_pDevice->SetCursorPosition(X,Y,Flags);115}116117STDMETHODIMP_(BOOL) D3D8Wrapper::IDirect3DDevice8::ShowCursor(BOOL bShow)118{119LOG("IDirect3DDevice8::ShowCursor( " << bShow << " ) [ " << this << " ]\n");120return m_pDevice->ShowCursor(bShow);121}122123STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::CreateAdditionalSwapChain(D3D8Base::D3DPRESENT_PARAMETERS* pPresentationParameters,D3D8Wrapper::IDirect3DSwapChain8** pSwapChain)124{125LOG("IDirect3DDevice8::CreateAdditionalSwapChain( " << pPresentationParameters << " , " << pSwapChain << " ) [ " << this << " ]\n");126D3D8Base::IDirect3DSwapChain8* realD3D = NULL;127128HRESULT hr = m_pDevice->CreateAdditionalSwapChain(pPresentationParameters,&realD3D);129130D3D8Wrapper::IDirect3DSwapChain8* wrappedD3D = new D3D8Wrapper::IDirect3DSwapChain8(realD3D);131132*pSwapChain = wrappedD3D;133134return hr;135}136137STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::Reset(D3D8Base::D3DPRESENT_PARAMETERS* pPresentationParameters)138{139LOG("IDirect3DDevice8::Reset( " << pPresentationParameters << " ) [ " << this << " ]\n");140return m_pDevice->Reset(pPresentationParameters);141}142143STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::Present(CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion)144{145#ifdef LOGGING146LOG("IDirect3DDevice8::Present( " << pSourceRect);147if (pSourceRect != NULL)148{149LOG("{ " << pSourceRect->left << " , " << pSourceRect->top << " , " << pSourceRect->right << " , " << pSourceRect->bottom << " }");150}151LOG(" , " << pDestRect);152if (pSourceRect != NULL)153{154LOG("{ " << pDestRect->left << " , " << pDestRect->top << " , " << pDestRect->right << " , " << pDestRect->bottom << " }");155}156LOG(" , " << hDestWindowOverride << " , " << pDirtyRegion << " ) [ " << this << " ]\n");157#endif158// Force the result to OK159HRESULT hr = D3D_OK;160161// Don't call the real present162//hr = m_pDevice->Present(pSourceRect,pDestRect,hDestWindowOverride,pDirtyRegion);163164// Let bizhawk know the frame is ready165rendering_callback(0);166167return hr;168}169170STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetBackBuffer(UINT BackBuffer,D3D8Base::D3DBACKBUFFER_TYPE Type,D3D8Wrapper::IDirect3DSurface8** ppBackBuffer)171{172LOG("IDirect3DDevice8::GetBackBuffer( " << BackBuffer << " , " << Type << " , " << ppBackBuffer << " ) [ " << this << " ]\n");173174/*175D3D8Base::IDirect3DSurface8* realD3D = NULL;176177HRESULT hr = m_pDevice->GetBackBuffer(BackBuffer,Type,&realD3D);178179D3D8Wrapper::IDirect3DSurface8* wrappedD3D = D3D8Wrapper::IDirect3DSurface8::GetSurface(realD3D);180*/181182// Return a pointer to our render surface, not the back buffer183*ppBackBuffer = render_surface;// wrappedD3D;184render_surface->m_ulRef++;185186return S_OK;187}188189STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetRasterStatus(D3D8Base::D3DRASTER_STATUS* pRasterStatus)190{191LOG("IDirect3DDevice8::GetRasterStatus( " << pRasterStatus << " ) [ " << this << " ]\n");192return m_pDevice->GetRasterStatus(pRasterStatus);193}194195STDMETHODIMP_(void) D3D8Wrapper::IDirect3DDevice8::SetGammaRamp(DWORD Flags,CONST D3D8Base::D3DGAMMARAMP* pRamp)196{197LOG("IDirect3DDevice8::SetGammaRamp( " << Flags << " , " << pRamp << " ) [ " << this << " ]\n");198m_pDevice->SetGammaRamp(Flags,pRamp);199}200201STDMETHODIMP_(void) D3D8Wrapper::IDirect3DDevice8::GetGammaRamp(D3D8Base::D3DGAMMARAMP* pRamp)202{203LOG("IDirect3DDevice8::GetGammaRamp( " << pRamp << " ) [ " << this << " ]\n");204m_pDevice->GetGammaRamp(pRamp);205}206207STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::CreateTexture(UINT Width,UINT Height,UINT Levels,DWORD Usage,D3D8Base::D3DFORMAT Format,D3D8Base::D3DPOOL Pool,D3D8Wrapper::IDirect3DTexture8** ppTexture)208{209LOG("IDirect3DDevice8::CreateTexture( " << Width << " , " << Height << " , " << Levels << " , " << Usage << " , " << Format << " , " << Pool << " , " << ppTexture << " ) [ " << this << " ]\n");210211D3D8Base::IDirect3DTexture8* realD3D = NULL;212213HRESULT hr = m_pDevice->CreateTexture(Width,Height,Levels,Usage,Format,Pool,&realD3D);214215D3D8Wrapper::IDirect3DTexture8* wrappedD3D = D3D8Wrapper::IDirect3DTexture8::GetTexture(realD3D);216217*ppTexture = wrappedD3D;218219return hr;220}221222STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::CreateVolumeTexture(UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3D8Base::D3DFORMAT Format,D3D8Base::D3DPOOL Pool,D3D8Wrapper::IDirect3DVolumeTexture8** ppVolumeTexture)223{224LOG("IDirect3DDevice8::CreateVolumeTexture( " << Width << " , " << Height << " , " << Levels << " , " << Usage << " , " << Format << " , " << Pool << " , " << ppVolumeTexture << " ) [ " << this << " ]\n");225226D3D8Base::IDirect3DVolumeTexture8* realD3D = NULL;227228HRESULT hr = m_pDevice->CreateVolumeTexture(Width,Height,Depth,Levels,Usage,Format,Pool,&realD3D);229230D3D8Wrapper::IDirect3DVolumeTexture8* wrappedD3D = new D3D8Wrapper::IDirect3DVolumeTexture8(realD3D);231232*ppVolumeTexture = wrappedD3D;233234return hr;235}236237STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::CreateCubeTexture(UINT EdgeLength,UINT Levels,DWORD Usage,D3D8Base::D3DFORMAT Format,D3D8Base::D3DPOOL Pool,D3D8Wrapper::IDirect3DCubeTexture8** ppCubeTexture)238{239LOG("IDirect3DDevice8::CreateCubeTexture( " << EdgeLength << " , " << Levels << " , " << Usage << " , " << Format << " , " << Pool << " , " << ppCubeTexture << " ) [ " << this << " ]\n");240241D3D8Base::IDirect3DCubeTexture8* realD3D = NULL;242243HRESULT hr = m_pDevice->CreateCubeTexture(EdgeLength,Levels, Usage,Format,Pool,&realD3D);244245D3D8Wrapper::IDirect3DCubeTexture8* wrappedD3D = new D3D8Wrapper::IDirect3DCubeTexture8(realD3D);246247*ppCubeTexture = wrappedD3D;248249return hr;250}251252STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::CreateVertexBuffer(UINT Length,DWORD Usage,DWORD FVF,D3D8Base::D3DPOOL Pool,D3D8Wrapper::IDirect3DVertexBuffer8** ppVertexBuffer)253{254LOG("IDirect3DDevice8::CreateVertexBuffer( " << Length << " , " << Usage << " , " << FVF << " , " << Pool << " , " << ppVertexBuffer << " ) [ " << this << " ]\n");255256D3D8Base::IDirect3DVertexBuffer8* realD3D = NULL;257258HRESULT hr = m_pDevice->CreateVertexBuffer(Length,Usage,FVF,Pool,&realD3D);259260D3D8Wrapper::IDirect3DVertexBuffer8* wrappedD3D = new D3D8Wrapper::IDirect3DVertexBuffer8(realD3D);261262*ppVertexBuffer = wrappedD3D;263264return hr;265}266267STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::CreateIndexBuffer(UINT Length,DWORD Usage,D3D8Base::D3DFORMAT Format,D3D8Base::D3DPOOL Pool,D3D8Wrapper::IDirect3DIndexBuffer8** ppIndexBuffer)268{269LOG("IDirect3DDevice8::CreateIndexBuffer( " << Length << " , " << Usage << " , " << Format << " , " << Pool << " , " << ppIndexBuffer << " ) [ " << this << " ]\n");270271D3D8Base::IDirect3DIndexBuffer8* realD3D = NULL;272273HRESULT hr = m_pDevice->CreateIndexBuffer(Length,Usage,Format,Pool,&realD3D);274275D3D8Wrapper::IDirect3DIndexBuffer8* wrappedD3D = new D3D8Wrapper::IDirect3DIndexBuffer8(realD3D);276277*ppIndexBuffer = wrappedD3D;278279return hr;280}281282STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::CreateRenderTarget(UINT Width,UINT Height,D3D8Base::D3DFORMAT Format,D3D8Base::D3DMULTISAMPLE_TYPE MultiSample,BOOL Lockable,D3D8Wrapper::IDirect3DSurface8** ppSurface)283{284LOG("IDirect3DDevice8::CreateRenderTarget( " << Width << " , " << Height << " , " << Format << " , " << MultiSample << " , " << Lockable << " , " << ppSurface << " ) [ " << this << " ]\n");285286D3D8Base::IDirect3DSurface8* realD3D = NULL;287288HRESULT hr = m_pDevice->CreateRenderTarget(Width,Height,Format,MultiSample,Lockable,&realD3D);289290D3D8Wrapper::IDirect3DSurface8* wrappedD3D = D3D8Wrapper::IDirect3DSurface8::GetSurface(realD3D);291292*ppSurface = wrappedD3D;293294return hr;295}296297STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::CreateDepthStencilSurface(UINT Width,UINT Height,D3D8Base::D3DFORMAT Format,D3D8Base::D3DMULTISAMPLE_TYPE MultiSample,D3D8Wrapper::IDirect3DSurface8** ppSurface)298{299LOG("IDirect3DDevice8::CreateDepthStencilSurface( " << Width << " , " << Height << " , " << Format << " , " << MultiSample << " , " << ppSurface << " ) [ " << this << " ]\n");300301D3D8Base::IDirect3DSurface8* realD3D = NULL;302303HRESULT hr = m_pDevice->CreateDepthStencilSurface(Width,Height,Format,MultiSample,&realD3D);304305D3D8Wrapper::IDirect3DSurface8* wrappedD3D = D3D8Wrapper::IDirect3DSurface8::GetSurface(realD3D);306307*ppSurface = wrappedD3D;308309return hr;310}311312STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::CreateImageSurface(UINT Width,UINT Height,D3D8Base::D3DFORMAT Format,D3D8Wrapper::IDirect3DSurface8** ppSurface)313{314LOG("IDirect3DDevice8::CreateImageSurface( " << Width << " , " << Height << " , " << Format << " , " << ppSurface << " ) [ " << this << " ]\n");315316D3D8Base::IDirect3DSurface8* realD3D = NULL;317318HRESULT hr = m_pDevice->CreateImageSurface(Width,Height,Format,&realD3D);319320D3D8Wrapper::IDirect3DSurface8* wrappedD3D = D3D8Wrapper::IDirect3DSurface8::GetSurface(realD3D);321322*ppSurface = wrappedD3D;323324return hr;325}326327STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::CopyRects(D3D8Wrapper::IDirect3DSurface8* pSourceSurface,CONST RECT* pSourceRectsArray,UINT cRects,D3D8Wrapper::IDirect3DSurface8* pDestinationSurface,CONST POINT* pDestPointsArray)328{329LOG("IDirect3DDevice8::CopyRects( " << pSourceSurface << " , " << pSourceRectsArray << " , " << cRects << " , " << pDestinationSurface << " , " << pDestPointsArray << " ) [ " << this << " ]\n");330331D3D8Base::IDirect3DSurface8* source;332if (pSourceSurface == NULL)333{334source = NULL;335}336else337{338source = pSourceSurface->GetSurface();339}340341D3D8Base::IDirect3DSurface8* destination;342if (pDestinationSurface == NULL)343{344destination = NULL;345}346else347{348destination = pDestinationSurface->GetSurface();349}350351if (pSourceSurface->m_ulRef == 0 || source == destination)352{353return D3DERR_INVALIDCALL;354}355356return m_pDevice->CopyRects(source,pSourceRectsArray,cRects,destination,pDestPointsArray);357}358359STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::UpdateTexture(D3D8Wrapper::IDirect3DBaseTexture8* pSourceTexture,D3D8Wrapper::IDirect3DBaseTexture8* pDestinationTexture)360{361LOG("IDirect3DDevice8::UpdateTexture( " << pSourceTexture << " , " << pDestinationTexture << " ) [ " << this << " ]\n");362D3D8Base::IDirect3DBaseTexture8* source;363if (pSourceTexture == NULL)364{365source = NULL;366}367else368{369source = pSourceTexture->GetBaseTexture();370}371372D3D8Base::IDirect3DBaseTexture8* destination;373if (pDestinationTexture == NULL)374{375destination = NULL;376}377else378{379destination = pDestinationTexture->GetBaseTexture();380}381382return m_pDevice->UpdateTexture(source,destination);383}384385STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetFrontBuffer(D3D8Wrapper::IDirect3DSurface8* pDestSurface)386{387LOG("IDirect3DDevice8::GetFrontBuffer( " << pDestSurface << " ) [ " << this << " ]\n");388if (pDestSurface == NULL)389{390return m_pDevice->GetFrontBuffer(NULL);391}392else393{394return m_pDevice->GetFrontBuffer(pDestSurface->GetSurface());395}396}397398STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetRenderTarget(D3D8Wrapper::IDirect3DSurface8* pRenderTarget,D3D8Wrapper::IDirect3DSurface8* pNewZStencil)399{400LOG("IDirect3DDevice8::SetRenderTarget( " << pRenderTarget << " , " << pNewZStencil << " ) [ " << this << " ]\n");401402//HRESULT hr = m_pDevice->SetRenderTarget(pRenderTarget->GetSurface(),pNewZStencil->GetSurface());403HRESULT hr = m_pDevice->SetRenderTarget(render_surface->GetSurface(),pNewZStencil->GetSurface());404405pRenderTarget->m_ulRef++;406pNewZStencil->m_ulRef++;407408return hr;409}410411STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetRenderTarget(D3D8Wrapper::IDirect3DSurface8** ppRenderTarget)412{413LOG("IDirect3DDevice8::GetRenderTarget( " << ppRenderTarget << " ) [ " << this << " ]\n");414415D3D8Base::IDirect3DSurface8* realD3D = NULL;416417HRESULT hr = m_pDevice->GetRenderTarget(&realD3D);418419D3D8Wrapper::IDirect3DSurface8* wrappedD3D = D3D8Wrapper::IDirect3DSurface8::GetSurface(realD3D);420421*ppRenderTarget = wrappedD3D;422423return hr;424}425426STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetDepthStencilSurface(D3D8Wrapper::IDirect3DSurface8** ppZStencilSurface)427{428LOG("IDirect3DDevice8::GetDepthStencilSurface( " << ppZStencilSurface << " ) [ " << this << " ]\n");429430D3D8Base::IDirect3DSurface8* realD3D = NULL;431432HRESULT hr = m_pDevice->GetDepthStencilSurface(&realD3D);433434D3D8Wrapper::IDirect3DSurface8* wrappedD3D = D3D8Wrapper::IDirect3DSurface8::GetSurface(realD3D);435436*ppZStencilSurface = wrappedD3D;437438return hr;439}440441STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::BeginScene()442{443LOG("IDirect3DDevice8::BeginScene() [ " << this << " ]\n");444return m_pDevice->BeginScene();445}446447STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::EndScene()448{449LOG("IDirect3DDevice8::EndScene() [ " << this << " ]\n");450return m_pDevice->EndScene();451}452453STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::Clear(DWORD Count,CONST D3D8Base::D3DRECT* pRects,DWORD Flags,D3D8Base::D3DCOLOR Color,float Z,DWORD Stencil)454{455#ifdef LOGGING456LOG("IDirect3DDevice8::Clear( " << Count << " , " << pRects);457if (pRects != NULL)458{459LOG("{ " << pRects->x1 << " , " << pRects->y1 << " , " << pRects->x2 << " , " << pRects->y2 << " }")460}461LOG(" , " << Flags << " , " << Color << " , " << Z << " , " << Stencil << " ) [ " << this << " ]\n");462#endif463464return m_pDevice->Clear(Count,pRects,Flags,Color,Z,Stencil);465}466467STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetTransform(D3D8Base::D3DTRANSFORMSTATETYPE State,CONST D3D8Base::D3DMATRIX* pMatrix)468{469LOG("IDirect3DDevice8::SetTransform( " << State << " , " << pMatrix << " ) [ " << this << " ]\n");470return m_pDevice->SetTransform(State,pMatrix);471}472473STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetTransform(D3D8Base::D3DTRANSFORMSTATETYPE State,D3D8Base::D3DMATRIX* pMatrix)474{475LOG("IDirect3DDevice8::GetTransform( " << State << " , " << pMatrix << " ) [ " << this << " ]\n");476return m_pDevice->GetTransform(State,pMatrix);477}478479STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::MultiplyTransform(D3D8Base::D3DTRANSFORMSTATETYPE foo,CONST D3D8Base::D3DMATRIX* bar)480{481LOG("IDirect3DDevice8::MultiplyTransform( " << foo << " , " << bar << " ) [ " << this << " ]\n");482return m_pDevice->MultiplyTransform(foo, bar);483}484485STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetViewport(CONST D3D8Base::D3DVIEWPORT8* pViewport)486{487LOG("IDirect3DDevice8::SetViewport( " << pViewport << " ) [ " << this << " ]\n");488return m_pDevice->SetViewport(pViewport);489}490491STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetViewport(D3D8Base::D3DVIEWPORT8* pViewport)492{493#ifdef LOGGING494LOG("IDirect3DDevice8::GetViewport( " << pViewport);495if (pViewport != NULL)496{497LOG("{ " << pViewport->X << " , " << pViewport->Y << " , " << pViewport->Width << " , " << pViewport->Height << " , " << pViewport->MinZ << " , " << pViewport->MaxZ << " }");498}499LOG(" ) [ " << this << " ]\n");500#endif501return m_pDevice->GetViewport(pViewport);502}503504STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetMaterial(CONST D3D8Base::D3DMATERIAL8* pMaterial)505{506LOG("IDirect3DDevice8::SetMaterial( " << pMaterial << " ) [ " << this << " ]\n");507return m_pDevice->SetMaterial(pMaterial);508}509510STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetMaterial(D3D8Base::D3DMATERIAL8* pMaterial)511{512LOG("IDirect3DDevice8::GetMaterial( " << pMaterial << " ) [ " << this << " ]\n");513return m_pDevice->GetMaterial(pMaterial);514}515516STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetLight(DWORD Index,CONST D3D8Base::D3DLIGHT8* foo)517{518LOG("IDirect3DDevice8::SetLight( " << Index << " , " << foo << " ) [ " << this << " ]\n");519return m_pDevice->SetLight(Index,foo);520}521522STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetLight(DWORD Index,D3D8Base::D3DLIGHT8* foo)523{524LOG("IDirect3DDevice8::GetLight( " << Index << " , " << foo << " ) [ " << this << " ]\n");525return m_pDevice->GetLight(Index,foo);526}527528STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::LightEnable(DWORD Index,BOOL Enable)529{530LOG("IDirect3DDevice8::LightEnable( " << Index << " , " << Enable << " ) [ " << this << " ]\n");531return m_pDevice->LightEnable(Index,Enable);532}533534STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetLightEnable(DWORD Index,BOOL* pEnable)535{536LOG("IDirect3DDevice8::GetLightEnable( " << Index << " , " << pEnable << " ) [ " << this << " ]\n");537return m_pDevice->GetLightEnable(Index,pEnable);538}539540STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetClipPlane(DWORD Index,CONST float* pPlane)541{542LOG("IDirect3DDevice8::SetClipPlane( " << Index << " , " << pPlane << " ) [ " << this << " ]\n");543return m_pDevice->SetClipPlane(Index,pPlane);544}545546STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetClipPlane(DWORD Index,float* pPlane)547{548LOG("IDirect3DDevice8::GetClipPlane( " << Index << " , " << pPlane << " ) [ " << this << " ]\n");549return m_pDevice->GetClipPlane(Index,pPlane);550}551552STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetRenderState(D3D8Base::D3DRENDERSTATETYPE State,DWORD Value)553{554LOG("IDirect3DDevice8::SetRenderState( " << State << " , " << Value << " ) [ " << this << " ]\n");555return m_pDevice->SetRenderState(State,Value);556}557558STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetRenderState(D3D8Base::D3DRENDERSTATETYPE State,DWORD* pValue)559{560LOG("IDirect3DDevice8::GetRenderState( " << State << " , " << pValue << " ) [ " << this << " ]\n");561return m_pDevice->GetRenderState(State,pValue);562}563564STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::BeginStateBlock()565{566LOG("IDirect3DDevice8::BeginStateBlock() [ " << this << " ]\n");567return m_pDevice->BeginStateBlock();568}569570STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::EndStateBlock(DWORD* pToken)571{572LOG("IDirect3DDevice8::EndStateBlock( " << pToken << " ) [ " << this << " ]\n");573return m_pDevice->EndStateBlock(pToken);574}575576STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::ApplyStateBlock(DWORD Token)577{578LOG("IDirect3DDevice8::ApplyStateBlock( " << Token << " ) [ " << this << " ]\n");579return m_pDevice->ApplyStateBlock(Token);580}581582STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::CaptureStateBlock(DWORD Token)583{584LOG("IDirect3DDevice8::CaptureStateBlock( " << Token << " ) [ " << this << " ]\n");585return m_pDevice->CaptureStateBlock(Token);586}587588STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::DeleteStateBlock(DWORD Token)589{590LOG("IDirect3DDevice8::DeleteStateBlock( " << Token << " ) [ " << this << " ]\n");591return m_pDevice->DeleteStateBlock(Token);592}593594STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::CreateStateBlock(D3D8Base::D3DSTATEBLOCKTYPE Type,DWORD* pToken)595{596LOG("IDirect3DDevice8::CreateStateBlock( " << Type << " , " << pToken << " ) [ " << this << " ]\n");597return m_pDevice->CreateStateBlock(Type,pToken);598}599600STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetClipStatus(CONST D3D8Base::D3DCLIPSTATUS8* pClipStatus)601{602LOG("IDirect3DDevice8::SetClipStatus( " << pClipStatus << " ) [ " << this << " ]\n");603return m_pDevice->SetClipStatus(pClipStatus);604}605606STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetClipStatus(D3D8Base::D3DCLIPSTATUS8* pClipStatus)607{608LOG("IDirect3DDevice8::GetClipStatus( " << pClipStatus << " ) [ " << this << " ]\n");609return m_pDevice->GetClipStatus(pClipStatus);610}611612STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetTexture(DWORD Stage,D3D8Wrapper::IDirect3DBaseTexture8** ppTexture)613{614LOG("IDirect3DDevice8::GetTexture( " << Stage << " , " << ppTexture << " ) [ " << this << " ]\n");615616D3D8Base::IDirect3DBaseTexture8* realD3D = NULL;617618HRESULT hr = m_pDevice->GetTexture(Stage,&realD3D);//ppTexture);619620D3D8Wrapper::IDirect3DBaseTexture8* wrappedD3D = new D3D8Wrapper::IDirect3DBaseTexture8(realD3D);621622*ppTexture = wrappedD3D;623624return hr;625}626627STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetTexture(DWORD Stage,D3D8Wrapper::IDirect3DBaseTexture8* pTexture)628{629LOG("IDirect3DDevice8::SetTexture( " << Stage << " , " << pTexture << " ) [ " << this << " ]\n");630631if (pTexture == NULL)632{633return m_pDevice->SetTexture(Stage,NULL);634}635else636{637return m_pDevice->SetTexture(Stage,pTexture->GetBaseTexture());638}639}640641STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetTextureStageState(DWORD Stage,D3D8Base::D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue)642{643LOG("IDirect3DDevice8::GetTextureStageState( " << Stage << " , " << Type << " , " << pValue << " ) [ " << this << " ]\n");644return m_pDevice->GetTextureStageState(Stage,Type,pValue);645}646647STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetTextureStageState(DWORD Stage,D3D8Base::D3DTEXTURESTAGESTATETYPE Type,DWORD Value)648{649LOG("IDirect3DDevice8::SetTextureStageState( " << Stage << " , " << Type << " , " << Value << " ) [ " << this << " ]\n");650return m_pDevice->SetTextureStageState(Stage,Type,Value);651}652653STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::ValidateDevice(DWORD* pNumPasses)654{655LOG("IDirect3DDevice8::ValidateDevice( " << pNumPasses << " ) [ " << this << " ]\n");656return m_pDevice->ValidateDevice(pNumPasses);657}658659STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetInfo(DWORD DevInfoID,void* pDevInfoStruct,DWORD DevInfoStructSize)660{661LOG("IDirect3DDevice8::GetInfo( " << DevInfoID << " , " << pDevInfoStruct << " , " << DevInfoStructSize << " ) [ " << this << " ]\n");662return m_pDevice->GetInfo(DevInfoID,pDevInfoStruct,DevInfoStructSize);663}664665STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetPaletteEntries(UINT PaletteNumber,CONST PALETTEENTRY* pEntries)666{667LOG("IDirect3DDevice8::SetPaletteEntries( " << PaletteNumber << " , " << pEntries << " ) [ " << this << " ]\n");668return m_pDevice->SetPaletteEntries(PaletteNumber,pEntries);669}670671STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetPaletteEntries(UINT PaletteNumber,PALETTEENTRY* pEntries)672{673LOG("IDirect3DDevice8::GetPaletteEntries( " << PaletteNumber << " , " << pEntries << " ) [ " << this << " ]\n");674return m_pDevice->GetPaletteEntries(PaletteNumber,pEntries);675}676677STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetCurrentTexturePalette(UINT PaletteNumber)678{679LOG("IDirect3DDevice8::SetCurrentTexturePalette( " << PaletteNumber << " ) [ " << this << " ]\n");680return m_pDevice->SetCurrentTexturePalette(PaletteNumber);681}682683STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetCurrentTexturePalette(UINT *PaletteNumber)684{685LOG("IDirect3DDevice8::GetCurrentTexturePalette( " << PaletteNumber << " ) [ " << this << " ]\n");686return m_pDevice->GetCurrentTexturePalette(PaletteNumber);687}688689STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::DrawPrimitive(D3D8Base::D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount)690{691LOG("IDirect3DDevice8::DrawPrimitive( " << PrimitiveType << " , " << StartVertex << " , " << PrimitiveCount << " ) [ " << this << " ]\n");692return m_pDevice->DrawPrimitive(PrimitiveType,StartVertex,PrimitiveCount);693}694695STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::DrawIndexedPrimitive(D3D8Base::D3DPRIMITIVETYPE PrimitiveType,UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount)696{697LOG("IDirect3DDevice8::DrawIndexedPrimitive( " << PrimitiveType << " , " << minIndex << " , " << NumVertices << " , " << startIndex << " , " << primCount << " ) [ " << this << " ]\n");698return m_pDevice->DrawIndexedPrimitive(PrimitiveType,minIndex,NumVertices,startIndex,primCount);699}700701STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::DrawPrimitiveUP(D3D8Base::D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride)702{703LOG("IDirect3DDevice8::DrawPrimitiveUP( " << PrimitiveType << " , " << PrimitiveCount << " , " << pVertexStreamZeroData << " , " << VertexStreamZeroStride << " ) [ " << this << " ]\n");704return m_pDevice->DrawPrimitiveUP(PrimitiveType,PrimitiveCount,pVertexStreamZeroData,VertexStreamZeroStride);705}706707STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::DrawIndexedPrimitiveUP(D3D8Base::D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,D3D8Base::D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride)708{709LOG("IDirect3DDevice8::DrawIndexedPrimitiveUP( " << PrimitiveType << " , " << MinVertexIndex << " , " << NumVertexIndices << " , " << PrimitiveCount << " , " << pIndexData << " , " << IndexDataFormat << " , " << pVertexStreamZeroData << " , " << VertexStreamZeroStride << " ) [ " << this << " ]\n");710return m_pDevice->DrawIndexedPrimitiveUP(PrimitiveType,MinVertexIndex,NumVertexIndices,PrimitiveCount,pIndexData,IndexDataFormat,pVertexStreamZeroData,VertexStreamZeroStride);711}712713STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::ProcessVertices(UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,D3D8Wrapper::IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags)714{715LOG("IDirect3DDevice8::ProcessVertices( " << SrcStartIndex << " , " << DestIndex << " , " << VertexCount << " , " << pDestBuffer << " , " << Flags << " ) [ " << this << " ]\n");716if (pDestBuffer == NULL)717{718return m_pDevice->ProcessVertices(SrcStartIndex,DestIndex,VertexCount,NULL,Flags);719}720else721{722return m_pDevice->ProcessVertices(SrcStartIndex,DestIndex,VertexCount,pDestBuffer->GetVertexBuffer(),Flags);723}724}725726STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::CreateVertexShader(CONST DWORD* pDeclaration,CONST DWORD* pFunction,DWORD* pHandle,DWORD Usage)727{728LOG("IDirect3DDevice8::CreateVertexShader( " << pDeclaration << " , " << pFunction << " , " << pHandle << " , " << Usage << " ) [ " << this << " ]\n");729return m_pDevice->CreateVertexShader(pDeclaration,pFunction,pHandle,Usage);730}731732STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetVertexShader(DWORD Handle)733{734LOG("IDirect3DDevice8::SetVertexShader( " << Handle << " ) [ " << this << " ]\n");735return m_pDevice->SetVertexShader(Handle);736}737738STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetVertexShader(DWORD* pHandle)739{740LOG("IDirect3DDevice8::GetVertexShader( " << pHandle << " ) [ " << this << " ]\n");741return m_pDevice->GetVertexShader(pHandle);742}743744STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::DeleteVertexShader(DWORD Handle)745{746LOG("IDirect3DDevice8::DeleteVertexShader( " << Handle << " ) [ " << this << " ]\n");747return m_pDevice->DeleteVertexShader(Handle);748}749750STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetVertexShaderConstant(DWORD Register,CONST void* pConstantData,DWORD ConstantCount)751{752LOG("IDirect3DDevice8::SetVertexShaderConstant( " << Register << " , " << pConstantData << " , " << ConstantCount << " ) [ " << this << " ]\n");753return m_pDevice->SetVertexShaderConstant(Register,pConstantData,ConstantCount);754}755756STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetVertexShaderConstant(DWORD Register,void* pConstantData,DWORD ConstantCount)757{758LOG("IDirect3DDevice8::GetVertexShaderConstant( " << Register << " , " << pConstantData << " , " << ConstantCount << " ) [ " << this << " ]\n");759return m_pDevice->GetVertexShaderConstant(Register,pConstantData,ConstantCount);760}761762STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetVertexShaderDeclaration(DWORD Handle,void* pData,DWORD* pSizeOfData)763{764LOG("IDirect3DDevice8::GetVertexShaderDeclaration( " << Handle << " , " << pData << " , " << pSizeOfData << " ) [ " << this << " ]\n");765return m_pDevice->GetVertexShaderDeclaration(Handle,pData,pSizeOfData);766}767768STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetVertexShaderFunction(DWORD Handle,void* pData,DWORD* pSizeOfData)769{770LOG("IDirect3DDevice8::GetVertexShaderFunction( " << Handle << " , " << pData << " , " << pSizeOfData << " ) [ " << this << " ]\n");771return m_pDevice->GetVertexShaderFunction(Handle,pData,pSizeOfData);772}773774STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetStreamSource(UINT StreamNumber,D3D8Wrapper::IDirect3DVertexBuffer8* pStreamData,UINT Stride)775{776LOG("IDirect3DDevice8::SetStreamSource( " << StreamNumber << " , " << pStreamData << " , " << Stride << " ) [ " << this << " ]\n");777if (pStreamData == NULL)778{779return m_pDevice->SetStreamSource(StreamNumber,NULL,Stride);780}781else782{783return m_pDevice->SetStreamSource(StreamNumber,pStreamData->GetVertexBuffer(),Stride);784}785}786787STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetStreamSource(UINT StreamNumber,D3D8Wrapper::IDirect3DVertexBuffer8** ppStreamData,UINT* pStride)788{789LOG("IDirect3DDevice8::GetStreamSource( " << StreamNumber << " , " << ppStreamData << " , " << pStride << " ) [ " << this << " ]\n");790791D3D8Base::IDirect3DVertexBuffer8* realD3D = NULL;792793HRESULT hr = m_pDevice->GetStreamSource(StreamNumber,&realD3D,pStride);794795D3D8Wrapper::IDirect3DVertexBuffer8* wrappedD3D = new D3D8Wrapper::IDirect3DVertexBuffer8(realD3D);796797*ppStreamData = wrappedD3D;798799return hr;800}801802STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetIndices(D3D8Wrapper::IDirect3DIndexBuffer8* pIndexData,UINT BaseVertexIndex)803{804LOG("IDirect3DDevice8::SetIndices( " << pIndexData << " , " << BaseVertexIndex << " ) [ " << this << " ]\n");805if (pIndexData == NULL)806{807return m_pDevice->SetIndices(NULL,BaseVertexIndex);808}809else810{811return m_pDevice->SetIndices(pIndexData->GetIndexBuffer(),BaseVertexIndex);812}813}814815STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetIndices(D3D8Wrapper::IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex)816{817LOG("IDirect3DDevice8::GetIndices( " << ppIndexData << " , " << pBaseVertexIndex << " ) [ " << this << " ]\n");818819D3D8Base::IDirect3DIndexBuffer8* realD3D = NULL;820821HRESULT hr = m_pDevice->GetIndices(&realD3D,pBaseVertexIndex);// ppIndexData,pBaseVertexIndex);822823D3D8Wrapper::IDirect3DIndexBuffer8* wrappedD3D = new D3D8Wrapper::IDirect3DIndexBuffer8(realD3D);824825*ppIndexData = wrappedD3D;826827return hr;828}829830STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::CreatePixelShader(CONST DWORD* pFunction,DWORD* pHandle)831{832LOG("IDirect3DDevice8::CreatePixelShader( " << pFunction << " , " << pHandle << " ) [ " << this << " ]\n");833return m_pDevice->CreatePixelShader(pFunction,pHandle);834}835836STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetPixelShader(DWORD Handle)837{838LOG("IDirect3DDevice8::SetPixelShader( " << Handle << " ) [ " << this << " ]\n");839return m_pDevice->SetPixelShader(Handle);840}841842STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetPixelShader(DWORD* pHandle)843{844LOG("IDirect3DDevice8::GetPixelShader( " << pHandle << " ) [ " << this << " ]\n");845return m_pDevice->GetPixelShader(pHandle);846}847848STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::DeletePixelShader(DWORD Handle)849{850LOG("IDirect3DDevice8::DeletePixelShader( " << Handle << " ) [ " << this << " ]\n");851return m_pDevice->DeletePixelShader(Handle);852}853854STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::SetPixelShaderConstant(DWORD Register,CONST void* pConstantData,DWORD ConstantCount)855{856LOG("IDirect3DDevice8::SetPixelShaderConstant( " << Register << " , " << pConstantData << " , " << ConstantCount << " ) [ " << this << " ]\n");857return m_pDevice->SetPixelShaderConstant(Register,pConstantData,ConstantCount);858}859860STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetPixelShaderConstant(DWORD Register,void* pConstantData,DWORD ConstantCount)861{862LOG("IDirect3DDevice8::GetPixelShaderConstant( " << Register << " , " << pConstantData << " , " << ConstantCount << " ) [ " << this << " ]\n");863return m_pDevice->GetPixelShaderConstant(Register,pConstantData,ConstantCount);864}865866STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::GetPixelShaderFunction(DWORD Handle,void* pData,DWORD* pSizeOfData)867{868LOG("IDirect3DDevice8::GetPixelShaderFunction( " << Handle << " , " << pData << " , " << pSizeOfData << " ) [ " << this << " ]\n");869return m_pDevice->GetPixelShaderFunction(Handle,pData,pSizeOfData);870}871872STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::DrawRectPatch(UINT Handle,CONST float* pNumSegs,CONST D3D8Base::D3DRECTPATCH_INFO* pRectPatchInfo)873{874LOG("IDirect3DDevice8::DrawRectPatch( " << Handle << " , " << pNumSegs << " , " << pRectPatchInfo << " ) [ " << this << " ]\n");875return m_pDevice->DrawRectPatch(Handle,pNumSegs,pRectPatchInfo);876}877878STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::DrawTriPatch(UINT Handle,CONST float* pNumSegs,CONST D3D8Base::D3DTRIPATCH_INFO* pTriPatchInfo)879{880LOG("IDirect3DDevice8::DrawTriPatch( " << Handle << " , " << pNumSegs << " , " << pTriPatchInfo << " ) [ " << this << " ]\n");881return m_pDevice->DrawTriPatch(Handle,pNumSegs,pTriPatchInfo);882}883884STDMETHODIMP D3D8Wrapper::IDirect3DDevice8::DeletePatch(UINT Handle)885{886LOG("IDirect3DDevice8::DeletePatch( " << Handle << " ) [ " << this << " ]\n");887return m_pDevice->DeletePatch(Handle);888}889}890}891892