How does "DXUTGetGlobalResourceCache().CreateTextureFromFile" correctly?
Hello Meho, maybe the ID3D11DeviceContext *pContext parameter is missing on the call? Also, I recommend you to use DirectX Tool Kit for a more "modern" texture loading, you can get more info here and here is the source (you can copy the .h and .cpp files to your project, there is no need to use the entire DirectXTK library).
This Toolkit is a bit complex solution, it is possible to use DDSTextureLoader, which is a part of the new DXUT also.
This Toolkit is a bit complex solution, it is possible to use DDSTextureLoader, which is a part of the new DXUT also.
Actually, DirectXTK has DDSTextureLoader and WICTextureLoader. Again, it is possible to rip these files to your own project.
Hi,
thank you all for repley!
Yes it is possible to use a other method to handle texturs!
In the DXUT folder of my project in Visual Studio 12, i cant find DDSTextureLoader and WICTextureLoader. So i loaded from
your link and copyed&pasted WICTextureLoader.h und WICTextureLoader.cpp in my projektfolder. After that i included WICTextureLoader.h
and tried the example from: https://directxtk.codeplex.com/wikipage?title=WICTextureLoader&referringTitle=Home
Now i have two variant:
1:
Hi,
thank you all for repley!
Yes it is possible to use a other method to handle texturs!
In the DXUT folder of my project in Visual Studio 12, i cant find DDSTextureLoader and WICTextureLoader. So i loaded from
your link and copyed&pasted WICTextureLoader.h und WICTextureLoader.cpp in my projektfolder. After that i included WICTextureLoader.h
and tried the example from: https://directxtk.codeplex.com/wikipage?title=WICTextureLoader&referringTitle=Home
Now i have two variant:
1:
hr = CreateWICTextureFromFile( pd3dDevice, L"Holz.jpg", nullptr, &g_pRV, 0 );Here the compiler returns three error, from "c:\program files (x86)\windows kits\8.0\include\shared\dxgi1_2.h(1274)".I think the errors are in my code and not in dxgi1_2.h !!2:ComPtr<ID3D11ShaderResourceView> srv;hr = CreateWICTextureFromFile( pd3dDevice, immContext.Get(), L"Holz.jpg", nullptr, srv.GetAddressOf() );Here i have trouble with immContext, because i dont know what variable it is!?Have somebody a idea?Thanks again!Mehop.s.: I dont have permission to upload a fil, so i uploaded it here: https://mega.co.nz/#!sMMw0ZYA!RuoDX6uDX0ULm2302h28wF21FDlS97EdaQT54aAN-Ik
Make sure you are calling CreateWICTextureFromFile from the WICTextureLoader.h you have just created. I can't read your code right now, so here is an simplified example of how I call this function (note the DirectX namespace; TextureMgr is my class that holds this function; md3dDevice is a raw pointer to a ID3D11Device):
#include "WICTextureLoader.h"
ID3D11ShaderResourceView* TextureMgr::CreateTexture(std::wstring filename)
{
ID3D11ShaderResourceView* srv = 0;
DirectX::CreateWICTextureFromFile(md3dDevice, filename.c_str(), nullptr, &srv);
return srv;
}