GteDXGIAdapter.cpp
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #include <GTEnginePCH.h>
10 using namespace gte;
11 
12 
14 {
15  if (mAdapter)
16  {
17  mAdapter->Release();
18  }
19 }
20 
22  :
23  mAdapter(nullptr)
24 {
25  *this = object;
26 }
27 
28 DXGIAdapter::DXGIAdapter(IDXGIAdapter1* adapter)
29  :
30  mAdapter(adapter)
31 {
32  ZeroMemory(&mDescription, sizeof(DXGI_ADAPTER_DESC1));
33  if (mAdapter)
34  {
35  HRESULT hr = mAdapter->GetDesc1(&mDescription);
36  CHECK_HR_RETURN_NONE("Unexpected error");
37 
38  for (UINT i = 0; ; ++i)
39  {
40  IDXGIOutput* output = nullptr;
41  hr = mAdapter->EnumOutputs(i, &output);
42  if (hr != DXGI_ERROR_NOT_FOUND)
43  {
44  mOutputs.push_back(DXGIOutput(output));
45  }
46  else
47  {
48  break;
49  }
50  }
51  }
52 }
53 
55 {
56  if (object.mAdapter)
57  {
58  object.mAdapter->AddRef();
59  }
60 
61  SafeRelease(mAdapter);
62 
63  mAdapter = object.mAdapter;
64  mDescription = object.mDescription;
65  mOutputs = object.mOutputs;
66  return *this;
67 }
68 
69 IDXGIAdapter1* DXGIAdapter::GetAdapter() const
70 {
71  return mAdapter;
72 }
73 
74 DXGI_ADAPTER_DESC1 const& DXGIAdapter::GetDescription() const
75 {
76  return mDescription;
77 }
78 
79 std::vector<DXGIOutput> const& DXGIAdapter::GetOutputs() const
80 {
81  return mOutputs;
82 }
83 
84 void DXGIAdapter::Enumerate(std::vector<DXGIAdapter>& adapters)
85 {
86  adapters.clear();
87 
88  IDXGIFactory1* factory = nullptr;
89  HRESULT hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1),
90  (void**)&factory);
91  CHECK_HR_RETURN_NONE("Unexpected error");
92 
93  if (factory)
94  {
95  for (UINT i = 0; ; ++i)
96  {
97  IDXGIAdapter1* adapter = nullptr;
98  hr = factory->EnumAdapters1(i, &adapter);
99  if (hr != DXGI_ERROR_NOT_FOUND)
100  {
101  adapters.push_back(DXGIAdapter(adapter));
102  }
103  else
104  {
105  break;
106  }
107  }
108 
109  SafeRelease(factory);
110  }
111 }
112 
IDXGIAdapter1 * mAdapter
#define CHECK_HR_RETURN_NONE(msg)
DXGI_ADAPTER_DESC1 const & GetDescription() const
IDXGIAdapter1 * GetAdapter() const
static void Enumerate(std::vector< DXGIAdapter > &adapters)
DXGIAdapter(DXGIAdapter const &object)
std::vector< DXGIOutput > const & GetOutputs() const
std::vector< DXGIOutput > mOutputs
ULONG SafeRelease(T *&object)
DXGIAdapter & operator=(DXGIAdapter const &object)
typedef UINT(WINAPI *PFNWGLGETGPUIDSAMDPROC)(UINT maxCount
GLuint object
Definition: glext.h:6426
DXGI_ADAPTER_DESC1 mDescription


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59