• Advertisement
Sign in to follow this  

a RenderTarget Larger than Window Size

This topic is 3967 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just render the whole scene to a target texture 1.25 times wider than the window/backbuffer size,and then use it as the texture of a Quad to render it to the backbuffer. Bu doing so, I can get 1.25 times more pixels in the window client -- it's needed for some visual effect. Also,it is much like the "PostProcessing" d3d sample and also runs in a dxut framework. However, to my surprise, I got a lot of black pixels in right/bottom of the final window client.It looks only the right bottom of the off-screen render target is cliped... much like that: --------------------------------- |-- shrinked--------|BBBBBBBBBBBB| |----game scene-----|BBBBBBBBBBBB| |-------------------|BBBBBBBBBBBB| |-------------------|BBBBBBBBBBBB| |-------------------|BBBBBBBBBBBB| |-------------------|(640,480)BBB| |BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB| --------------------------------- (800,600) It looks like D3D only render a (800,600) rect of pixel to my (1000,750) off-screen texture and then when I render it back to screen it's (640,480)... what will cause that to happen? anyone have some hint? Thanks alot! ============================================================================ code fragment: OnCreateDevice: V_RETURN( pd3dDevice->CreateTexture( 1000, 750, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pSceneSave, NULL ) ); OnFrameRender: (1)1st pass IDirect3DSurface9* pSurface = NULL; V(g_pSceneSave->GetSurfaceLevel(0, &pSurface)); V(pd3dDevice->SetRenderTarget(0,pSurface)); V(pd3dDevice->Clear(0,NULL,D3DCLEAR_TARGET| D3DCLEAR_ZBUFFER,D3DCOLOR_ARGB(0,0xff,0,0),1.0f,0)); D3DVIEWPORT9 vport; vport.Width = 1000; vport.Height = 750; vport.X = vport.Y = 0; vport.MinZ = 0.f; vport.MaxZ = 1.f; V(pd3dDevice->SetViewport(&vport)); [Render game scene... etc] (2)2nd pass PPVERT Quad[4] = { { -0.5f, -0.5f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f }, { pd3dsdBackBuffer->Width-0.5f, -0.5, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f }, { -0.5, pd3dsdBackBuffer->Height-0.5f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f }, { pd3dsdBackBuffer->Width-0.5f, pd3dsdBackBuffer->Height-0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f } [CreateVertexBuffer etc] pd3dDevice->SetTexture(0, g_pSceneSave); pd3dDevice->SetTexture(1, 0); pd3dDevice->SetStreamSource( 0, pVB, 0, sizeof(PPVERT) ); pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );

Share this post


Link to post
Share on other sites
Advertisement
Do you CreateDepthStencilSurface to create a new depth buffer to match your new render target? You should. The debug runtimes would probably be screaming at you if you enabled them. This is probably causing the SetViewport to fail, which then means you're drawing to the old viewport dimensions. You'll need code to restore the viewport back when you switch the render target and depth buffer back to the one's from the device. You should save the depth surface pointer when you create or reset the device, as I don't think there is any way to obtain the pointer after you've activated your other depth buffer.

Share this post


Link to post
Share on other sites
quite right!!!
After I manually create a bigger depth buufer to the d3d device,
it now works properly!!

thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement