Advertisement Jump to content
Sign in to follow this  
Halsafar

bit array to d3d texture surface

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

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!