RenderTexture?
I would like to be able to render into a texture under DirectX9 i made a simple RenderTexture class however I am not sure on how to tackle rendering to a 2D texture under DirectX10.
My first puny attempt seems to fail when I create the render target view using CreateRenderTarget in OnCreateDevice10, the methods BeginCapture are used to start rendering to a texture a to restore render target, respectively.
Any help is much appreciated,
/// class member data
ID3D10Texture2D* md_pMap;
ID3D10RenderTargetView* md_pRTV;
ID3D10RenderTargetView* apOldRTVs[1];
ID3D10DepthStencilView* pOldDS;
D3D10_VIEWPORT OldVP;
HRESULT CRenderTexture::OnCreateDevice10()
{
HRESULT hr;
D3D10_TEXTURE2D_DESC dt;
dt.Width = 256;
dt.Height = 256;
dt.Format = DXGI_FORMAT_R16G16B16A16_FLOAT;
dt.BindFlags = D3D10_BIND_RENDER_TARGET;
hr = DXUTGetD3D10Device()->CreateTexture2D(&dt, NULL, &md_pMap);
D3D10_RENDER_TARGET_VIEW_DESC dv;
dv.Format = dt.Format;
dv.ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2D;
DXUTGetD3D10Device()->CreateRenderTargetView(md_pMap, &dv, &md_pRTV);
}void CRenderTexture::BeginCapture()
{
DXUTGetD3D10Device()->OMGetRenderTargets( 1, apOldRTVs, &pOldDS );
DXUTGetD3D10Device()->RSGetViewports( &cRT, &OldVP );
float ClearColor[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
DXUTGetD3D10Device()->ClearRenderTargetView( md_pRTV, ClearColor);
DXUTGetD3D10Device()->OMSetRenderTargets(1, &md_pRTV, NULL);
}void CRenderTexture::EndCapture()
{
DXUTGetD3D10Device()->RSSetViewports( 1, &OldVP );
DXUTGetD3D10Device()->OMSetRenderTargets( 1, apOldRTVs, pOldDS );
SAFE_RELEASE( apOldRTVs[0] );
SAFE_RELEASE( pOldDS );
}
I am using Visual Studio 2005 Professional and Vista RC1 with DirectX August 2006 SDK release on a NV40 GPU.

