Sign in to follow this  
Halsafar

bit array to d3d texture surface

Recommended Posts

Is it possible to create a blank texture, get its surface, lock it, and copy bits to it? Specifically, when I lock it, do I get an array which is sized n^2, every 4 elements being rgba?

Share this post


Link to post
Share on other sites
When you lock a surface, you get a pointer to it's first scanline of data. The pitch (AKA memory width AKA memory distance between lines) of a scanline may vary, but you get that also when you lock the surface.

To fill the texture, loop through the scanlines (count of which is the surface height), and multiply the current scanline number by the pitch to obtain pointers for each individual scanline. In the inner loop, go through each pixel of the scanline - the amount of valid pixels is exactly equal to the surface's pixel width.

The type of data is determined from the texture format - you don't automatically get ARGB32 values, unless your surface format happens to actually be ARGB32.

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