DuplicateOutput 随E_INVALIDARGS下降

DuplicateOutput is falling with E_INVALIDARGS

提问人:46784 提问时间:7/25/2023 最后编辑:Simon Mourier46784 更新时间:7/25/2023 访问量:41

问:

我正在尝试捕获我的屏幕,并且也这样做,我正在使用重复输出(行: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

评论

0赞 drescherjm 7/25/2023
哪条线是#44?
0赞 46784 7/25/2023
@drescherjm倒数第四
0赞 Simon Mourier 7/25/2023
你的设备参数可能是错误的。来自官方文档:“E_INVALIDARG出于以下原因之一:1) 指定的设备 (pDevice) 无效,未在正确的适配器上创建,或者不是从 IDXGIFactory1 (或从 IDXGIFactory1) 继承的 DXGI 工厂接口的更高版本创建,或 2) 调用应用程序已复制此桌面输出。

答: 暂无答案