Jump to content
  • Advertisement
Sign in to follow this  
ReaVeR-Andrey

[solved] Render to a texture

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

Advertisement
What is it you're really trying to do? Do you really need to render to a texture, or are you thinking that's the way to accomplish something specific? Maybe there is another way to do it.

Although, rendering to a texture does sound kind of cool

Share this post


Link to post
Share on other sites
1) Create a texture that can be used as a render target:
LPDIRECT3DTEXTURE9 texture = NULL;
pd3dDevice->CreateTexture(size.x, size.y, 1, D3DUSAGE_RENDERTARGET, A8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);

2) Set that texture as render target:
pd3dDevice->SetRenderTarget(0, texture);

3) Render something (shaders or fixed function)

You can then restore the original "default" render target by passing null to SetRenderTarget and you can then set "texture" as a source texture for future renderings.

Hope this helps

- Kasper

Share this post


Link to post
Share on other sites
Ah, sorry - you cannot restore the original render targets by passing NULL (this is only the syntax I've used for my own wrapping of D3D). You have to get a hold of the current render target before setting the texture render target:

LPDIRECT3DSURFACE9 primarySurface;
pd3dDevice->GetRenderTarget(0, &primarySurface);

Then re-set "primarySurface" once you're done rendering into the texture

- Kasper

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!