DuplicateOutput is falling with E_INVALIDARGS

62 views Asked by At

I am trying to capture my screen and too do this I am using Duplicate output (line: 44) but it fails with the error E_INVALIDARGS. This is my first time using directx.

#include "dda_impl.hpp"
#include "definitions.hpp"

HRESULT dda_impl::initialize( )
{
    IDXGIOutput* output{ nullptr };
    IDXGIDevice2* device{ nullptr };
    IDXGIFactory1* factory{ nullptr };
    IDXGIAdapter* adapter{ nullptr };
    IDXGIOutput1* output1{ nullptr };

    /// Release all temporary refs before exit
    #define CLEAN_RETURN( x ) \
    SAFE_RELEASE( device );\
    SAFE_RELEASE( factory );\
    SAFE_RELEASE( output );\
    SAFE_RELEASE( output1 );\
    SAFE_RELEASE( adapter );\
    return x;

    HRESULT hr{ S_OK };
    /// To create a DDA object given a D3D11 device, we must first get to the DXGI Adapter associated with that device
    if ( FAILED( hr = this->m_d3d_device->QueryInterface( __uuidof( IDXGIDevice2 ), ( void** ) &device ) ) )
    {
        CLEAN_RETURN( hr );
    }

    if ( FAILED( hr = device->GetParent( __uuidof( IDXGIAdapter ), ( void** ) &adapter ) ) )
    {
        CLEAN_RETURN( hr );
    }
    /// Once we have the DXGI Adapter, we enumerate the attached display outputs, and select which one we want to capture
    /// This sample application always captures the primary display output, enumerated at index 0.
    if ( FAILED ( hr = adapter->EnumOutputs( 0, &output ) ) )
    {
        CLEAN_RETURN( hr );
    }

    if ( FAILED( hr = output->QueryInterface( __uuidof( IDXGIOutput1 ), ( void** ) &output1 ) ) )
    {
        CLEAN_RETURN( hr );
    }
    /// Ask DXGI to create an instance of IDXGIOutputDuplication for the selected output. We can now capture this display output
    if ( FAILED( hr = output1->DuplicateOutput( device, &this->m_duplication ) ) )
    {
        CLEAN_RETURN( hr );
    }

Tried using directx debug tools but whenever directx sdk is installed I get an unresolved external symbol for d3d11.h. I am unsure if maybe I setup the device wrong or what I did wrong.

0

There are 0 answers