Jump to content
  • Advertisement
Sign in to follow this  
JoeLaBanane

RenderTarget

This topic is 4806 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! I want to blit some textures to a RenderTarget texture with Alpha. Then, I remove that texture as "current" render target and I need to blit it to an other texture or surface, with alpha blending. I create my texture with CreateTexture(D3DUSAGE_RENDERTARGET & D3DPOOL_DEFAULT) but the problem is that D3DPOOL_DEFAULT dont allow us to lock to direct acces bitmap. D3DUSAGE_RENDERTARGET seem not compatible with D3DPOOL_MANAGED. I abslolutly need to be able to direct acces my RenderTarget texture bits. Any idea? Thanks, Joe.

Share this post


Link to post
Share on other sites
Advertisement
You need to create the texture with the D3DUSAGE_DYNAMIC flag. I'm not entirely sure if you can use that flag with the D3DUSAGE_RENDERTARGET flag though.

If you can't then you might need to use IDirect3DDevice9::StretchRect() to copy between the D3DPOOL_DEFAULT texture and a D3DPOOL_SYSTEMMEM texture, then lock the system memory copy.

Share this post


Link to post
Share on other sites
This approach will be horribly slow and inefficient. Since you already have a render-target, why don't you just render the textures directly to it? This will totally avoid locking and copying data.

Have you used ID3DXSprite before? If not, it's really nice - it lets you render textures very easily (check out <ahref="http://www.codesampler.com/dx9src/dx9src_8.htm#dx9_d3dxsprite">this</a. tutorial). All you need to do is use Sprite to render your textures to your render target. Something like this:

SetRenderTarget( renderTarget );

sprite->Draw2D( 50, 50, texture1 );
sprite->Draw2D( 500, 500, texture2 );
sprite->Draw2D( 350, 200, texture3 );

This will be *tons* faster. And it's a lot less code too [smile]

Share this post


Link to post
Share on other sites
Alternatively, create two textures using D3DUSAGE_RENDERTARGET flags and the same dimensions and formats. Then:
Set one of the textures to the Render Target and render
Swap the pointers to the two textures
Set the Render Target to something else
Render a textured quad with the ex-rendertarget as the texture

This would also be much faster than a DYNAMIC rendertarget or a LOCKABLE rendertarget

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!