Greetings all,
Thought I'd share this little D3D code hack... With this code, you can watch how the values you render are processed/stored.
Basically, after the code locks the depth and the back buffer, it just unlocks them, but if you keep an eye in the Watch window of Visual Studio, you'll see that the pointers in the D3DLOCKED_RECT structs are still valid. And as you issue DP calls, you'll see directly how the values change...
Just keep in mind, it's a hack, and it always works with RefRast only!
#define D3D_DEBUG_INFO #include <d3d9.h> #pragma comment(lib,"d3d9") struct VTX { float x,y,z,rhw; D3DCOLOR clr; }; void main(void) { LPDIRECT3D9 pD3D = Direct3DCreate9(D3D_SDK_VERSION); D3DPRESENT_PARAMETERS pp; memset(&pp,0,sizeof(pp)); pp.BackBufferWidth = 124; pp.BackBufferHeight = 164; pp.BackBufferFormat = D3DFMT_A8R8G8B8; pp.EnableAutoDepthStencil = TRUE; pp.AutoDepthStencilFormat = D3DFMT_D32F_LOCKABLE; pp.hDeviceWindow = GetDesktopWindow(); pp.SwapEffect = D3DSWAPEFFECT_DISCARD; pp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; pp.Windowed = TRUE; LPDIRECT3DDEVICE9 pDevice = NULL; pD3D->CreateDevice(0,D3DDEVTYPE_REF,GetDesktopWindow(),D3DCREATE_HARDWARE_VERTEXPROCESSING,&pp,&pDevice); pDevice->SetRenderState(D3DRS_ZENABLE,TRUE); pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_ALWAYS); pDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET,0,0,0); pDevice->BeginScene(); LPDIRECT3DSURFACE9 pDepth = NULL; LPDIRECT3DSURFACE9 pBB = NULL; pDevice->GetDepthStencilSurface(&pDepth); pDevice->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&pBB); D3DLOCKED_RECT rcLock1; pDepth->LockRect(&rcLock1,NULL,D3DLOCK_READONLY); pDepth->UnlockRect(); D3DLOCKED_RECT rcLock2; pBB->LockRect(&rcLock2,NULL,D3DLOCK_READONLY); pBB->UnlockRect(); VTX tri[3] = { 0,0, .99, 1, 0xFF0000FF, 120,0, .99, 1, 0xFF0000FF, 0,120, .99, 1, 0xFF0000FF, }; pDevice->SetFVF(D3DFVF_XYZRHW|D3DFVF_DIFFUSE); pDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST,1,tri,sizeof(VTX)); pDevice->EndScene(); pBB->Release(); pDepth->Release(); pDevice->Release(); pD3D->Release(); } |

A code snippet for testing