Giter Club home page Giter Club logo

directxtk's Introduction

DirectX Logo

DirectX Tool Kit for DirectX 11

http://go.microsoft.com/fwlink/?LinkId=248929

Copyright (c) Microsoft Corporation.

February 21, 2024

This package contains the "DirectX Tool Kit", a collection of helper classes for writing Direct3D 11 C++ code for Universal Windows Platform (UWP) apps for Windows 11, Windows 10, Xbox One, and Win32 desktop applications for Windows 7 Service Pack 1 or later.

This code is designed to build with Visual Studio 2019 (16.11), Visual Studio 2022, clang for Windows v12 or later, or MinGW 12.2. Use of the Windows 10 May 2020 Update SDK (19041) or later is required for Visual Studio.

These components are designed to work without requiring any content from the legacy DirectX SDK. For details, see Where is the DirectX SDK?.

Directory Layout

  • Inc\

    • Public Header Files (in the DirectX C++ namespace):

      • Audio.h - low-level audio API using XAudio2 (DirectXTK for Audio public header)
      • BufferHelpers.h - C++ helpers for creating D3D resources from CPU data
      • CommonStates.h - factory providing commonly used D3D state objects
      • DDSTextureLoader.h - light-weight DDS file texture loader
      • DirectXHelpers.h - misc C++ helpers for D3D programming
      • Effects.h - set of built-in shaders for common rendering tasks
      • GamePad.h - gamepad controller helper using XInput, Windows.Gaming.Input, or GameInput
      • GeometricPrimitive.h - draws basic shapes such as cubes and spheres
      • GraphicsMemory.h - helper for managing dynamic graphics memory allocation
      • Keyboard.h - keyboard state tracking helper
      • Model.h - draws meshes loaded from .CMO, .SDKMESH, or .VBO files
      • Mouse.h - mouse helper
      • PostProcess.h - set of built-in shaders for common post-processing operations
      • PrimitiveBatch.h - simple and efficient way to draw user primitives
      • ScreenGrab.h - light-weight screen shot saver
      • SimpleMath.h - simplified C++ wrapper for DirectXMath
      • SpriteBatch.h - simple & efficient 2D sprite rendering
      • SpriteFont.h - bitmap based text rendering
      • VertexTypes.h - structures for commonly used vertex data formats
      • WICTextureLoader.h - WIC-based image file texture loader
      • XboxDDSTextureLoader.h - Xbox One exclusive apps variant of DDSTextureLoader
  • Src\

    • DirectXTK source files and internal implementation headers
  • Audio\

    • DirectXTK for Audio source files and internal implementation headers
  • MakeSpriteFont\

    • Command line tool used to generate binary resources for use with SpriteFont
  • XWBTool\

    • Command line tool for building XACT-style wave banks for use with DirectXTK for Audio's WaveBank class
  • build\

    • Contains YAML files for the build pipelines along with some miscellaneous build files and scripts.

Documentation

Documentation is available on the GitHub wiki.

Notices

All content and source code for this package are subject to the terms of the MIT License.

For the latest version of DirectXTK, bug reports, etc. please visit the project site on GitHub.

Release Notes

  • Starting with the February 2023 release, the Mouse class implementation of relative mouse movement was updated to accumulate changes between calls to GetState. By default, each time you call GetState the deltas are reset which works for scenarios where you use relative movement but only call the method once per frame. If you call it more than once per frame, then add an explicit call to EndOfInputFrame to use an explicit reset model instead.

  • As of the September 2022 release, the library makes use of C++11 inline namespaces for differing types that have the same names in the DirectX 11 and DirectX 12 version of the DirectX Tool Kit. This provides a link-unique name such as DirectX::DX11::SpriteBatch that will appear in linker output messages. In most use cases, however, there is no need to add explicit DX11 namespace resolution in client code.

  • Starting with the July 2022 release, the bool forceSRGB parameter for DDSTextureLoader Ex functions is now a DDS_LOADER_FLAGS typed enum bitmask flag parameter. This may have a breaking change impact to client code. Replace true with DDS_LOADER_FORCE_SRGB and false with DDS_LOADER_DEFAULT.

  • As of the October 2021 release, the DGSLEffect no longer directly supports skinning. Instead, make use of SkinnedDGSLEffect which is derived from DGSLEffect.

  • Starting with the June 2020 release, this library makes use of typed enum bitmask flags per the recommendation of the C++ Standard section 17.5.2.1.3 Bitmask types. This may have breaking change impacts to client code:

    • You cannot pass the 0 literal as your flags value. Instead you must make use of the appropriate default enum value: AudioEngine_Default, SoundEffectInstance_Default, ModelLoader_Clockwise, or WIC_LOADER_DEFAULT.

    • Use the enum type instead of DWORD if building up flags values locally with bitmask operations. For example, WIC_LOADER_FLAGS flags = WIC_LOADER_DEFAULT; if (...) flags |= WIC_LOADER_FORCE_SRGB;

  • The UWP projects and the Win10 classic desktop project include configurations for the ARM64 platform. Building these requires installing the ARM64 toolset.

  • When using clang/LLVM for the ARM64 platform, the Windows 11 SDK (22000) or later is required.

  • The CompileShaders.cmd script must have Windows-style (CRLF) line-endings. If it is changed to Linux-style (LF) line-endings, it can fail to build all the required shaders.

  • Xbox One support for DirectX 11 requires the legacy Xbox One XDK. See February 2023 or earlier releases of DirectX Tool Kit for the required project files.

Support

For questions, consider using Stack Overflow with the directxtk tag, or the DirectX Discord Server in the dx9-dx11-developers channel.

For bug reports and feature requests, please use GitHub issues for this project.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Credits

The DirectX Tool Kit is the work of Shawn Hargreaves and Chuck Walbourn, with contributions from Aaron Rodriguez Hernandez and Dani Roman.

Thanks to Shanon Drone for the SDKMESH file format.

Thanks to Adrian Tsai for the geodesic sphere implementation.

Thanks to Garrett Serack for his help in creating the NuGet packages for DirectX Tool Kit.

Thanks to Roberto Sonnino for his help with the CMO, DGSL rendering, and the VS Starter Kit animation.

Thanks to Pete Lewis and Justin Saunders for the normal-mapped and PBR shaders implementation.

Thanks to Andrew Farrier and Scott Matloff for their on-going help with code reviews.

directxtk's People

Contributors

djm00n avatar ifarbod avatar jicailiu avatar jpetermugaas avatar maksqwe avatar pixelartdragon avatar walbourn avatar waruqi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

directxtk's Issues

DXTK Collisions

I just wanted to ask if it's possible to edit the actual code and get the point of collision for example of a triangle-ray test, I've been messing with the code but I couldn't get it, I'm a bit lost to find this...

SoundStream class for playing streaming wave banks

DirectXTK for Audio has a WaveBank class which allows in-memory XACT-style wave banks to be used to play one-shots and to create SoundEffectInstances.

The package also includes a command-line utility, XWBTool, to build XACT-style wave banks. In addition to building in-memory wave banks, it can build streaming wave banks which are suitable for use with async IO as demonstrated in XAudio2AsyncStream.

Therefore, this work item is to create a WaveBank::CreateSoundStream() function which creates a SoundStream class to perform this kind of streaming as part of the DirectXTK for Audio library.

UML Diagram of Effect Classes

I think it would be very useful for the wiki to include a UML diagram of all the Effect classes. I have been learning about the connections between the effect interfaces through the current wiki articles as well as reading the code and it has been an encumbrance.

I feel that a proper UML diagram would go a long way in helping those like me that would like to expand upon the Effect classes present.

Support for DirectX 12

DirectX Tool Kit currently supports DirectX 11.x. While not everything in the tool kit is applicable to DirectX 12, a subset of the graphics functionality makes sense.

  • DDSTextureLoader
  • WICTextureLoader
  • ScreenGrab
  • SpriteBatch
  • SpriteFont
  • GeometricPrimitive
  • Model

DirectX 12 has a very different approach to state and shaders, so perhaps that would be best done by implementing a PSOFactory. This would likely be used in place of CommonStates and Effects for DirectX 12.

DirectXHelpers12 would be a good place for the new SetDebugObjectName template and an UpdateSubResource equivalent.

Also a GenerateMips helper since 'auto-gen' mips is not a DX12 feature.

A LinearAllocator for handling communication with the GPU is also essential.

Note that you can currently use DirectX Tool Kit in DX12 apps through Direct3D 11 interop.

Audio, GamePad, and SimpleMath work "as is".

Installation instructions

I'd like a simple list of steps to add this library to an existing project. I'm not sure what I'm supposed to do with all this code and all these project files.

DirectXTK Sprites Init Crash

Hello guys! I'm desperated to fix this error. My renderer is DX11 and I've already included all headers and the DirectXTK.lib so the problem is when my program reachs this code in runtime 6a5cf6e1439f7facb5d8b192510daad9.png
https://gyazo.com/6a5cf6e1439f7facb5d8b192510daad9

where pSpriteBatch is defined like this:
std::unique_ptr<SpriteBatch> pSpriteBatch;
This is the DXInitializer:

void DX11Renderer::InitDevice()
{
DXGI_SWAP_CHAIN_DESC scd;

ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC));
scd.BufferCount = 1;  
scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
scd.BufferDesc.Width = ScreenX;
scd.BufferDesc.Height = ScreenY;
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scd.OutputWindow = DXWindow;
scd.SampleDesc.Count = 4;
scd.Windowed = TRUE;
scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;

///DEVICE INIT
D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, NULL, NULL, D3D11_SDK_VERSION, &scd, &DX11SwapChain, &DX11Device, NULL, &DX11DeviceContext);

DX11SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&BackBuffer);

DX11Device->CreateRenderTargetView(BackBuffer, NULL, &DX11RenderTargetView);
BackBuffer->Release();

DX11DeviceContext->OMSetRenderTargets(1, &DX11RenderTargetView, NULL);

///VIEWPORT INIT
D3D11_VIEWPORT viewport;
ZeroMemory(&viewport, sizeof(D3D11_VIEWPORT));

viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = ScreenX;
viewport.Height = ScreenY;

DX11DeviceContext->RSSetViewports(1, &viewport);

///FONTS INIT
pSpriteBatch.reset(new SpriteBatch(DX11DeviceContext)); // <<-- crash
pPurista12.reset(new SpriteFont(DX11Device, L"font.spritefont"));

///BUFFER INIT
D3D11_BUFFER_DESC bd;
ZeroMemory(&bd, sizeof(bd));

bd.Usage = D3D11_USAGE_DYNAMIC;
bd.ByteWidth = sizeof(VERTEX) * 30;
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;

DX11Device->CreateBuffer(&bd, NULL, &VertexBuffer);

///BLEND INIT

///SHADER INIT
InitRenderShaders();
}

When it reachs the line it shows me this exception 02589a97c1d19a0e5a02aaae9103ecd1.png
https://gyazo.com/02589a97c1d19a0e5a02aaae9103ecd1

and this is the breakpoint details 5aca89f56827d44d5a938b412aef40f9.png
https://gyazo.com/5aca89f56827d44d5a938b412aef40f9

To be specific, the code will crash when it reachs this code from the file 'mutex.c':
5a320b954b101b87e97fa7623913ad1a.png
https://gyazo.com/5a320b954b101b87e97fa7623913ad1a

Does anybody any idea why this happens? I'm building it as Release in x64 bits.
Thanks in advance.

EffectsFactory option for sRGB materials

If rendering to a gamma-correct render target, you want to use linear colors for rendering. There's a way to force the textures to convert from sRGB, but currently the model loaders assume the material color information is linear.

There should be an option (perhaps a flag parameter on Model::CreateFrom) to convert loaded colors from SRGBtoRGB.

Compile the fx file

I have change something in a fx file, and I try to compile it by the ComplieShaders.cmd but failed.
please tell me how to compile the fx file ?

How to use bounding sphere intersects ?

Hi,

I'm getting the bounding sphere by calling m_bounding = m_Tree->meshes.at(0)->boundingSphere;

I then try to check for intersection using a ray

void GameApp::Pick(int sx, int sy, XMVECTOR & pickRayInWorldSpacePos, XMVECTOR &pickRayInWorldSpaceDir)
{
    XMVECTOR pickRayInViewSpaceDir = XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f);
    XMVECTOR pickRayInViewSpacePos = XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f);

    float PRVecX, PRVecY, PRVecZ;
    XMFLOAT4X4 tmp;
    XMStoreFloat4x4(&tmp, m_Camera.ProjectionMatrix());
    //Transform 2D pick position on screen space to 3D ray in View space
    PRVecX = (((2.0f * sx) / 784) - 1) / tmp.m[0][0];
    PRVecY = -(((2.0f * sy) / 562) - 1) / tmp.m[1][1];
    PRVecZ = 1.0f;  //View space's Z direction ranges from 0 to 1, so we set 1 since the ray goes "into" the screen

    pickRayInViewSpaceDir = XMVectorSet(PRVecX, PRVecY, PRVecZ, 0.0f);

    //Uncomment this line if you want to use the center of the screen (client area)
    //to be the point that creates the picking ray (eg. first person shooter)
    //pickRayInViewSpaceDir = XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f);

    // Transform 3D Ray from View space to 3D ray in World space
    XMMATRIX pickRayToWorldSpaceMatrix;
    XMVECTOR matInvDeter;   //We don't use this, but the xna matrix inverse function requires the first parameter to not be null

    pickRayToWorldSpaceMatrix = XMMatrixInverse(&matInvDeter, m_Camera.ViewMatrix());   //Inverse of View Space matrix is World space matrix

    pickRayInWorldSpacePos = XMVector3TransformCoord(pickRayInViewSpacePos, pickRayToWorldSpaceMatrix);
    pickRayInWorldSpaceDir = XMVector3TransformNormal(pickRayInViewSpaceDir, pickRayToWorldSpaceMatrix);
    pickRayInWorldSpaceDir = XMVector3Normalize(pickRayInWorldSpaceDir);

    float dist;
    if (m_bounding.Intersects(pickRayInWorldSpacePos, pickRayInWorldSpaceDir, dist) == true)
    {
        m_Picked++;
    }

}

but the center of the sphere is not world coordinates correct ? should I translate the sphere center to the object that I want to test for intersection ?

SpriteFont can't use normalized coordinates

You can put SpriteBatch into a normalized coordinate mode with SetRotation( DXGI_MODE_ROTATION_UNSPECIFIED which eliminates the pixel coordinate -> normalized coordinate transform. If you do so, however, SpriteFont won't draw correctly because the font offsets are still in pixels.

This would need a mode for SpriteFont that uses the inverse viewport transform on the offsets.

Debug Shapes

While GeometricPrimitive can draw wireframe shapes, they can be obscuring for debug purposes. A debug shape manager with a life-time based on PrimitiveBatch renderer is useful for dynamic collision and visibility testing.

XNA Game Studio Sample

Many of the debug shapes are also drawn in the DirectxMath Collision sample.

Where to ask questions

Hi can you tell me where to ask question or leave comments etc. ? can I just ask here ?
Btw. my question is regarding "SpriteFont" can you please tell me how many instances of SpriteFont I can create ? Should I use one SpriteFont to render as many text sprites possible or can I create multiple SpriteFont instances ?

SimpleMath is missing equivalents to Viewport methods

The XNA Game Studio framework's Viewport includes a number of methods that could be useful as part of SimpleMath and should interop with the CD3D11_VIEWPORT class.

Key methods:

  • Project
  • Unproject
  • AspectRatio
  • TitleSafeArea

Might make more sense to implement in DirectXHelpers.h than SimpleMath

ComputeLights specular falloff improvement

In Lighting.fxh::ComputeLights(), the specular intensity currently falls of only as a term of dotH and a step() of dotL (diffuse "angle"). While correct, this results in sudden drop when dotL > 90.
image

A solution is to modulate the specular term further by dotL so we don't see the sharp edge

    float3 zeroL = step(0, dotL);
    float3 diffuse  = zeroL * dotL;
    float3 specular = pow(max(dotH, 0) * zeroL, SpecularPower) * dotL;
                                                              ^^^^^^^^

Output:
image

bounding sphere of a modal mesh

Hi,

I'm trying to get a bounding sphere of a modal mesh and transform it to world coordinates. but the bounding sphere without any transformation is not center at 0,0,0.

here is how I do the transformation```

 m_bounding = m_Tree->meshes.at(0)->boundingSphere;
 XMMATRIX sphereTranslate = XMMatrixTranslation(m_bounding.Center.x, m_bounding.Center.y,
     m_bounding.Center.z);
sphereTranslate = sphereTranslate*treeTranslate;

XMMATRIX boundingSphereScale = XMMatrixScaling(120.0f, 120.0f, 120.0f);
worldSphere = boundingSphereScale*sphereTranslate;
m_bounding.Transform(m_bounding, sphereTranslate* boundingSphereScale);

m_BoundingSphere->Draw(worldSphere, m_Camera.ViewMatrix(), m_Camera.ProjectionMatrix());

Event annotation

The library could use PIX event annotation for both Windows and Xbox One. This might also justify adding a Profile config to the vcxproj's in addition to the existing Release and Debug configs.

The library already uses PIX object naming.

missing comdecl.h

Hello there, I am trying to compile the DirectXTK but I am having problem with an header:

#include <C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\comdecl.h>
At line 46 of the Audio.h it is trying to include with full path that header. By googling around it looks like now the comdecl.h should be part of the windows sdk. I dont have the (June 2010) folder at all, but my windows sdk is up to date, I am running windows 10 by the way.
I run a search for comdecl.h and the only one showed up was the one inside the unreal engine.

Anyone got an idea on the problem?
I did not find an official download fo the june 2010 directX only one hosted on other websites like cnet etc.
I don't have much experience with the win sdk or api in general so sorry if it is a dumb question

Bug in Model class SDKMESH loader

I think I found a bug when loading and rendering the island.sdkmesh using a Model class object. The island.sdkmesh model has two mesh parts but only one is rendered.

Model support for collision meshes

The existing CMO and SDKMESH model loaders create IBs and VBs as USAGE_DEFAULT and then release the loaded geometry. This is a great match for rendering, but makes it difficult to do CPU-side triangle-based collision.

There should be a way to get Model to keep a shadow-copy or a parameter to inform the system that the loaded model is for collision and not intended for rendering...

Mouse/Keyboard GetState()/IsKeyDown()/IsKeyUp() methods

I would like to suggest that the methods listed in the subject line be made static, thereby eliminating the need to instantiate an instance of Mouse/Keyboard for most uses. For now, I'm wrapping instances of these classes in a class that has equivalent static methods, so I can achieve the effect I'm going for, but it would be nice if the DirectXTK more closely matched the XNA API right out of the box. If there is a technical reason why they shouldn't be made static I'd like to know why, if just for educational purposes. I'm humbled by the quality of the code and I'm still a ways away from mastering C++.

Another suggestion, and this is just a stylistic thing, I think it would be better to have the first letter of the Mouse::State struct members capitalized. This matches the style of the Keyboard::State struct and Microsoft conventions in general...at least in the clean and consistent world of .NET. :)

Thanks guys!

Windows 7 and CreateFile2.

Somehow on my machine with Windows 7 _WIN32_WINNT is 0x0603 and _WIN32_WINNT_WIN8 is 0x0602. This is used in DDSTextureLoader.cpp and causes problems because CreateFile2() function is available starting from Windows 8.

Raise minimum supported Feature Level to 9.3

The DirectX Tool Kit has supported all feature levels 9.1 and up, primarily to support Surface RT and Surface RT 2 devices. Since these devices will not be getting upgraded to Windows 10, and given the fact that the vast majority of PCs have 10.0 or better hardware, we will be retiring support for FL 9.1. There are almost no 9.2 devices of relevance today, but Windows phone 8.1 support requires FL 9.3.

MediaStream class for playing compressed audio

This work item is for implementing a version of XAudio2MFStream as part of DirectXTK for Audio using Media Foundation's SourceReader which supports a number of built-in codecs including WMA.

Note this is specifically for the case of wanting to apply some effect using XAudio2. Direct playback of a streaming file in the background is more efficiently implemented by using Media Session directly. See Media Session Playback Example.

The original XNA GS library included a DynamicSoundEffectIstance class primarily as a way to implement streaming. With DirectXTK for Audio, it generally makes more sense to implement a streamer directly against the XAudio2 API to more efficient handle events, callbacks, etc.

Unresolved externals in DirectXTK

Hi all,
I'm using DirectXTK and I'm getting unresolved externals when I enable no intersincs, by defining the following #define XM_NO_INTRINSICS

unresolved external symbol "public: void __fastcall DirectX::SpriteBatch

Remove VS 2012 adapter code

As part of dropping VS 2012 projects and Windows phone 8.0 support, can clean up the following code:

  • Remove C4005 disable for stdint.h (workaround for bug with VS 2010 + Windows 7 SDK)
  • Remove C4481 disable for "override is an extension" (workaround for VS 2010 bug)
  • Remove DIRECTX_STD_CALLCONV std::function workaround for VS 2012
  • Remove DIRECTX_CTOR_DEFAULT / DIRECTX_CTOR_DELETE macros and just use =default, =delete directly (VS 2013 or later supports this)
  • Remove DirectXMath 3.03 adapters for 3.06 constructs (workaround for Windows 8.0 SDK)
  • Make use of std::make_unique<> (C++14 draft feature supported in VS 2013)
  • Remove some guarded code patterns for Windows XP (i.e. functions that were added to Windows Vista)
  • Make consistent use of = {} to initialize memory to zero (C++11 brace init behavior fixed in VS 2013)
  • Remove legacy WCHAR Win32 type and use wchar_t
  • Remove guards around use of WIC (Windows phone 8.0 lacked WIC support)

FixedFunctionEffect

Shaders that can emulate the Direct3D9 legacy fixed-function pipeline, or at least a simplified version of it.

  • Point lights
  • Spot lights
  • 2,4 and 8 stage multi-texture blend

Will likely require more than a 9.1 feature level.

Normal map effects

The current set of 'built-in' shaders does not include support for normal mapped rendering with optional specular map. This is a common technique in modern rendering, so worth adding.

  • NormalMapEffect

Retire Windows 8.1 Store, Windows phone 8.1, and VS 2013 projects

At some point we should remove support for these older versions in favor of UWP apps

DirectXTK_Windows81.vcxproj
DirectXTK_WindowsPhone81.vcxproj
DirectXTK_XAMLSilverlight_WindowsPhone81.vcxproj

This would also be a good time to drop VS 2013 entirely:

DirectXTK_Desktop_2013.vcxproj
DirectXTK_Desktop_2013_DXSDK

Please put any requests for continued support for one or more of these here.

Windows 8.1 and VirtualFree

Hi Chuck. I wasn't sure if this was a bug but it seems suspect and I thought I would mention it. After upgrading to DirectXTK Nov 30 my Windows 8.1 apps throw a compile time error on this line:

if (_WIN32_WINNT >= _WIN32_WINNT_WIN10) || (defined(_XBOX_ONE) && defined(_TITLE)) || !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)

struct virtual_deleter { void operator()(void* p) { if (p) VirtualFree(p, 0, MEM_RELEASE); } };

endif

I am not very knowledgable of Windows/C++ but is it possible that VirtualFree only exists in Windows 10 libraries? If I comment out this line my Windows 8.1 UWP compiles fine. Otherwise, the error is that identifier "VirtualFree" cannot be found. Thanks, Shaun.

Expose VB/IB created by GeometricPrimitive

The existing GeometricPrimitive implementation hides the code that creates the vertices and indices for the various built-in shapes. Ideally there should be a way to create the verts/indices, modify them, and then create your own VB/IB to render with. This would (a) allow for custom modifications and tricks on existing content, and (b) simplify the DX12 work to come that will need to share the procedural creation code but can't share the same VB/IB creation.

Wrong Measurements from MeasureString

Hi Developers,

I have notice that the MeasureString returns a wrong size. The string "W" is used to measure the string size. The spritefont file is generated using MakeSpriteFont tool. The font setting is

  • FontName: Arial
  • FontStyle: Bold
  • FontSize: 185

The returned result for the width and the height are 233 and 283.642578 respectively. "W" is placed at (0,0) I have edited Image 1 to include a black dotted line and marked a red circle to indicate the position where my mouse positioned which reflects the values shown in the Window Title. Clearly, there is a big difference between the Vector2 returned and the size which I had measured.

Image 1:
image 1

In addition, when I used SpriteBatch to draw "W" on the screen (0,0) using origin (0,0), it does not draw at the correct place. Instead, there is some sort of spacing as shown in Image 2.

Image 2:
image 2

To test it further, I have used SpriteBatch to draw "W" on the screen at the bottom left (i.e. making it right justified) of the screen using the origin calculated via MeasureString, but it does not draw at the correct place as shown in Image 3. Instead, it is lifted and cut off.

Image 3:
image 3

AudioEmitter enhancements

Currently the AudioEmitter class has limited helpers for common scenarios, but does not simplify the use more complex emitter setups:

  • Multi-channel emitters (ChannelCount, ChannelRadius, updating EmitterAzimuths)
  • Sound cones (set pCone with an extended AudioEmitter for the memory required?)
  • Inner-radius (InnerRadius, InnerRadiusAngle)

GeometricPrimitive support for tangents

Currently GeometricPrimitive only generates vertices with VertexPositionNormalTexture vertices. It should at a minimum support a way of generating and drawing with tangents as those are required for NormalMapEffect.

Suggestion to add Keyboard::GetPressedKeyCode() or something similar

For the TextBox control I created, I needed the ability to handle key down events to do all the things textboxes do. Getting the keyboard state is the first step, but that's just a snapshot of the entire array of virtual keys. Being able to simply query for which virtual key was pressed was important to me, so I created the following method. If there is a more elegant solution or a method using the existing API I'd like to know and I'll ditch this approach-- which hopefully isn't too embarrassing!

Thanks!

    INT BInput::Keyboard::GetPressedKeyCode()
    {
        auto pState = reinterpret_cast<uint32_t*>(&BInput::KeyboardTracker->pressed);

        for (INT i = 0; i < 8; i++)
        {
            if (*pState != 0)
            {
                auto pStateChunk = reinterpret_cast<uint8_t*>(pState);

                for (INT j = 0; j < 4; j++)
                {
                    if (*pStateChunk != 0)
                    {
                        for (INT k = 0; k < 8; k++)
                        {
                            if (*pStateChunk & (1 << k))
                                return (32 * i) + (8 * j) + k;
                        }
                    }

                    pStateChunk++;
                }
            }

            pState++;
        }

        return 0;
    }

Mouse gets out of screen in relative mode

Hi, I am using the DirectX Mouse component and it's working fine.

However I do have some annoying behavior. I am locking the mouse with mode RELATIVE when right-clicking my window to have 3D 'mouse-look' mode - and going back to ABSOLUTE mode when releasing the right-mouse button (the app is in windowed non-fullscreen mode). Only thing : when I move the mouse too far out of the window borders, the right-mouse button release event is not fired which means I am locked into mouse-look mode with no button pressed. At this point the mouse cursor is still invisible. So I can only 'guess' where my cusor is and try to right click my window again to try to relase it. It happens that I randomly click outside the window and pop-up front another window which is very annoying.

My tracker basically works like this :

// Absolute / relative modes
if (getTrackerPressed(g_ActionButtons[LOCK_VIEW])) {
    g_mouse_state.x = 0;
    g_mouse_state.y = 0;
    g_mouse->SetMode(Mouse::MODE_RELATIVE);
}
else if (getTrackerReleased(g_ActionButtons[LOCK_VIEW])) {
    g_mouse_state.x = 0;
    g_mouse_state.y = 0;
    g_mouse->SetMode(Mouse::MODE_ABSOLUTE);
}

Any help appreciated.

PBREffect

With almost all engines supporting this, would be nice to have PBR effect support.

SaveWICTextureToFile does not preserve alpha

I am correctly clearing the screen with the transparent color via

m_d3dContext->ClearRenderTargetView(m_renderTargetView.Get(), Colors::Transparent);
m_d3dContext->ClearDepthStencilView(m_depthStencilView.Get(), D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);

// Set render target.
m_d3dContext->OMSetRenderTargets(1, m_renderTargetView.GetAddressOf(), m_depthStencilView.Get());

// Set the viewport.
m_viewport = CD3D11_VIEWPORT(0.0f, 0.0f, static_cast<float>(m_iWidth), static_cast<float>(m_iHeight));
m_d3dContext->RSSetViewports(1, &m_viewport);

but it does not preserve the alpha channel when I take a screenshot with the SaveWICTextureToFile method.

void CDirectXWrapper::Screenshot(LPCWSTR fileName)
{
    DX::ThrowIfFailed(
        SaveWICTextureToFile(m_d3dContext.Get(), m_renderTarget.Get(), GUID_ContainerFormatPng, fileName)
    );
}

Can't use DirectX::Keyboard::ProcessMessage with SetWindowsHookEx (for low-level global keyboard / WH_KEYBOARD_LL)

The hook succeeds and messages get sent correctly when keys are pressed, but does it somehow get processed differently in ProcessMessage than a normal messaging thread?

// Create messenging thread.
m_pHookThread = new std::thread(&CDirectXWrapper::Hook, this);
m_pHookThread->detach();

void CDirectXWrapper::Hook()
{
    // Install hooks
    m_hHook = SetWindowsHookEx(WH_KEYBOARD_LL, [](const int nCode, const WPARAM wParam, const LPARAM lParam) {
        switch (wParam)
        {
        case WM_ACTIVATEAPP:
            Keyboard::ProcessMessage(nCode, wParam, lParam);
            break;
        case WM_KEYDOWN:
        case WM_SYSKEYDOWN:
        case WM_KEYUP:
        case WM_SYSKEYUP:
            Keyboard::ProcessMessage(nCode, wParam, lParam);
            break;
        }

        return CallNextHookEx(m_hHook, nCode, wParam, lParam);
    }, NULL, 0);

    if (m_hHook == NULL)
    {
        std::wcout << "Keyboard hook failed!" << std::endl;
    }
    else
    {
        std::wcout << "Keyboard hooked!" << std::endl;
    }

    // Messenging loop.
    while (GetMessage(NULL, NULL, 0, 0));
}

DXGI_COLOR_SPACE_TYPE is undefined.

I'm trying to use DDSTextureLoader.
When I include DDSTextureLoader.h, Visual Studio complains that "DXGI_COLOR_SPACE_TYPE" is missing at "c:\program files (x86)\windows kits\10\include\10.0.10586.0\um\d3d11_1.h(2680)".
Logically, I can force to compile this by adding my own DXGI_COLOR_SPACE_TYPE definition before the include macro, but I want to run it without the obnoxious hack.
What gives?

Request to expose SpriteFont::Impl::FindGlyph() method to the toolkit's API

I'm writing a framework based on DirectX which includes common UI controls such as buttons, labels, textboxes, etc. As you can imagine, the TextBox control required precise measurement of rendered fonts, which was only possible once I added a FindGlyph() wrapper to the SpriteFont class so that I could get offset information for characters. I could have possibly not required this if MeasureString() worked differently.

While ultimately I was able to complete the development of this control, my framework is now dependent on a custom, modified version of DirectXTK-- not a desirable thing, obviously.

If this change request is not feasible and there is a way to achieve precise font measurements through other means I would appreciate any assistance you could provide!

Thanks!

AsyncStatus ambiguous symbol when using DirectXTK with "DirectX 11 and XAML app" template

Installing the latest version of DirectXTK from Nuget (2016.8.4.1) into a project based on the "DirectX 11 and XAML app" Visual Studio template is causing build errors since AsyncState is an ambiguous symbol.

Well honestly, it only breaks when I add an include of SimpleMath.h in the pch.h.

But this worked earlier, any ideas on how to solve easiest?

This is on Windows 10 Anniversary Update, with Visual Studio 2015 Update 2

DirectXMath: XMMatrixPerspectiveFovLH AspectHByW?

There's no github for DirectXMath, so I guess this is the next best thing.

I think the AspectHByW parameter of XMMatrixPerspectiveFovLH should be AspectWByH.

If you look at the math to compute m[0][0] and m[1][1] inside XMMatrixPerspectiveFovLH, you'll see that it's identical to the math used in gluPerspective. However, gluPerspective's aspect parameter is width/height.

How could gluPerspective and XMMatrixPerspectiveFovLH use the same math, but have a different meaning? Futhermore, the results in my app look wrong when I pass height/width, but look correct when I pass width/height.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.