dev.nlited.com

>>

DirectXTK

<<<< prev
next >>>>

2017-11-25 20:48:28 chip Page 2068 📢 PUBLIC

I am starting with DirectX 11, installed the "DirectX Game" templates, and created a new "Direct3D Win32 Game" project (not Direct3D12 Win32 Game). This worked.

Install the DirectX Tool Kit using NuGet.

The examples have little or no error checking. It helped to expand the generic ThrowIfFailed template:


pch.h: ThrowIfFailed(): namespace DX { inline void ThrowIfFailed(HRESULT hr) { if(FAILED(hr)) { WCHAR text[200]; WCHAR ErrorText[80]; memset(text,0,sizeof(text)); memset(ErrorText,0,sizeof(ErrorText)); FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0,hr,0,ErrorText,_ARRAYSIZE(ErrorText)-1,0); _snwprintf(text,_ARRAYSIZE(text)-1,L"HR %08X\r\n%s",hr,ErrorText); MessageBox(0,text,L"DirectX Error",MB_OK|MB_ICONERROR); // Set a breakpoint on this line to catch DirectX API errors throw std::exception(); } } }

The tutorial is a "monkey-see, monkey-do" that steps through loading and drawing sprites.

The tutorials make extensive use of "smart pointers". Microsoft::WRL (Windows Runtime Library) implements ComPtr. The std::unique_ptr is a standard template that wraps a pointer to an object so that the destructor is called when the wrapper falls out of scope.

The multi-sample anti-aliasing example failed. It is not supported by the VMware graphics emulator.
D3D11 ERROR: ID3D11Device::CreateTexture2D: The Sample descriptor is invalid for a D3D10.0 level driver. DXGI_SAMPLE_DESC::Count (value = 4) must be between 1 and 32, inclusively. For 4 samples, the current graphics implementation only supports DXGI_SAMPLE_DESC::Quality (value = 0) less than 0. <-- if 0 is shown here for Quality, this means the graphics implementation doesn't support this number of samples. Use CheckMultisampleQualityLevels to detect what the graphics implementation supports. [ STATE_CREATION ERROR #93: CREATETEXTURE2D_INVALIDSAMPLES]

When I tried to run it natively on Skull the following DLLs were missing: ucrtbased.dll, MSVCP1400.dll, VCRUNTIME1400.dll. This is normally fixed by changing the runtime library from "Multi-threaded DLL" to "Multi-threaded debug". However, the DirectXTK libraries were linked using the DLL causing a conflict in the final link. I switched to the release build and was able to run it.

The Rendering a Model example did not compile because Model::CreateFromCMO() does not exist. The version of Model.h that is in the NuGet package is quite a bit different than the version in github. The package includes two versions of the DirectXTK, one for Windows 8.1 and another for Windows 10. The Windows 10 version does not include a declaration for CreateFromCMO(). The project is currently using the Windows 10 version. I tried changing the target version of Windows to 8.1, but it is still referencing the Windows 10 package.

packages.config: <?xml version="1.0" encoding="utf-8"?> <packages> <package id="directxtk_desktop_2015" version="2017.9.22.1" targetFramework="native" /> <package id="directxtk12_desktop_2015" version="2017.9.22.1" targetFramework="native" /> </packages>

C/C++ > Preprocessor > Preprocessor Definitions = HAS_DIRECTXTK12

The properties for the individual files have different settings:
C/C++ > General > Additional Include Directories
$(MSBuildThisFileDirectory)../../build/native/include/;%(AdditionalIncludeDirectories)

I was able to finally build the project by setting the "Additional Include Directories" for both the project and the individual files. When I deleted the explicit settings for the files (inherit from project), the original setting would reappear and the directxtk12 directory would be used. I could not figure out where the directxtk directory was being defined or how to change it.

This tutorial did a good job of stepping through some very basic examples and providing a useful library. Now I have an idea of the basic tools and interfaces that are available, but very little understanding of what they do or how they work.



WebV7 (C)2018 nlited | Rendered by tikope in 41.113ms | 3.23.101.60