Skip to content

Instantly share code, notes, and snippets.

@fujii
Created December 17, 2021 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fujii/72df773fe7fa11fd7459755f184cee6a to your computer and use it in GitHub Desktop.
Save fujii/72df773fe7fa11fd7459755f184cee6a to your computer and use it in GitHub Desktop.
#include <iostream>
#include <windows.h>
#include <vector>
#include <dxgi1_2.h>
#pragma comment(lib, "DXGI.lib")
int main()
{
std::cout << "EnumAdapters\n";
IDXGIAdapter * pAdapter;
std::vector <IDXGIAdapter2*> vAdapters;
IDXGIFactory* pFactory = NULL;
if (FAILED(CreateDXGIFactory(__uuidof(IDXGIFactory) ,(void**)&pFactory))) {
std::cout << "CreateDXGIFactory failed\n";
return 1;
}
for (int i = 0; pFactory->EnumAdapters(i, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++i) {
IDXGIAdapter2* adapter2;
if (SUCCEEDED(pAdapter->QueryInterface( __uuidof(IDXGIAdapter2), ( LPVOID* )&adapter2))) {
DXGI_ADAPTER_DESC2 desc;
if (SUCCEEDED(adapter2->GetDesc2(&desc)))
std::cout << "VendorId: " << std::hex << desc.VendorId << std::endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment