Skip to main content
gamedev.net
🔒 Locked

RenderTarget

Started by JoeLaBanane Sep 14, 2005 at 7:54 AM 3 replies 900+ views
Original Post
JoeLaBanane
JoeLaBanane
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.
Evil Steve
Evil Steve
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.
circlesoft
circlesoft
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 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]
PAiNIC
PAiNIC
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

Topic Locked

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

Sign in to reply to this topic.