本文整理汇总了C++中CreateDXGIFactory1函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateDXGIFactory1函数的具体用法?C++ CreateDXGIFactory1怎么用?C++ CreateDXGIFactory1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreateDXGIFactory1函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
IDXGIFactory1* factory = 0;
CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&factory);
IDXGIAdapter* adapter = NULL;
for (unsigned int index = 0; SUCCEEDED(factory->EnumAdapters(index, &adapter)); ++index)
{
DXGI_ADAPTER_DESC ad = {};
adapter->GetDesc(&ad);
if (ad.VendorId == 0x1414 && ad.DeviceId == 0x8c)
continue; // Skip Microsoft Basic Render Driver
printf("// GPU %d: %S (Vendor %04x Device %04x)\n", index, ad.Description, ad.VendorId, ad.DeviceId);
if (argc == 1)
{
testCache(adapter);
}
else if (argc > 1 && strcmp(argv[1], "--") == 0)
{
testCacheSequence(adapter, argc, argv);
}
else
{
testCacheMeshes(adapter, argc, argv);
}
}
}
示例2: CHECKED
void DesktopDuplication::init()
{
IDXGIFactory1* dxgiFactory = nullptr;
CHECKED(hr, CreateDXGIFactory1(__uuidof(IDXGIFactory1), reinterpret_cast<void**>(&dxgiFactory)));
IDXGIAdapter1* dxgiAdapter = nullptr;
CHECKED(hr, dxgiFactory->EnumAdapters1(adapter, &dxgiAdapter));
dxgiFactory->Release();
CHECKED(hr, D3D11CreateDevice(dxgiAdapter,
D3D_DRIVER_TYPE_UNKNOWN,
NULL,
NULL,
NULL,
NULL,
D3D11_SDK_VERSION,
&d3dDevice,
NULL,
&d3dContext));
IDXGIOutput* dxgiOutput = nullptr;
CHECKED(hr, dxgiAdapter->EnumOutputs(output, &dxgiOutput));
dxgiAdapter->Release();
IDXGIOutput1* dxgiOutput1 = nullptr;
CHECKED(hr, dxgiOutput->QueryInterface(__uuidof(dxgiOutput1), reinterpret_cast<void**>(&dxgiOutput1)));
dxgiOutput->Release();
IDXGIDevice* dxgiDevice = nullptr;
CHECKED(hr, d3dDevice->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&dxgiDevice)));
CHECKED(hr, dxgiOutput1->DuplicateOutput(dxgiDevice, &outputDuplication));
dxgiOutput1->Release();
dxgiDevice->Release();
}
示例3: EnumD3DAdapters
static inline void EnumD3DAdapters(
bool (*callback)(void*, const char*, uint32_t),
void *param)
{
ComPtr<IDXGIFactory1> factory;
ComPtr<IDXGIAdapter1> adapter;
HRESULT hr;
UINT i = 0;
IID factoryIID = (GetWinVer() >= 0x602) ? dxgiFactory2 :
__uuidof(IDXGIFactory1);
hr = CreateDXGIFactory1(factoryIID, (void**)factory.Assign());
if (FAILED(hr))
throw HRError("Failed to create DXGIFactory", hr);
while (factory->EnumAdapters1(i++, adapter.Assign()) == S_OK) {
DXGI_ADAPTER_DESC desc;
char name[512] = "";
hr = adapter->GetDesc(&desc);
if (FAILED(hr))
continue;
/* ignore microsoft's 'basic' renderer' */
if (desc.VendorId == 0x1414 && desc.DeviceId == 0x8c)
continue;
os_wcs_to_utf8(desc.Description, 0, name, sizeof(name));
if (!callback(param, name, i - 1))
break;
}
}
示例4: printf
IDXGIAdapter* spoutDirectX::GetAdapterPointer(int index)
{
// printf("spoutDirectX::GetAdapterPointer(%d)\n", index);
// Enum Adapters first : multiple video cards
IDXGIFactory1* _dxgi_factory1;
if ( FAILED( CreateDXGIFactory1( __uuidof(IDXGIFactory1), (void**)&_dxgi_factory1 ) ) ) {
printf( " Could not create CreateDXGIFactory1\n" );
return nullptr;
}
IDXGIAdapter* adapter1_ptr = nullptr;
for ( UINT32 i = 0; _dxgi_factory1->EnumAdapters( i, &adapter1_ptr ) != DXGI_ERROR_NOT_FOUND; i++ ) {
if ( index == (int)i ) {
// printf(" Adapter %d matches\n", i);
// Now we have the requested adapter, but does it support the required extensions
_dxgi_factory1->Release();
return adapter1_ptr;
}
else {
// printf(" Adapter %d found\n", i);
}
adapter1_ptr->Release();
}
// printf(" Adapter %d not found\n", index);
_dxgi_factory1->Release();
return nullptr;
}
示例5: __uuidof
bool CDuplicateOutputDx11::GetSpecificAdapter(int idAdapter, IDXGIAdapter** pAdapter)
{
HRESULT err = S_OK;
if (!pAdapter)
{
return false;
}
REFIID iidVal = __uuidof(IDXGIFactory1);
UINT adapterID = 0; // adapter index
IDXGIFactory1* pFactory = NULL;
if (FAILED(err = CreateDXGIFactory1(iidVal, (void**)&pFactory)))
{
return false;
}
UINT i = 0;
UINT adapterDeviceID = idAdapter; // if device id equal zero, use the first device
DXGI_ADAPTER_DESC dxgiDesc;
IDXGIAdapter1 *giAdapter = NULL;
if (pFactory->EnumAdapters1(i, &giAdapter) != S_OK)
{
return false;
}
if (pFactory)pFactory->Release();
*pAdapter = giAdapter;
return true;
}
示例6: GetAdapterName
// Get an adapter name
bool spoutDirectX::GetAdapterName(int index, char *adaptername, int maxchars)
{
IDXGIFactory1* _dxgi_factory1;
IDXGIAdapter* adapter1_ptr = nullptr;
UINT32 i;
if ( FAILED( CreateDXGIFactory1( __uuidof(IDXGIFactory1), (void**)&_dxgi_factory1 ) ) )
return false;
for ( i = 0; _dxgi_factory1->EnumAdapters( i, &adapter1_ptr ) != DXGI_ERROR_NOT_FOUND; i++ ) {
if((int)i == index) {
DXGI_ADAPTER_DESC desc;
adapter1_ptr->GetDesc( &desc );
adapter1_ptr->Release();
size_t charsConverted = 0;
wcstombs_s(&charsConverted, adaptername, maxchars, desc.Description, maxchars-1);
// Is the adapter compatible ?
// TODO : test for Intel graphics version ?
// 11.08.15 - removed for use with Intel HD4400/5000 graphics
// if(strstr(adaptername, "Intel")) {
// printf("Intel graphics not supported\n");
// return false;
// }
_dxgi_factory1->Release();
return true;
}
}
_dxgi_factory1->Release();
return false;
}
示例7: GetAdapterInfo
bool spoutDirectX::GetAdapterInfo(char *adapter, char *display, int maxchars)
{
IDXGIFactory1* _dxgi_factory1;
IDXGIAdapter* adapter1_ptr = nullptr;
UINT32 i;
size_t charsConverted = 0;
// Enum Adapters first : multiple video cards
if ( FAILED( CreateDXGIFactory1( __uuidof(IDXGIFactory1), (void**)&_dxgi_factory1 ) ) )
return false;
for ( i = 0; _dxgi_factory1->EnumAdapters( i, &adapter1_ptr ) != DXGI_ERROR_NOT_FOUND; i++ ) {
DXGI_ADAPTER_DESC desc;
adapter1_ptr->GetDesc( &desc );
// Return the current adapter - max of 2 assumed
wcstombs_s(&charsConverted, adapter, maxchars, desc.Description, maxchars-1);
IDXGIOutput* p_output = nullptr;
for ( UINT32 j = 0; adapter1_ptr->EnumOutputs( j, &p_output ) != DXGI_ERROR_NOT_FOUND; j++ ) {
DXGI_OUTPUT_DESC desc_out;
p_output->GetDesc( &desc_out );
if(desc_out.AttachedToDesktop)
wcstombs_s(&charsConverted, display, maxchars, desc.Description, maxchars-1);
if( p_output )
p_output->Release();
}
}
_dxgi_factory1->Release();
return true;
}
示例8:
CD3DRenderer::CD3DRenderer(HWND& window)
{
m_hWnd = window;
if(FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&m_pdxgiFactory)))
g_pDebug->printError("Failed to create DXGI Factory.");
IDXGIAdapter1 * pAdapter;
for (UINT i = 0;
m_pdxgiFactory->EnumAdapters1(i, &pAdapter) != DXGI_ERROR_NOT_FOUND;
++i)
m_vAdapters.push_back(pAdapter);
IDXGIOutput *pOutput;
m_vAdapters[m_uiCurrentAdapter]->EnumOutputs(0, &pOutput);
UINT modeCount;
pOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &modeCount, nullptr);
DXGI_MODE_DESC *descArr = new DXGI_MODE_DESC[modeCount];
pOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &modeCount, descArr);
for (UINT i = 0; i < modeCount; i++)
{
if (descArr[i].RefreshRate.Numerator / descArr[i].RefreshRate.Denominator <= 60)
m_vAdapterModes.push_back(descArr[i]);
}
pOutput->Release();
delete[] descArr;
}
示例9: create_device
BOOL CALLBACK create_device(PINIT_ONCE ignored, void *ignored2,
void **ignored3) {
debug_log("creating device");
HRESULT hr;
hr = CreateDXGIFactory1(__uuidof(IDXGIFactory2), (void **)&dxgi_factory);
assert(hr == S_OK);
hr = dxgi_factory->EnumAdapters1(0, &dxgi_adapter);
assert(hr == S_OK);
hr = dxgi_adapter->EnumOutputs(0, &dxgi_output);
assert(hr == S_OK);
hr = dxgi_output->QueryInterface(__uuidof(IDXGIOutput1),
(void **)&dxgi_output1);
assert(hr == S_OK);
const D3D_FEATURE_LEVEL levels[] = { D3D_FEATURE_LEVEL_11_0 };
D3D_FEATURE_LEVEL out_level;
UINT flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#ifndef NDEBUG
flags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
hr = D3D11CreateDevice(dxgi_adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, flags,
levels, 1, D3D11_SDK_VERSION, &device, &out_level, &context);
assert(hr == S_OK);
hr = dxgi_output1->DuplicateOutput(device, &dxgi_output_duplication);
assert(hr == S_OK);
InitializeCriticalSection(&directx_critical_section);
return TRUE;
}
示例10: find_output
static HRESULT find_output()
{
CComPtr<IDXGIFactory1> pFactory;
HRESULT hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void **)(&pFactory));
for (UINT i = 0; ; i++) {
CComPtr<IDXGIAdapter1> pAdapter;
if (S_OK != (hr = pFactory->EnumAdapters1(i, &pAdapter))) {
break;
}
aslog::info(L"Found adapter %d", i);
for (UINT j = 0; ; j++) {
CComPtr<IDXGIOutput> pOutput;
if (S_OK != (hr = pAdapter->EnumOutputs(j, &pOutput))) {
break;
}
aslog::info(L"Found output %d-%d", i, j);
DXGI_OUTPUT_DESC desc;
pOutput->GetDesc(&desc);
aslog::info(L"Output %d-%d name: %s", i, j, desc.DeviceName);
aslog::info(L"Output %d-%d attached to desktop: %s", i, j, desc.AttachedToDesktop ? L"true" : L"false");
g_pAdapter = pAdapter;
g_pOutput = pOutput;
hr = D3D11CreateDevice(pAdapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, D3D11_CREATE_DEVICE_DEBUG, NULL, 0, D3D11_SDK_VERSION, &g_pDevice, NULL, &g_pContext);
return hr;
}
}
return hr;
}
示例11: GetDisplayDevices
void GetDisplayDevices(DeviceOutputs &deviceList)
{
HRESULT err;
deviceList.ClearData();
#ifdef USE_DXGI1_2
REFIID iidVal = OSGetVersion() >= 8 ? __uuidof(IDXGIFactory2) : __uuidof(IDXGIFactory1);
#else
REFIIF iidVal = __uuidof(IDXGIFactory1);
#endif
IDXGIFactory1 *factory;
if(SUCCEEDED(err = CreateDXGIFactory1(iidVal, (void**)&factory)))
{
UINT i=0;
IDXGIAdapter1 *giAdapter;
while(factory->EnumAdapters1(i++, &giAdapter) == S_OK)
{
Log(TEXT("------------------------------------------"));
DXGI_ADAPTER_DESC adapterDesc;
if(SUCCEEDED(err = giAdapter->GetDesc(&adapterDesc)))
{
if (adapterDesc.DedicatedVideoMemory != 0) {
DeviceOutputData &deviceData = *deviceList.devices.CreateNew();
deviceData.strDevice = adapterDesc.Description;
UINT j=0;
IDXGIOutput *giOutput;
while(giAdapter->EnumOutputs(j++, &giOutput) == S_OK)
{
DXGI_OUTPUT_DESC outputDesc;
if(SUCCEEDED(giOutput->GetDesc(&outputDesc)))
{
if(outputDesc.AttachedToDesktop)
{
deviceData.monitorNameList << outputDesc.DeviceName;
MonitorInfo &monitorInfo = *deviceData.monitors.CreateNew();
monitorInfo.hMonitor = outputDesc.Monitor;
mcpy(&monitorInfo.rect, &outputDesc.DesktopCoordinates, sizeof(RECT));
}
}
giOutput->Release();
}
}
}
else
AppWarning(TEXT("Could not query adapter %u"), i);
giAdapter->Release();
}
factory->Release();
}
}
示例12: CreateWindowsAdapter
std::unique_ptr< WindowsAdapter > CreateWindowsAdapter( const int id ) noexcept {
ComPtr< IDXGIFactory1 > factory;
auto hresult = CreateDXGIFactory1( __uuidof( IDXGIFactory1 ), reinterpret_cast< void** >( &factory ) );
if ( FAILED( hresult ) ) {
return nullptr;
}
return CreateAdapter( factory, id );
}
示例13: HookDXGIFactory
HRESULT WINAPI HookDXGIFactory(REFIID riid, void **ppFactory)
{
// We need shared texture support for OpenVR, so force DXGI 1.0 games to use DXGI 1.1
IDXGIFactory1* pDXGIFactory;
HRESULT hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void **)&pDXGIFactory);
if (FAILED(hr))
return hr;
return pDXGIFactory->QueryInterface(riid, ppFactory);
}
示例14: FindNVIDIA
// LJ DEBUG
bool spoutDirectX::FindNVIDIA(int &nAdapter)
{
IDXGIFactory1* _dxgi_factory1;
IDXGIAdapter* adapter1_ptr = nullptr;
DXGI_ADAPTER_DESC desc;
// DXGI_OUTPUT_DESC desc_out;
UINT32 i;
bool bFound = false;
if ( FAILED( CreateDXGIFactory1( __uuidof(IDXGIFactory1), (void**)&_dxgi_factory1 ) ) )
return false;
for ( i = 0; _dxgi_factory1->EnumAdapters( i, &adapter1_ptr ) != DXGI_ERROR_NOT_FOUND; i++ ) {
adapter1_ptr->GetDesc( &desc );
printf( "Adapter(%d) : %S\n", i, desc.Description );
/*
IDXGIOutput* p_output = nullptr;
if(adapter1_ptr->EnumOutputs(0, &p_output ) == DXGI_ERROR_NOT_FOUND) {
printf(" No outputs\n");
continue;
}
for ( UINT32 j = 0; adapter1_ptr->EnumOutputs( j, &p_output ) != DXGI_ERROR_NOT_FOUND; j++ ) {
p_output->GetDesc( &desc_out );
// printf( " Output : %d\n", j );
// printf( " Name %S\n", desc_out.DeviceName );
// printf( " Attached to desktop : (%d) %s\n", desc_out.AttachedToDesktop, desc_out.AttachedToDesktop ? "yes" : "no" );
// printf( " Rotation : %d\n", desc_out.Rotation );
// printf( " Left : %d\n", desc_out.DesktopCoordinates.left );
// printf( " Top : %d\n", desc_out.DesktopCoordinates.top );
// printf( " Right : %d\n", desc_out.DesktopCoordinates.right );
// printf( " Bottom : %d\n", desc_out.DesktopCoordinates.bottom );
if( p_output )
p_output->Release();
}
*/
if(wcsstr(desc.Description, L"NVIDIA")) {
// printf("Found NVIDIA adapter %d (%S)\n", i, desc.Description);
bFound = true;
break;
}
}
_dxgi_factory1->Release();
if(bFound) {
printf("Found NVIDIA adapter %d (%S)\n", i, desc.Description);
nAdapter = i;
return true;
}
return false;
}
示例15: GetNumAdapters
// Get the number of graphics adapters in the system
int spoutDirectX::GetNumAdapters()
{
IDXGIFactory1* _dxgi_factory1;
IDXGIAdapter* adapter1_ptr = nullptr;
UINT32 i;
// printf("spoutDirectX::GetNumAdapters\n");
// Enum Adapters first : multiple video cards
if ( FAILED( CreateDXGIFactory1( __uuidof(IDXGIFactory1), (void**)&_dxgi_factory1 ) ) )
return 0;
for ( i = 0; _dxgi_factory1->EnumAdapters( i, &adapter1_ptr ) != DXGI_ERROR_NOT_FOUND; i++ ) {
// DXGI_ADAPTER_DESC desc;
// adapter1_ptr->GetDesc( &desc );
// printf( "Adapter : %S\n", desc.Description );
// adapter1_ptr->Release();
// printf( "bdd_spout : D3D11 Adapter %d found\n", i );
DXGI_ADAPTER_DESC desc;
adapter1_ptr->GetDesc( &desc );
printf( "Adapter(%d) : %S\n", i, desc.Description );
printf( " Vendor Id : %d\n", desc.VendorId );
// printf( " Dedicated System Memory : %.0f MiB\n", (float)desc.DedicatedSystemMemory / (1024.f * 1024.f) );
// printf( " Dedicated Video Memory : %.0f MiB\n", (float)desc.DedicatedVideoMemory / (1024.f * 1024.f) );
// printf( " Shared System Memory : %.0f MiB\n", (float)desc.SharedSystemMemory / (1024.f * 1024.f) );
IDXGIOutput* p_output = nullptr;
if(adapter1_ptr->EnumOutputs(0, &p_output ) == DXGI_ERROR_NOT_FOUND) {
printf(" No outputs\n");
}
for ( UINT32 j = 0; adapter1_ptr->EnumOutputs( j, &p_output ) != DXGI_ERROR_NOT_FOUND; j++ ) {
DXGI_OUTPUT_DESC desc_out;
p_output->GetDesc( &desc_out );
printf( " Output : %d\n", j );
printf( " Name %S\n", desc_out.DeviceName );
printf( " Attached to desktop : (%d) %s\n", desc_out.AttachedToDesktop, desc_out.AttachedToDesktop ? "yes" : "no" );
printf( " Rotation : %d\n", desc_out.Rotation );
printf( " Left : %d\n", desc_out.DesktopCoordinates.left );
printf( " Top : %d\n", desc_out.DesktopCoordinates.top );
printf( " Right : %d\n", desc_out.DesktopCoordinates.right );
printf( " Bottom : %d\n", desc_out.DesktopCoordinates.bottom );
if( p_output )
p_output->Release();
}
}
_dxgi_factory1->Release();
return (int)i;
}