티스토리 뷰
http://www.gpgstudy.com/forum/viewtopic.php?t=4297
위의 URL참조.
m_pd3dDevice->CreateTexture( 128,128, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_pGlareTexture, NULL);
LPDIRECT3DSURFACE9 pBackBuffer=NULL;
m_pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
m_pGlareTexture->GetSurfaceLevel(0,&m_pGlareTargetSurface);
m_pd3dDevice->StretchRect( pBackBuffer, NULL, m_pGlareTargetSurface, NULL, D3DTEXF_NONE );
gpg에서 말한것 처럼 아래되로 하니 되긴함..
D3DLOCKED_RECT Rect;
m_pGlareTexture->LockRect(0, &Rect, NULL,dwFlag);
LPBYTE pPixel = (LPBYTE) Rect.pBits;
이때 Rect의 피치랑 데이터값이 NULL이다.
문제는 DX도움말에서는 D3DPOOL_DEFAULT에서는 Lock이 되지 않는다고 한다..
그래서 RendertargetTexture를 시스템 메모리에 있는 텍스쳐로 복사를 하라는...
LPDIRECT3DSURFACE9 pSurface = NULL;
// make surface in System Pool
m_pd3dDevice->CreateOffscreenPlainSurface( RENDERTARGETSIZE, RENDERTARGETSIZE, D3DFMT_R32F, D3DPOOL_SYSTEMMEM, &pSurface, NULL );
// Copy render target surface to pSurface
hr = m_pd3dDevice->GetRenderTargetData( pRenderTarget, pSurface );
if( FAILED(hr) ) return hr;
// Lock (in Sys mem) and Read ...
D3DLOCKED_RECT Rect;
hr = pSurface->LockRect( &Rect, 0, D3DLOCK_READONLY );
if( FAILED(hr) ) return hr;
for( UINT v=0; v<RENDERTARGETSIZE; v++ ) {
for( UINT u=0; u<RENDERTARGETSIZE; u++ ) {
BackArray[v][u] = ((float*)Rect.pBits)[u];
}
Rect.pBits = (BYTE*)Rect.pBits + Rect.Pitch;
}
pSurface->UnlockRect();
pSurface->Release();
'DirectX' 카테고리의 다른 글
디바이스 로스트 (0) | 2014.11.27 |
---|---|
셰이더 컴파일 (0) | 2014.07.31 |
D3DPOOL (0) | 2014.07.22 |
D3DXVec3CatmullRom (0) | 2014.07.15 |