DuplicateOutput 因 E_INVALIDARGS 而下降

问题描述 投票:0回答:0

我正在尝试捕获我的屏幕,并且我也使用重复输出(行:44),但它失败并出现错误 E_INVALIDARGS。这是我第一次使用 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 );
    }

尝试使用 directx 调试工具,但每当安装 directx sdk 时,我都会得到一个无法解析的 d3d11.h 外部符号。我不确定是否我设置了设备错误或者我做错了什么。

directx direct3d11 dxgi
© www.soinside.com 2019 - 2024. All rights reserved.