DirectXTutorials.com에서 this tutorial을 따라 DX11을 배우고 있습니다. 지금 시점에서 장치를 만들었고 컨텍스트가 있으며 이제 스왑 체인을 만들어야합니다.
그러나 CreateSwapChainForCoreWindow(...)
을 호출하면 스왑 체인이 nullptr로 남으며 0x887a0001
을 반환합니다. DirectX Error Lookup은 코드에 대해 다음을 뱉어냅니다.DXGI_ERROR_INVALID_CALL이 코어 창을위한 스왑 체인을 만들 때
Name: DXGI_ERROR_INVALID_CALL
Description: The application has made an erroneous API call that it had enough information to avoid.
This error is intended to denote that the application should be altered to avoid the error.
Use of the debug version of the DXGI.DLL will provide run-time debug output with further information.
Severity code: Failed
이 오류를 방지하려면 코드를 어떻게 변경해야합니까? 스왑 체인 설명에 대한 형식이나 효과를 변경하지 않고 다른 답변을 시도한 적이 있습니다.
는 여기에 실패 마지막 호출이다, 문제의 코드입니다 :
void Game::Initialize()
{
// Define temporary pointers to a device and a device context
ComPtr<ID3D11Device> dev11;
ComPtr<ID3D11DeviceContext> devcon11;
// Create the device and device context objects
D3D11CreateDevice(
nullptr,
D3D_DRIVER_TYPE_HARDWARE,
nullptr,
0,
nullptr,
0,
D3D11_SDK_VERSION,
&dev11,
nullptr,
&devcon11
);
// Convert the pointers from the DirectX 11 version to the DirectX 11.1 versions
dev11.As(&mDevice);
devcon11.As(&mDeviceContext);
// Obtain the DXGI factory
// [1] Convert our ID3D11Device1 into an IDXGIDevice1
ComPtr<IDXGIDevice1> dxgiDevice;
mDevice.As(&dxgiDevice);
// [2] Use the IDXGDevice1 interface to get access to the adapter
ComPtr<IDXGIAdapter> dxgiAdapter;
dxgiDevice->GetAdapter(&dxgiAdapter);
// [3] Use the IDXGIAdapter interface to get access to the factory
ComPtr<IDXGIFactory2> dxgiFactory;
dxgiAdapter->GetParent(__uuidof(IDXGIFactory2), &dxgiFactory);
// Set up the swap chain description
DXGI_SWAP_CHAIN_DESC1 scd = { 0 };
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // How the swap chain should be used
scd.BufferCount = 2; // A front and back buffer
scd.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // The most common swap chain format
scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // The recommended flip mode
scd.SampleDesc.Count = 1; // Disable anti-aliasing
HRESULT result = dxgiFactory->CreateSwapChainForCoreWindow(
mDevice.Get(), // Address of the device
reinterpret_cast<IUnknown*>(CoreWindow::GetForCurrentThread()), // Address of the window
&scd, // Address of the swap chain description
nullptr, // Monitor selection stuff - leave null
&mSwapChain // Address of the new swap chain
);
}
mDevice
, mDeviceContext
및 mSwapChain
클래스의 모든 멤버 변수입니다.
SDL과 SFML에서 DirectX로 곧바로 들어 왔기 때문에 이전 버전보다 낮았습니다. 문제가되는 전화를 피하기위한 충분한 정보가 있다면, 대신 내가 무엇을 불러야합니까? 나는 사람들이 CreateDeviceAndSwapChain
라고 부르는 몇 가지 질문을 본다. 이것이 선호되는 방법인가?
편집 : 그 어떤 변화도 가져 오지면 가 명확히하기 위해, 프로젝트 유형, DirectX11 App (Universal Windows)
입니다.
reinterpret_cast<IUnknown*>(CoreWindow::GetForCurrentThread()), // Address of the window
실패의 지점에서 스택 추적에보기 내가 App::Initialize
에서 Game::Initialize
를 호출하는 것을 보여 주었다 :
[DeviceResources] (https://github.com/walbourn/directx-vs-templates/blob/master/d3d11game_uwp_dr/DeviceResources.cpp)를 살펴보고, "CreateDXGIFactory2 ''. –
@ChuckWalbourn 감사합니다. 템플릿에서 새 프로젝트를 생성했는데 문제가 발생하지 않습니다. 그래서 저는 그것을 저와 비교할 것입니다. –