Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


DirectX9 , Render Targets

This topic is 5200 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

Hi again Not sure if i got this right (looked through the forum about render targets) This is what i do : 1) Create a Texture as a Render target and get the surface : D3DDevice9.CreateTexture(256 , 256, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, aTexture, nil); aTexture.GetSurfaceLevel(0, aSurface); 2) Save the old render target, to be restored later : D3DDevice9.GetRenderTarget(0, OTarget); D3DDevice9.GetDepthStencilSurface(ODepthBuffer); 3) Set a new Render Target : D3DDevice9.SetRenderTarget(0, aSurface); 4) Render stuff to new target. (While this steep, ZWRITEENABLE is False) 5) Restore to old target : D3DDevice9.SetRenderTarget(0, OTarget); D3DDevice9.SetDepthStencilSurface(ODepthBuffer); OTarget := nil; ODepthBuffer := nil; I do setup all render stages in 4) and restore them in 5) It all works fine, only one problem : When restoring the old Target, the data on it, is gone ! Rendering is done like this : 1. BeingScene 2. Render the enviorment (Terrain etc.) 3. Now do Render target stuff, see above. 4. Render the resulting textures from 3. 5. EndScene 6. Flip How come the OTarget gets its data deleted ? or can this method not be used ? [edited by - Mythar on May 20, 2004 2:49:30 AM]

Share this post

Link to post
Share on other sites
I''m just writing ideas, but you might want to try grabbing a reference to the render target when you Get() it (AddRef). The only reference this surface has is by the SetRenderTarget() function and if it gets called with a different target, it will dereference the old target (I think...). Just an idea...

Chris Pergrossi
My Realm | "Good Morning, Dave"

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!