Coder Social home page Coder Social logo

walbourn / directx-sdk-samples Goto Github PK

View Code? Open in Web Editor NEW
1.3K 76.0 357.0 178.25 MB

This repo contains Direct3D 11, XInput, and XAudio2 samples C++ samples from the legacy DirectX SDK updated to build using the Windows 10 SDK

Home Page: https://walbourn.github.io/directx-sdk-samples-catalog/

License: MIT License

C++ 88.35% C 2.10% Haskell 0.19% Batchfile 0.06% HLSL 9.07% VBScript 0.24%
directx-sdk

directx-sdk-samples's Introduction

DirectX SDK Samples

This repo contains Direct3D 11, XInput, and XAudio2 samples that originally shipped in the legacy DirectX SDK. These are all Windows desktop applications for Windows 7 Service Pack 1 or later.

They have all been cleaned up to build using the Windows 10 SDK, and DO NOT require the DirectX SDK to build. Projects for Visual Studio 2019 are provided, and can be upgraded to VS 2022.

The remainder of the legacy DirectX SDK samples for Direct3D 10, Direct3D 9, etc. can be found directx-sdk-legacy-samples. These make use of the Microsoft.DXSDK.D3DX NuGet so also DO NOT require the legacy DirectX SDK to build.

Notices

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

Support

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

Contributing

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

A full list of credits for all these samples is lost to history. They have been developed by various Microsoft engineers over many years.

A partial list of contributors includes: Dave Bonora, David Cook, Shanon Drone, Kev Gee, Xin Huang, Matt Lee, Cody Pritchard, Jason Sandlin, David Tuft, and Chuck Walbourn.

directx-sdk-samples's People

Contributors

aklemets avatar carepackage17 avatar hanfling avatar sgbourque avatar sredna avatar walbourn 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

directx-sdk-samples's Issues

Media Foundation samples

It would be useful to have a Direct3D 11 / Media Foundation equivalent to the old Texture9 and CutScene DirectShow samples.

There is a Windows 8 sample on MSDN

Pick Sample

The Pick10 legacy DirectX SDK samples was written for Direct3D 10 / FX10 add used D3DXmath. It would be useful to port it to Direct3D 11 / FX 11 to be a DirectXMath sample.

Visual studio 2015 selector wrong

For VS 20115 solutions, the second line should be:
# Visual Studio 14

The current projects open in the latest version because the string does not match this.
This is true of at least the DXUT examples.

How can I add a new sample with vs2019?

There are some dx11 samples not in this repo, but installed with Microsoft DirectX SDK (June 2010.

ContactHardeningShadows11
DDSWithoutD3DX11
DecalTessellation11
DetailTessellation11
PNTriangles11
WindowsTouch

These samples are vs2010 or vs 2013, how can I convert them to vs2019 and add to this repo?

`device->SetProperty()` returns `hr = E_NOTIMPL Not implemented.`

I have an old USB joystick (steering wheel) and I can run the DirectInput/Joystick example with it.

But if I try to run the Force Feedback one, I'm getting E_NOTIMPL from some calls like FFConst.cpp:239.

if (FAILED(hr = g_pDevice->SetProperty(DIPROP_AUTOCENTER, &dipdw.diph)))

If I just disable that one, then the error goes down to FFConst.cpp:273

if (FAILED(hr = g_pDevice->CreateEffect(GUID_ConstantForce,
        &eff, &g_pEffect, nullptr)))

I could test that joystick's "force feedback" from a "ForceTest.exe" tool I found from somebody that implemented force feedback in some Flight Simulator versions, but I can't tell how exactly the tool accesses the joystick as the tool is not open source.

Is this something with the joystick drivers? Where could I look up what they are missing developed in order to accept those calls? The driver installs OEMForceFeedback keys to the windows registry and (claims) it supports, for instance, constant force among other capabilities.

There May be a bug in Sample: "CascadingShadowMaps", or I got it wrong.

Hi, @walbourn , I am studying the DirectX11 samples "CascadingShadowMaps" shipped with DirexX11-SDK(june 2010) and I have a question about render scene pixel shader in "RenderCascadeScene.hlsl" and
and the constant buffer:

cbuffer cbAllShadowData : register( b0 )
{
   ...
    // For Map based selection scheme, this keeps the pixels inside of the the valid range.
    // When there is no boarder, these values are 0 and 1 respectivley.
    **float           m_fMinBorderPadding;     
    float           m_fMaxBorderPadding;**
   ...

};
VS_OUTPUT VSMain( VS_INPUT Input )
{
    VS_OUTPUT Output;
   
    [Omitted]

    // Transform the shadow texture coordinates for all the cascades.
    **Output.vTexShadow = mul( Input.vPosition, m_mShadow );**
    return Output;
}
float4 PSMain( VS_OUTPUT Input ) : SV_TARGET
{
   ...

    float4 vShadowMapTextureCoordViewSpace = Input.vTexShadow;
    ...

    if ( !SELECT_CASCADE_BY_INTERVAL_FLAG ) 
    {
        iCurrentCascadeIndex = 0;
        if ( CASCADE_COUNT_FLAG  == 1 ) 
        {
            vShadowMapTextureCoord = vShadowMapTextureCoordViewSpace * m_vCascadeScale[0];
            vShadowMapTextureCoord += m_vCascadeOffset[0];
        }
        if ( CASCADE_COUNT_FLAG > 1 ) {
            for( int iCascadeIndex = 0; iCascadeIndex < CASCADE_COUNT_FLAG && iCascadeFound == 0; ++iCascadeIndex ) 
            {
                vShadowMapTextureCoord = vShadowMapTextureCoordViewSpace * m_vCascadeScale[iCascadeIndex];
                vShadowMapTextureCoord += m_vCascadeOffset[iCascadeIndex];

                if ( **min( vShadowMapTextureCoord.x, vShadowMapTextureCoord.y ) > m_fMinBorderPadding
                  && max( vShadowMapTextureCoord.x, vShadowMapTextureCoord.y** ) < m_fMaxBorderPadding )
                { 
                    iCurrentCascadeIndex = iCascadeIndex;   
                    iCascadeFound = 1; 
                }
            }
        }
    } 
    ...
}  

When I check the buffer settings in cpp code,, it is like:

    // The border padding values keep the pixel shader from reading the borders during PCF filtering.
    pcbAllShadowConstants->m_fMaxBorderPadding = (float)( m_pCascadeConfig->m_iBufferSize  - 1.0f ) / 
        (float)m_pCascadeConfig->m_iBufferSize;
    pcbAllShadowConstants->m_fMinBorderPadding = (float)( 1.0f ) / 
        (float)m_pCascadeConfig->m_iBufferSize;

Obviously, in hlsl pixel shaer, the global variables: m_fMinBorderPadding, m_fMaxBorderPadding will be bound to (0, 1), whereas, vShadowMapTextureCoord can not be in range [0, 1][0, 1][0,1] before perspective divide( divide by its w component ). When checking the code previously in pixel shader to check whether there is any piece of code doing perspective divide, I find none unfortunately. I think this is a bug in the implementation, or I got it wrong. I beg your opinion about this.

Yet, another question, In PSMain mentioned above, the usage of “ddx()” and "ddy()" intrinsic function
in HLSL may be wrong:

        vShadowMapTextureCoordDDX = ddx( vShadowMapTextureCoordViewSpace );
        vShadowMapTextureCoordDDY = ddy( vShadowMapTextureCoordViewSpace );    

Refer to https://docs.microsoft.com/zh-cn/windows/desktop/direct3dhlsl/dx-graphics-hlsl-ddx, ddx and ddy take screen space coordinates, but vShadowMapTextureCoordViewSpace is in light view space, more transformations are needed here.

The CDXUTSDKMesh is used in EmptyProject11, under certain circumstances, a memory leak will occur after destruction

I tried to use the DXUT framework on empty project11, and then I found that when using CDXUTSDKMesh in an empty project11
,a memory leak occurs when the project is closed,even though I have destroyed CDXUTSDKMesh
The pseudo code is as follows

CDXUTSDKMesh                        g_Mesh;
OnD3D11CreateDevice
{
    HRESULT hr = S_OK;
     V_RETURN(g_Mesh.Create(pd3dDevice, L"Tiny\\tiny.sdkmesh"));
     return S_OK;
}

OnD3D11DestroyDevice
{
     g_Mesh.Destroy();
}

A pop-up window told me that d3ddevice has a non-zero reference count
This situation will not happen when the texture requested by tiny.sdkmesh is not in the same directory as him

GDFTrace icon resource 101

CGDFParse::OutputGDFIconInfo hardcodes icon id 101 while CGDFParse::IsIconPresent just picks the first icon, which is correct?

For Games Explorer on Windows 8 it seems like the icon id does not matter.

Is there any platform where it matters? What does Vista do if there is no __GDF_THUMBNAIL png resource?

Retire VS 2013 projects

I'll be removing the VS 2013 projects in 2018. I'll continue to support VS 2015 and VS 2017

I need Direct Input for 8x Gamepads support

I connect 4 physical gamepads + 4 virtual ones (Droidjoy, HandyGamepad).... Physical & virtuals work fine separately, but when I mix them all 8 devices, they are not all recognized (2nd replaces the xinput port of the 1st, & 1st doesn't work anymore). I NEED a port optimizer / driver for Xinput disabler, or converting it to Direct Input, to finally support 8 gamepads !!! Trying now DS4Win & SDL2 with confidence of failure.

DxDiag samples

The legacy DxDiagOutput and DxDiagReport samples should be able to build with just the Windows SDK

TileResource sample

For Gamefest 2011, there was a TiledResources sample created that demonstrates the basics of virtual texturing. The feature was then added to Direct3D 11.2, but there was not a Win32 desktop sample for it, only a Windows store sample.

It might be useful to clean up the original sample to use 11.2 tiled resources when available.

MSDN links for directx-sdk-samples on wiki "fail" to find the link.

https://github.com/walbourn/directx-sdk-samples/wiki

The link to the samples on that wiki page no longer work. That is, the code appears to be gone from the docs.microsoft.com site (that the link resolves to). Anyway, I know a version of the code is here on GitHub but I thought those were a different (newer) version which was updated to NOT use .fx files for example. Perhaps I am thinking of a different distro.

Thanks for any help!

Convert samples to use offline built shaders

The bulk of the samples use run-time HLSL compilation which is not recommended for production use. At least some if not all samples should be updated to build the shaders as a part of the build instead of at runtime.

IsXInputDevice function return false when i use a xbox series x controller

I use the function described in the msdn document to detect whether my controller is an xinput device, but i get a false return when i use a xbox series x controller.

DWORD dwVidPid = MAKELONG(dwVid, dwPid);
if (dwVidPid == pGuidProductFromDirectInput->Data1)
{
    bIsXinputDevice = true;
    goto LCleanup;
}

the dwVidPid value is 185794654 and the pGuidProductFromDirectInput->Data1 is 185795678

Transforming Normal Vectors

Applying a transformation M to both a surface and a surface tangent, results in a transformed tangent of the transformed surface. Applying a transformation M to both a surface and a surface normal, does not necessarily result in the transformed normal of the transformed surface. To obtain the transformed normal, one should use a transformation N=(M^-1)^T (i.e. transposed inverse of the original transformation matrix M).

Shouldn't this matrix N be used instead of M in for example directx-sdk-samples/Direct3D11Tutorials/Tutorial06/Tutorial06.fx?

Bug in VarianceShadowsManager::ComputeNearAndFar()

VarianceShadowsManager::ComputeNearAndFar() calculates fFarPlane incorrectly in certain situations. Manually setting fFarPlane to a larger value circumvents the issue but defeats the purpose of "AABB/Scene NearFar" FIT_NEARFAR_SCENE_AABB fitting.

cdmbug3.mp4

Advanced Particles Samples

The following legacy DirectX SDK samples were written for Direct3D 10 / FX10 and demonstrate various particle techniques. They should be ported to Direct3D 11, perhaps using FX11, for reference:

  • AdvancedParticles
  • DeferredParticles
  • GPUBoids
  • SoftParticles

how to use CDXUTIMEEditBox in SimpleSample11? with nothing to show for it

CDXUTIMEEditBox* pIMEEdit;
CDXUTIMEEditBox::InitDefaultElements(&g_HUD);

if (SUCCEEDED(CDXUTIMEEditBox::CreateIMEEditBox(&g_HUD, IDC_EDITBOX2, L"", 0, iY += iYo, 170, 22, false, &pIMEEdit)))
{
    g_HUD.AddControl(pIMEEdit);
    pIMEEdit->GetElement(0)->iFont = 1;
    pIMEEdit->GetElement(1)->iFont = 1;
    pIMEEdit->GetElement(9)->iFont = 1;
    pIMEEdit->GetElement(0)->TextureColor.Init(D3DCOLOR_ARGB(128, 255, 255, 255));  // Transparent center
    pIMEEdit->SetBorderWidth(3);
    pIMEEdit->SetTextColor(D3DCOLOR_ARGB(255, 64, 64, 64));
    pIMEEdit->SetCaretColor(D3DCOLOR_ARGB(255, 64, 64, 64));
    pIMEEdit->SetSelectedTextColor(D3DCOLOR_ARGB(255, 255, 255, 255));
    pIMEEdit->SetSelectedBackColor(D3DCOLOR_ARGB(255, 40, 72, 72));
  
}

collision project can not work on win10 with Visual Studio 2022

Can not compile collision sample.I got this error:
LNK2001 unresolved external symbol "private: static class DirectX::SharedResourcePool<struct ID3D11Device *,class DirectX::EffectBase::DeviceResources> DirectX::EffectBase::deviceResourcesPool" (?deviceResourcesPool@?$EffectBase@UBasicEffectTraits@@@DirectX@@0V?$SharedResourcePool@PEAUID3D11Device@@VDeviceResources@?$EffectBase@UBasicEffectTraits@@@DirectX@@$$V@2@A)
I tried include 'd3compiler.lib' location to "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x64"
and "d3dcompiler_47.dll" to "C:\Program Files (x86)\Windows Kits\10\Redist\D3D\x64"
both still can not compile!

OS:windows 10
SDK:10.0.19041.0
Visual Studio 2022 :17.0.5

Tutorials

Where can I find the tutorials from the "tutorial01" folder?

XInputEnable is deprecated

In the XInput samples (both BasicController and RumbleController) XInputEnable is used.

XInputEnable has been marked as deprecated for windows 10 and up. Using the function invokes non-standard-conforming behavior of emitting an error instead of a warning for deprecated attributes and/or #pragma deprecated preprocessor directives so the samples will not compile by default without disabling SDL checks:

#if(_WIN32_WINNT >= _WIN32_WINNT_WIN8)
void WINAPI XInputEnable
(
    _In_ BOOL enable     // [in] Indicates whether xinput is enabled or disabled. 
);
#if(_WIN32_WINNT >= _WIN32_WINNT_WIN10)
#pragma deprecated(XInputEnable)
#endif

An alternative would be nice, as I think it's a good thing to have the ability to disable controllers when a program loses focus.

Geometry Shader Samples

The following legacy DirectX SDK samples were written for Direct3D 10 / FX10 and demonstrate the geometry shader stage. They should be ported to Direct3D 11, perhaps using FX11, for reference to GS techniques:

  • CubemapGS
  • ParticlesGS
  • PipesGS
  • Skinning10
  • ShadowVolume10

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.