Jump to content
  • Advertisement
Sign in to follow this  
dbuzaleski

DX11 1DTexture Help Needed!

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

Hello!


I'm trying to create a Shader Resource View for a 1D texture. However, my source for the texture is just a .png file, and when I use:


D3DX11CreateTextureFromFile( g_pd3dDevice, L"ColorRamp01.png", NULL, NULL, &pTexture, NULL );


The texture is created as a 2D texture. I have also tried using the D3DX11_IMAGE_LOAD_INFO structure to specify that I want a 1D texture as follows, but I get the same results.



D3DX11_IMAGE_INFO sourceInfo;
hr = D3DX11GetImageInfoFromFile(L"ColorRamp01.png", NULL, &sourceInfo, NULL );
sourceInfo.ResourceDimension = D3D11_RESOURCE_DIMENSION_TEXTURE1D;

D3DX11_IMAGE_LOAD_INFO loadInfo;
loadInfo.pSrcInfo = &sourceInfo;

ID3D11Resource *pTexture = NULL;
D3DX11CreateTextureFromFile( g_pd3dDevice, L"ColorRamp01.png", &loadInfo, NULL, &pTexture, NULL );



Any suggestions on what I am doing wrong?


NOTE: Yes, I know I'm ignoring a return value, I just omitted that to make the listing shorter. On execution all the HRESULTS are coming back as S_OK

Share this post


Link to post
Share on other sites
Advertisement
The pLoadInfo is specified as [in] in the docs, so this value is just returned.

I found a function called D3DX11LoadTextureFromTexture, maybe this does what you want, but I can't say since I never used it.



If you can't get that to work you'll need to create a new 1D texture and use the height/format from the one you load and then manually copy the data into the 1D texture.


Share this post


Link to post
Share on other sites
Will look in to LoadTextureFromTexture...I was hoping to avoid having to populate the data myself, but I guess that's mostly just laziness.


Also I need to go back to the MSDN pages I was viewing that led me to that LoadInfo structure...the verbiage on MSDN definitely stated that you could alter the values of that structure to control how the texture was loaded, but it wouldn't be the first time I misread something there...

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!