Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


[SOLVED] D3DX11CreateShaderResourceViewFromFile - deprecated.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 RoundPotato   Members   -  Reputation: 126

Like
0Likes
Like

Posted 16 May 2014 - 02:50 PM

Hello,
 
I am learning Direct3D and I am following this lesson.
 
When I was supposed to to load a texture using: 

HRESULT D3DX11CreateShaderResourceViewFromFile(
  _In_   ID3D11Device *pDevice,
  _In_   LPCTSTR pSrcFile,
  _In_   D3DX11_IMAGE_LOAD_INFO *pLoadInfo,
  _In_   ID3DX11ThreadPump *pPump,
  _Out_  ID3D11ShaderResourceView **ppShaderResourceView,
  _Out_  HRESULT *pHResult
);

I came across microsoft reference , stating:
 

Note  The D3DX (D3DX 9, D3DX 10, and D3DX 11) utility library is deprecated for Windows 8 and is not supported for Windows Store apps.
Note  Instead of using this function, we recommend that you use these:

  • DirectXTK library (runtime), CreateXXXTextureFromFile (where XXX is DDS or WIC)
  • DirectXTex library (tools), LoadFromXXXFile (where XXX is WIC, DDS, or TGA; WIC doesn't support DDS and TGA; D3DX 9 supported TGA as a common art source format for games) then CreateShaderResourceView

 
So I went ahead and downloaded "DirectXTex.zip" from DirectXTex .
 
I unzip it, place it in some random directory... and end up looking at "DirectXTex\DDSTextureLoader" containing the ".h" and ".cpp" files.
I link those files to my project (after painful failures and simply pointing to additional includes to ".h" and linking ".cpp" by dragging to project instead of failing documentation) and use

// Load texture.
CreateDDSTextureFromFile(dev, L"poop.jpg", 0, &cubesTexture); 

(Without knowing what "DDS" actually means, skipping the overly-complicated text on the internet) ... wham.. bham... and it compiles.   

 

 
 
I launch it... and...  33etz4k.jpg
 
 
Any idea on how to whack this sucker? I'm currently stuck and unable to continue, so any help would be much appreciated.
 
-----
I have tried compiling it into a library using visual studio project files from "DirectXTex\DirectXTex" and linking via "additional library paths" (or similar name) and putting a dependency of generated ".lib" in the linker. This failed to even compile with an unresolved external symbol (needles to say the linker didn't like it).


Edited by RoundPotato, 16 May 2014 - 07:23 PM.


Sponsor:

#2 TiagoCosta   Crossbones+   -  Reputation: 2337

Like
1Likes
Like

Posted 16 May 2014 - 04:56 PM

DDS (DirectDraw Surface) is a texture format.
 
If you want to load a .jpg texture, use the WICTextureLoader (since it supports BMP, JPEG, PNG, TIFF, GIF, etc).
 
Anyway, I think that error is being caused by something else. Which Visual Studio version are you using? And did you use the appropriate project file to compile DirectXTex?

 

Did you call CoInitialize or CoInitializeEx? 

The library assumes that the client code will have already called CoInitialize or CoInitializeEx as needed by the application before calling any DirectXTex routines

 

 

EDIT:



I have tried compiling it into a library using visual studio project files from "DirectXTex\DirectXTex" and linking via "additional library paths" (or similar name) and putting a dependency of generated ".lib" in the linker. This failed to even compile with an unresolved external symbol (needles to say the linker didn't like it).

 

I'm pretty sure you have to compile it to a library in order to use it.

 

Can you write a copy of the errors here?

I've only used DIrectXTK (not DirectXTex) but I didn't have any problem linking.


Edited by TiagoCosta, 16 May 2014 - 05:02 PM.


#3 RoundPotato   Members   -  Reputation: 126

Like
0Likes
Like

Posted 16 May 2014 - 06:19 PM

thankyouyellow.gif TiagoCosta ! You saved my day (literally, by saving my mood).
 
I managed to solve it by using WIC-based function (without compiling the library, direct implementation linkage).
 
 

DDS (DirectDraw Surface) is a texture format.
 
If you want to load a .jpg texture, use the WICTextureLoader (since it supports BMP, JPEG, PNG, TIFF, GIF, etc).

 
I am a 100% beginner, so could I ask you such silly questions:
 
* Is using "WIC" is the main format for those listed file/image formats and the standard way of doing things?

* Am I actually using an official and main method to load images using Direct3D11 ?
 

 

Did you call CoInitialize or CoInitializeEx? 

The library assumes that the client code will have already called CoInitialize or CoInitializeEx as needed by the application before calling any DirectXTex routines

 


No, I did after you mentioned that and I spotted it on that website after as well. It worked, but being myself, I removed it and tried, it still works. So as long as it works, I'd rather not call those methods even though they are mentioned (I'm assuming they are needed in some other specific calls).


Edited by RoundPotato, 16 May 2014 - 06:21 PM.


#4 spazzarama   Members   -  Reputation: 778

Like
1Likes
Like

Posted 16 May 2014 - 06:57 PM


* Is using "WIC" is the main format for those listed file/image formats and the standard way of doing things?
* Am I actually using an official and main method to load images using Direct3D11 ?

 

Windows Imaging Component or WIC is a standard way of loading images of various codecs on Windows (since Vista I think). Loading textures (to be used as image data) using the WIC is a common approach in Direct3D.

 

With DDS textures you can store data in the same format that is used within a D3D texture object. It is important to remember that a texture doesn't necessarily contain image data (i.e. you might use a texture to store a height map or a whole range of other things), the DDS format allows you to store this data in the various texture formats. You can also use the D3D texture block compression (BC) formats within a DDS.

 

The DirectXTK project is maintained by Microsoft. Chuck Walbourn has been involved in DirectX since the early days on Windows 95. These methods for loading your texture data are great to use. The actual format you choose to use really depends on your storage constraints, and your asset workflow.


Edited by spazzarama, 16 May 2014 - 06:58 PM.

Justin Stenning | Blog | Book - Direct3D Rendering Cookbook (using C# and SharpDX)

Projects: Direct3D Hook, EasyHookAfterglow, C#raft

@spazzarama

 

#5 RoundPotato   Members   -  Reputation: 126

Like
0Likes
Like

Posted 16 May 2014 - 07:23 PM

Thanks spazzarma, that cleared my questions smile.png



#6 Buckeye   Crossbones+   -  Reputation: 5600

Like
0Likes
Like

Posted 18 May 2014 - 07:32 AM

Regarding the DirectXTK and DDS files - a bit of testing indicates the CreateWICTextureFromFile does not include DDS files (and the docs for WICTextureLoader don't mention it.) For DDS files, use CreateDDSTextureFromFile which is part of the DDSTextureLoader interface.

 

If you have a generic loader with a variable filename, test the file extension, and use CreateWIC.. if not DDS, else use CreateDDS.


Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS