-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdapterReader.cpp
More file actions
38 lines (26 loc) · 890 Bytes
/
AdapterReader.cpp
File metadata and controls
38 lines (26 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "AdapterReader.h"
std::vector<AdapterData> AdapterReader::adapters;
AdapterData::AdapterData(IDXGIAdapter* pAdapter) {
this->pAdapter = pAdapter;
HRESULT hr = pAdapter->GetDesc(&this->description);
if (FAILED(hr)) {
Logger::Log(hr, "Failed to get description for IDXGIAdapter");
}
}
std::vector<AdapterData> AdapterReader::GetAdapterData() {
if (adapters.size() > 0) // If already intiialized
return adapters;
Microsoft::WRL::ComPtr<IDXGIFactory> pFactory;
HRESULT hr = CreateDXGIFactory(__uuidof(IDXGIFactory), reinterpret_cast<void**>(pFactory.GetAddressOf()));
if (FAILED(hr)) {
Logger::Log("Failed to create DXGIFactory for enumatoring adapters.");
exit(-1);
}
IDXGIAdapter* pAdapter;
UINT index = 0;
while (SUCCEEDED(pFactory->EnumAdapters(index, &pAdapter))) {
adapters.push_back(AdapterData(pAdapter));
index += 1;
}
return adapters;
}