Jump to content
  • Advertisement
Sign in to follow this  
Grdman

fastest way to copy textures?

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

My question is simple: I have 2 D3DTextures and I want one of them to be copied to a part of the other, what is the fastest way to do this? Right now Im just setting the target texture as rendering target and renders the source on it. I have found other ways to do it in the DirectX documantation but I dont know if any of them will improve my preformance. Both the textures must be created with the D3DUSAGE_RENDERTARGET flag because Im using them as render targets in other parts of the program.

Share this post


Link to post
Share on other sites
Advertisement
I think your only option is IDirect3DDevice9::StretchRect. I'm not sure about the performance of it, but to make it as fast as possible, I'd use the same size rect for src and dest, and use D3DTEXF_NONE as the filter type.

What are you trying to do, though? There might be a more efficient way to do what you want.

Share this post


Link to post
Share on other sites
Thanx that works, still dont know if its that mutch faster though.

Im working on a GUI in 3D, that is I have a lot of windows that can be positioned and turned in 3D space, in those windows there can be other windows positioned in a sub space.

So what Im doing is rendering a window on a D3D surface and I render that surface on another and finally to the screen.

Share this post


Link to post
Share on other sites
I see.. however, wouldn't it be more efficient simply to draw all the windows directly to the screen? As in, you'd draw the parent window, and then all the child windows in front of it?

Share this post


Link to post
Share on other sites
Quote:
Original post by Drakex
I see.. however, wouldn't it be more efficient simply to draw all the windows directly to the screen? As in, you'd draw the parent window, and then all the child windows in front of it?


This requires you to re-render each window each frame though. If you have one RT per window (a window contains all of the individual controls, like command buttons and text boxes and labels), then you can render the window to its RT when needed. Then, just render the RT to the backbuffer as a textured quad.

This is pretty efficient, as you only draw the window when it is updated. Like this:

if( isUpdated )
{
RenderWindow(); // Render the window to its RT
DrawQuad(); // Draw the RT as a quad to the backbuffer
}
else
{
DrawQuad(); // No window rendering needed
}

In most situations, rendering a texture to another is faster than copying it through APIs like StretchRect or UpdateTexture.

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!