我已经创建了一个默认的 DirectX12 应用程序(旋转 3D 立方体),并且在我void DX::DeviceResources::Present()
尝试将后台缓冲区写入文件中:
// Present the contents of the swap chain to the screen.
void DX::DeviceResources::Present()
{
// The first argument instructs DXGI to block until VSync, putting the application
// to sleep until the next VSync. This ensures we don't waste any cycles rendering
// frames that will never be displayed to the screen.
HRESULT hr = m_swapChain->Present(1, 0);
UINT backBufferIndex = m_swapChain->GetCurrentBackBufferIndex();
ComPtr<ID3D12Resource> spBackBuffer;
m_swapChain->GetBuffer(backBufferIndex, IID_PPV_ARGS(&spBackBuffer));
//before writing the buffer, I want to check that the file is being
//created
ofstream myfile;
myfile.open("WHEREISTHEFILE.txt");
myfile << "Writing this to a file.\n";
myfile.close();
// If the device was removed either by a disconnection or a driver upgrade, we
// must recreate all device resources.
if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET)
{
m_deviceRemoved = true;
}
else
{
DX::ThrowIfFailed(hr);
MoveToNextFrame();
}
}
问题出现在这里:
ofstream myfile;
myfile.open("WHEREISTHEFILE.txt");
myfile << "Writing this to a file.\n";
myfile.close();
我只想先写一个文件(如此处所示),然后再尝试写后台缓冲区的内容。现在,由于某种原因,我找不到输出文件......我到处搜索,我的项目中的所有目录,甚至在 Microsoft DirectX SDK 文件夹中。
没有抛出异常,我可以在调试时单步执行每一行而不会出错。
它可能在哪里?