Jump to content
  • Advertisement
Sign in to follow this  
matthew007101

D3DX10 :: Manually create a 2D texture resource from a user-defined variable(array)

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

Can anyone tell me how I can manually create a 2D texture resource (ID3D10Texture2D) from a floating point pointer?

For example, if you have a file you can use "D3DX10CreateTextureFromFile" to load the image into your resource. Or if your image file is loaded in the memory, you can use "D3DX10CreateTextureFromMemory" to achieve the same thing.

What if I have created an i.e. 512x512 float pointer and filled it in with random normalized [0,1] floats. And now want to make a 2D texture with format "DXGI_FORMAT_R32_FLOAT" and dimension 512x512 out my 1D floating point array?

I tried "D3DX10CreateTextureFromMemory" and it did not work! I believe "CreateTexture2D" will not work either, as it requires a "const D3D10_SUBRESOURCE_DATA *" to be supplied to it.

If you have done this before or have an idea of how this should be done, please let me know!

Share this post


Link to post
Share on other sites
Advertisement
CreateTexture2D is the right way to go.

If you need to fill the data during creation you need to provide an array of D3D10_SUBRESOURCE_DATA elements for each mip map. pSysMem will point to your raw data and SysMemPitch the size of a line in bytes. In your case 512*sizeof(float).

As an alternative you can use UpdateSubresource to transfer your data to the texture after creation. But this will only work for D3D10_USAGE_DEFAULT resources.


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!