Jump to content
  • Advertisement
Sign in to follow this  
lomateron

creating 2D texture questions

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

why when CreateTexture2D() with a D3D10_SUBRESOURCE_DATA

why does D3D10_SUBRESOURCE_DATA needs SysMemPitch and SysMemSlicePitch, isn't that already defined in D3D10_TEXTURE2D_DESC width,height?

 

What if in D3D10_SUBRESOURCE_DATA's pSysMem I put a chunk of memory that is smaller than the texture size and I call CreateTexture2D()

, does the texture is created correctly with the chunk of memory that I put and the rest of the pixels in 0?

 

Share this post


Link to post
Share on other sites
Advertisement

why when CreateTexture2D() with a D3D10_SUBRESOURCE_DATA

why does D3D10_SUBRESOURCE_DATA needs SysMemPitch and SysMemSlicePitch, isn't that already defined in D3D10_TEXTURE2D_DESC width,height?


Not quite. The pitch defines how your texture rows (and slices) are laid out in memory. Granted you can pack it tightly, so e.g. SysMemPitch is actually width * size of texel.
 

What if in D3D10_SUBRESOURCE_DATA's pSysMem I put a chunk of memory that is smaller than the texture size and I call CreateTexture2D(), does the texture is created correctly with the chunk of memory that I put and the rest of the pixels in 0?


That doesn't sound like a good idea. You could try it, but I expect some access violation or something.

Share this post


Link to post
Share on other sites
What if in D3D10_SUBRESOURCE_DATA's pSysMem I put a chunk of memory that is smaller than the texture size and I call CreateTexture2D()

, does the texture is created correctly with the chunk of memory that I put and the rest of the pixels in 0?

Like any other C++ library, D3D has no way of knowing whether some data you pass it is "valid" or "invalid". If you give it a pointer to data that's smaller than what it expects, then it will read right past the end of that data and pull in garbage data (and quite possibly cause an access violation, like unbird mentioned).

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!