|
|
我先通过
GetDepthStencilSurface 获得当前深度surface
然后想通过LockRect()和 UnlockRect()对其直接进行操作 不知道为什么只要一访问这片内存就会出错
求高手帮忙
代码如下:
if(Moo::RenderTarget::pNewDS!=NULL)
{
D3DSURFACE_DESC surfaceDesc;
D3DLOCKED_RECT lockedRect;
Moo::RenderTarget::pNewDS->GetDesc(&surfaceDesc);
Moo::RenderTarget::pNewDS->LockRect(&lockedRect,0,0);
DWORD* imageDate = (DWORD*)lockedRect.pBits;
int index;
for (UINT i=0;i < surfaceDesc.Width;i++)
{
for (UINT j=0;j<surfaceDesc.Height;j++)
{
index=i*lockedRect.Pitch/4+j;
if(j>10 && j<20)
imageDate[index]=0x0;
}
}
Moo::RenderTarget::pNewDS->UnlockRect();
}
说明一下深度缓冲格式是 d24x8
其中Moo::RenderTarget::pNewDS 是depthstencilsurface 指针 |
|