gpt4 book ai didi

c++ - MiscFlags D3D11_RESOURCE_MISC_GDI_COMPATIBLE 用于 GDI 兼容纹理,但 IDXGISurface1::GetDC 抛出异常

转载 作者:太空宇宙 更新时间:2023-11-04 12:39:50 27 4
gpt4 key购买 nike

我正在使用 MiscFlags D3D11_RESOURCE_MISC_GDI_COMPATIBLE 创建纹理。然而调试层显示以下错误。如果我使用 D3D10_RESOURCE_MISC_GDI_COMPATIBLE 标志 CreateTexture2D() - 抛出异常。为什么调试层需要 D3D10_RESOURCE_MISC 而不是 D3D11_RESOURCE_MISC?

DXGI ERROR: IDXGISurface1::GetDC: GetDC can only be called for textures that were created with the D3D10_RESOURCE_MISC_GDI_COMPATIBLE flag. [ MISCELLANEOUS ERROR #89: ]

TRY_POINTER(renderer);
D3D11_TEXTURE2D_DESC desc;
ZeroMemory(&desc, sizeof(desc));
desc.Width = gsl::narrow_cast<UINT>(width);
desc.Height = gsl::narrow_cast<UINT>(height);
desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
desc.CPUAccessFlags = 0;
desc.MipLevels = 1;
desc.SampleDesc.Count = 1;
desc.MiscFlags = D3D11_RESOURCE_MISC_GDI_COMPATIBLE;

ID3D11DevicePtr device = renderer->Device();
ID3D11Texture2DPtr texture2D;
IF_FAILED_THROW_HR(device->CreateTexture2D(&desc, nullptr, &texture2D));

最佳答案

对不起。我的错。在从表面使用 GDI 兼容 DC 之前,IDXGISurface1 变为空。现在它的工作!没有 DXGI 错误。

关于c++ - MiscFlags D3D11_RESOURCE_MISC_GDI_COMPATIBLE 用于 GDI 兼容纹理,但 IDXGISurface1::GetDC 抛出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54747694/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com