Sign in to follow this  

[SlimDX] Texture.LockRect

Recommended Posts

Tape_Worm    2807
It's been a very long time since I've touched this stuff, so bear with me if this is a dumb question.

I'm locking a region on a texture and attempting to dump an array of data into it. When I call the DataStream.Write(byte[], offset, size) method it appears to just dump the data in without respecting the region. The only thing that seems to be applied is the offset of the rect, the width/height don't seem to matter. Is this normal? How does the rectangular region specified in the LockRectangle parameter actually work when locking a texture?

I'm calling Texture.LockRectangle and passing in a rectangle of (100, 100)-(356, 356) to the rect parameter and passing no flags.

Here's a picture of what I'm seeing. The red area is the locked area (written one pixel at a time), the blue area is what happens when I just dump the array into the Write method:

[Edited by - Tape_Worm on December 5, 2010 2:23:47 PM]

Share this post

Link to post
Share on other sites
Erik Rufelt    5901
The Pitch of the returned structure must be taken into account, which says how many bytes are in each row. This may or may not be the same as the width of the rectangle, or even as the width of the whole texture (possible padding). You should be able to write a full row at a time however.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this