WinDxgiOutputDuplication::WinDxgiOutputDuplication(WinDxgiOutput1 *dxgiOutput, WinD3D11Device *d3D11Device)
: m_outDupl(0)
{
  HRESULT hr = dxgiOutput->getDxgiOutput1()->DuplicateOutput(d3D11Device->getDevice(), &m_outDupl);
  if (FAILED(hr)) {
    if (hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE) {
      throw WinDxRecoverableException(
        _T("Can't DuplicateOutput() because resource doesn't available at the time"), hr);
    } else {
      throw WinDxCriticalException(_T("Can't DuplicateOutput()"), hr);
    }
  }
}
Example #2
0
WinDxgiAdapter::WinDxgiAdapter(WinDxgiDevice *winDxgiDevice, int iAdapter)
: m_dxgiAdapter(0)
{
  winDxgiDevice->getAdapter(&m_dxgiAdapter);
  IDXGIFactory *m_dxgiFactory;
  HRESULT hr = m_dxgiAdapter->GetParent( __uuidof( IDXGIFactory ), (void**) (&m_dxgiFactory) );
  if (FAILED(hr)) {
    throw WinDxCriticalException(_T("Can't get IDXGIAdapter parent factory (%ld)"), (long)hr);
  }

  hr = m_dxgiFactory->EnumAdapters(iAdapter, &m_dxgiAdapter);
  m_dxgiFactory->Release();
  if (hr == DXGI_ERROR_NOT_FOUND) {
    StringStorage errMess;
    errMess.format(_T("IDXGIAdapter not found for iAdapter = %u"), iAdapter);
    throw WinDxRecoverableException(errMess.getString(), hr);
  }
  if (FAILED(hr)) {
    throw WinDxCriticalException(_T("Can't IDXGIFactory::EnumAdapters()"), hr);
  }
}