|
|
请问:
LPDIRECT3DSURFACE9 g_pSDepth;
D3DLOCKED_RECT LockedRect;
g_pSDepth-> LockRect(&LockedRect, 0,0);
D3DSURFACE_DESC surfaceDesc;
g_pSDepth->GetDesc(&surfaceDesc);
DWORD* imageData = (DWORD*)LockedRect.pBits;
for( i = 0; i < surfaceDesc.Height; i++)
{
for(DWORD j = 0; j < surfaceDesc.Width; j++)
{
int index = i * LockedRect.Pitch / 4 + j;
imageData[3] = 0xffff0000;
}
}
为什么能够编译,但是运行时总是出现内存错误呢。
是不是SURFACE是如何初始化,是
LPDIRECT3DTEXTURE9 g_pTDepth;
D3DXCreateTexture( g_pd3dDevice,
800,
600,
D3DUSAGE_RENDERTARGET,
D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT,
& g_pTDepth );
g_pTDepth->GetSurfaceLevel(0,&g_pSDepth);
这样吗?
不然怎么确定surface的format呢?
如果要用这个surface来储存z-buffer信息该怎么做呢?
小弟愚笨还请各位大侠指点啊
[em4] [em4] [em4] |
|