So, I resolved the issue by giving up and installing the Visual Studio. However, I ended up compiling with Clang; but, instead of linking to GCC, I link to MSVC (otherwise, I'll get errors referring to vcruntime.h).
The original problem was that I wanted to use GCC in order to work with DirectX 11, but when it came to the point when I needed to load a texture, it was unfortunate that the D3DX (d3dx11.h) function that I wanted to use was deprecated in favor of D3D implementations: instead of using D3DX11CreateShaderResourceViewFromFile, I should consider using DirectXTex that has the function that I need (CreateWICTextureFromFile).
Well, I downloaded and did (kinda) everything that Chuck Walbourn suggested:
- Download DirectXTex.
- Move the DirectXTex subfolder somewhere (you will later link to it); my location example:
I:\Projects\VS\Real_DirectX11\common\include\DirectXTex
- In your project's source (in my case, I just have main.cpp), #include <DirectXTex.h> (not in quotes, because I'm going to link to it).
- Take two files from the subfolder WICTextureLoader:
WICTextureLoader11.cpp and WICTextureLoader11.h.
- And put them into my project's source (or maybe you want to link them).
- Inside my
main.cpp, I #include both of those files (.h/.cpp):
Nothing works, I get link errors (many errors!). I decided to give up and install Visual Studio again (I'm saying again, because at one point I got into OpenGL and started preferring portable solutions; and much simplistic, since my project folder has only the source code and asset files).
Seems like, VS is getting faster in its loading speeds (not compilation!), so maybe it's not that bad after all. Nope. I download the DirectXTex through NuGet package manager and probably did everything for the thing to work. Well, it kinda works, except I get irrelevant errors this time that I didn't get when I was compiling with GCC: my shaders don't compile! Oh no, where did I screw up? I have no idea! Setting the preferences for each files (VS, target version, etc.), nothing helps.
OK, let's get back to my compiler, except this time I'm using Clang (LLVM 10.0 Windows 64-bit) and I link to MSVC (you have it after installing Visual Studio). How? I change my Environment Variable PATHs from GCC's to MSVC's:
include
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include
lib
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\lib\x64
lib32
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\lib\x86
And, just in case, also included bin
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\Hostx64\x64
Then, I use a batch file to compile my thing:
build.bat
@echo off
set filename=%1
clang++ ^
%cd%\src\%1.cpp ^
-I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt" ^
-I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um" ^
-I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\winrt" ^
-I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared" ^
-I"I:\Projects\VS\Real_DirectX11\common\include\DirectXTex" ^
-L"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64" ^
-L"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64" ^
-L"I:\Projects\VS\Real_DirectX11\common\lib" ^
-w -lkernel32 -luser32 -lole32 -ldxguid -luuid -ldxgi -ld3d11 -ld3dcompiler -ldirectxtex -o %cd%\bin\%1.exe
In the command line (assuming you're in the root of your project), I just simply write build main and hit the enter. Everything compiles just fine. I'm using the flag -w which is for suppressing all warnings. Why? Because if I don't use it, it will give hundreds of warnings related to the Windows SDK's files (though, I still check if my own code doesn't have warnings).
I loaded the texture with this code:
HRESULT result;
...
result = DirectX::CreateWICTextureFromFile(d3d11_device, L"../textures/mdx.png", NULL, &texture);
if(FAILED(result))
{
// handle the error
}
I don't know if I'm going into any troubles later in my DirectX 11 rendering engine... but I'll just hope that everything is going to be fine.
