Original Post
🔒 Locked
RenderTarget
Advertisement
You can easily do this with IDirect3DDevice::GetRenderTarget() and IDirect3DDevice::SetRenderTarget(). Actually, the D3DX interface is just a wrapper around these calls.
The following sample code renders the scene to a cubemap:
The following sample code renders the scene to a cubemap:
// Get the current rendertarget, keep it for later LPDIRECT3DSURFACE9 RTOld = NULL; VERIFY( d3dDevice->GetRenderTarget( 0, &RTOld ) ); // Iterate through each cube face for( int nFace = 0; nFace < 6; ++nFace ) { LPDIRECT3DSURFACE9 pSurf; // Obtain the surface of the cubemap VERIFY( d3dCubeMap->GetCubeMapSurface( (D3DCUBEMAP_FACES)nFace, 0, &pSurf ) ); // Set the rendertarget to the cubemap's surface VERIFY( d3dDevice->SetRenderTarget( 0, pSurf ) ); SafeRelease( pSurf ); // Build the viewing matrix for this particular face D3DXMATRIXA16 mView = GetCubeMapViewMatrix( nFace ); D3DXMatrixMultiply( &mView, &mViewDir, &mView ); // Clear the device VERIFY( d3dDevice->Clear( 0L, NULL, D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0L ) ); // Begin the scene if( SUCCEEDED( d3dDevice->BeginScene() ) ) { // Re-render the world again RenderWorld(); // End the scene. d3dDevice->EndScene(); } } // Restore the old render target VERIFY( d3dDevice->SetRenderTarget( 0, RTOld ) );Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement