Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About fanwenjie

  • Rank

Personal Information

  • Interests
  1. fanwenjie

    Querying the depth buffer

    I hack the struct of IDirect3DSurface9 and disassembly it,Find that if the Lockable bit is 0, LockRect will return failed!. You can lock all format of Surface by setting Lockable bit to 1! typedef struct { LPVOID lpVtbl; PHANDLE pSharedHandle; D3DFORMAT TextureFormat; D3DRESOURCETYPE Type; struct { DWORD Flag0 : 26; DWORD Lockable : 1; DWORD Flag1 : 5; } CPUAccessFlags; DWORD Unknown; D3DMULTISAMPLE_TYPE MultiSampleType; DWORD MultiSampleQuality; UINT Width; UINT Height; D3DPOOL Pool; D3DFORMAT Format; }Direct3DSurface9; void GrabZStencilSurface(IDirect3DDevice9 *pDevice) { IDirect3DSurface9 *pZStencilSurface = NULL; pDevice->GetDepthStencilSurface(&pZStencilSurface); ((Direct3DSurface9 *)pZStencilSurface)->CPUAccessFlags.Lockable = 1; D3DLOCKED_RECT lockRect = { 0 }; pZStencilSurface->LockRect(&lockRect, NULL, D3DLOCK_READONLY); void *pData = lockRect.pBits; //TODO: Grab Depth Stencil Data pZStencilSurface->UnlockRect(); pZStencilSurface->Release(); }
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!