Skip to main content
gamedev.net
🔒 Locked

Direct3D9 SetRenderTarget usage

Started by miodragsm 1 reply 4.2k views
Original Post
miodragsm
miodragsm
How is rendering into texture done in d3d9? ( IDirect3DDevice9::SetRenderTarget() ??? ) Example? Any link would help.
IFooBar
IFooBar
You can render to a texture as follows:

1 Get the surface (IDirect3DSurface9) interface of the texture you want to render to
2 Get the old surface that is currently being rendered to
3 Set the texture''s surface as the render target
4 Render stuff as usual
5 When done, set the old surface as the render target


IDirect3DSurface9* pSurf, *pOldTarget;

// 1

pTexture->GetSurfaceLevel( 0, &pSurf );

// 2

pDevice->GetRenderTarget( 0, &pOldTarget );

// 3

pDevice->SetRenderTarget( pSurf );

// 4


// 5

pDevice->SetRenderTarget( pOldTarget );

// Dont forget to release surface

pSurf->Release();
pOldTarget->Release();


I dont believe Im forgetting anything...


| TripleBuffer Software |
| Plug-in Manager :: DX Utility Engine :: C++ Debug Kit :: DirectX Tutorials :: Awesome Books |
[size=2]aliak.net
miodragsm
miodragsm
Thanks IFooBar.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.