Jump to content
  • Advertisement
Sign in to follow this  
devronious

Texture.LockRectangle problem...

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

I'm locking a rectangle on a texture that's 512x512. The rectangle that I want to lock is position = 25,25 and size = 50,50 so I call lock rectangle like this:
Rectangle area = new Rectangle(25,25,50,50);
Array a = tex.LockRectangle(typeof(int), 0, area, LockFlags.None, new int[] { area.Height, area.Width });

The problem I'm getting is that it paints bands rather than the entire rectangle. It seems to lock a region that is within the rectangle but the x and y indexes don't point to the proper pixels. Sometimes if I paint the entire rectangle then it will only paint a band on the top or bottom of the rectangle and sometimes the entire rectangle. Please help, Devin

Share this post


Link to post
Share on other sites
Advertisement
How are you writing data to the locked rectangle?

When writing, you need to use the Offset returned by the lock method as the "width of a row". This is because internally, DX might use a surface that's a different width from the area that was locked.

Hope this helps.

Share this post


Link to post
Share on other sites
I'm lost. The only thing returned is an array of data. To write to the array I just use Array.SetValue(data, y, x);

Any ideas? Perhaps it's a bug in mdx.

-Devin

Share this post


Link to post
Share on other sites
This method has several overloads, half of which have an out parameter that returns the pitch.

Like this:
int pitch;
Array a = tex.LockRectangle(typeof(int), 0, area, LockFlags.None, out pitch, new int[] { area.Height, area.Width });
Hope this helps.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What good is the pitch going to do when it returns an array that is bound to 2 dimensions?

I don't understand how that can be used.

Thanks for your help,

Devin

Share this post


Link to post
Share on other sites
What good is the pitch going to do when it returns an array that is bound to 2 dimensions?

I don't understand how that can be used.

Thanks for your help,

Devin

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!