Jump to content
  • Advertisement
Sign in to follow this  
brekehan

texture.lock - c#

This topic is 4327 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 overall goal is to get a rectangular portion of my texture and make another texture of it. I saw that texture.lock takes a rect as a parameter, but it keeps failing with an invalid call exception. Does anyone have an example of how to do this whether it be with this function or another? 1 ) Load a texture from file 2 ) Grab a rect from it 3 ) make a new texture from that rect

Share this post


Link to post
Share on other sites
Advertisement
the way I do it is probably not the best way. But I create a new texture, and a RenderToTexture object, then just draw a quad from your source texture onto it.


Texture t = new Texture(device, surfaceWidth, surfaceHeight, 1, Usage.None,Format.A8R8G8B8, Pool.Managed);

Direct3D.Surface surfaceTarget = t.GetSurfaceLevel(0);
renderToSurface = new RenderToSurface(device, SurfaceWidth, SurfaceHeight, Format.A8R8G8B8, false, DepthFormat.D16);

Viewport vp = new Viewport();

vp.X = 0;
vp.Y = 0;
vp.Width = surfaceWidth;
vp.Height = surfaceHeight;

renderToSurface.BeginScene(surfaceTarget, vp);

// draw quad here

renderToSurface.EndScene();

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!