fastest way to copy textures?

Started by
3 comments, last by circlesoft 18 years, 8 months ago
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.
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.
_______________________________________________________________________Hoo-rah.
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.
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?
_______________________________________________________________________Hoo-rah.
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.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )

This topic is closed to new replies.

Advertisement