Jump to content
  • Advertisement
Sign in to follow this  
walsh06

Copy Texture2D

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

Im currently trying to make part of one Texture onto another. I think it has something to do with GetData but I cant figure out how to make it work.

The basic idea is I want to make a texture become a certain rectangle of another texture. Any help would be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
I'd use SpriteBatch to render your first Texture2D onto a new RenderTarget, render your clipped second Texture2D on top, then cast the RenderTarget onto a final Texture2D which will be the combination of the two original textures.

Share this post


Link to post
Share on other sites
if you only want to copy a part of a texture to another, without any change in location of the rect, and both are of the same format, you can use CopySubresourceRegion.

Share this post


Link to post
Share on other sites

I'd use SpriteBatch to render your first Texture2D onto a new RenderTarget, render your clipped second Texture2D on top, then cast the RenderTarget onto a final Texture2D which will be the combination of the two original textures.

I have to admit I dont really understand what are you saying. Could you explain it in a bit more detail.

Share this post


Link to post
Share on other sites

[quote name='PhillipHamlyn' timestamp='1343150850' post='4962668']
I'd use SpriteBatch to render your first Texture2D onto a new RenderTarget, render your clipped second Texture2D on top, then cast the RenderTarget onto a final Texture2D which will be the combination of the two original textures.

I have to admit I dont really understand what are you saying. Could you explain it in a bit more detail.
[/quote]
Just look at ATEFred's suggestion! Here is the MSDN-page for what he suggested.

http://msdn.microsoft.com/en-us/library/windows/desktop/ff476394%28v=vs.85%29.aspx

Share this post


Link to post
Share on other sites
But he said that the rectangle has to stay the same. I assumed that means the texture2D cant change location. Am I wrong in thinking that??

Share this post


Link to post
Share on other sites
He meant that the contents of the rectangle you specify will be exactly the same in the new texture. However, you will copy the data from one texture to another. Try it!

Share this post


Link to post
Share on other sites
Oh ok, So with my code Im displaying the Texture and then I want a 100x200 square to be copied to a new texture. This is determined by where the user clicks. So how do i implement the click into it.

Share this post


Link to post
Share on other sites
Well, that's a completely different question. DirectInput is deprecated after DirectX 8, but it's still works well for normal keyboard and mouse operations. I'd recommend you to take a look at Rasterteks DirectInput tutorial.

There is also XInput, which is supposed to replace DirectInput, but as far as I know, it can't handle mice devices.

Share this post


Link to post
Share on other sites
well basically I was creating a rectangle around their click and I want to copy the texture thats inside that rectangle. So do I have to do something different??

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!