Jump to content
  • Advertisement
Sign in to follow this  
MTclip

Render to Texture..???

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

What is the exact process to render to a texture.. is it necessary to render to a separate SURFACE .. then send that to the texture.. or is there a way to render directly to the texture ... any good links would be nice .....

Share this post


Link to post
Share on other sites
Advertisement
yeah... that was one of my refrences.... Ive got it to work
first rendering to a separate SURFACE then setting the TEXTURE to the SURFACE and then drawing the TEXTURE to a QUAD on the back buffer.....

but when i do this.. after a while about 5 seconds the texture starts to mess up.. I am still looking in to this... ( i think i may have to do with on of the sprites i have moving around)

Also i read some where that you can turn of the stencil buffer...

and finally is it possible to render directly to a TEXTURE and skip the surface part???



.......:[]p

Share this post


Link to post
Share on other sites
MTclip,

You might try this. Create a texture with the usage flag set to D3DUSAGE_RENDERTARGET.

Then when you want to render to the texture call the following two functions:

IDirect3DTexture9::GetSurfaceLevel( UINT Level, IDirect3DSurface9 **ppSurfaceLevel );

This will return to you an IDirect3DSurface9*. Then pass the surface into the following function before rendering:

IDirect3DDevice9::SetRenderTarget( DWORD RenderTargetIndex, IDirect3DSurface9 *pRenderTarget );

If all works as I'd imagine in a perfect world, the surface of the texture should be set as a current render target and after rendering should contain what you'd want it to contain. Hope this works!

Share this post


Link to post
Share on other sites
I do the same thing with DirectX 8, and it works fine. A word of caution: remember to cache the pointer to your back-buffer so you can reset it as the default render target when you're done drawing to your texture.

Share this post


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

  • 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!