本文整理汇总了C++中IDXGIAdapter1::GetDesc方法的典型用法代码示例。如果您正苦于以下问题:C++ IDXGIAdapter1::GetDesc方法的具体用法?C++ IDXGIAdapter1::GetDesc怎么用?C++ IDXGIAdapter1::GetDesc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDXGIAdapter1
的用法示例。
在下文中一共展示了IDXGIAdapter1::GetDesc方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
示例2: LogVideoCardStats
void LogVideoCardStats()
{
HRESULT err;
#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)
{
DXGI_ADAPTER_DESC adapterDesc;
if(SUCCEEDED(err = giAdapter->GetDesc(&adapterDesc)))
{
if (!(adapterDesc.VendorId == 0x1414 && adapterDesc.DeviceId == 0x8c)) { // Ignore Microsoft Basic Render Driver
Log(TEXT("------------------------------------------"));
Log(TEXT("Adapter %u"), i);
Log(TEXT(" Video Adapter: %s"), adapterDesc.Description);
Log(TEXT(" Video Adapter Dedicated Video Memory: %u"), adapterDesc.DedicatedVideoMemory);
Log(TEXT(" Video Adapter Shared System Memory: %u"), adapterDesc.SharedSystemMemory);
UINT j = 0;
IDXGIOutput *output;
while(SUCCEEDED(giAdapter->EnumOutputs(j++, &output)))
{
DXGI_OUTPUT_DESC desc;
if(SUCCEEDED(output->GetDesc(&desc)))
Log(TEXT(" Video Adapter Output %u: pos={%d, %d}, size={%d, %d}, attached=%s"), j,
desc.DesktopCoordinates.left, desc.DesktopCoordinates.top,
desc.DesktopCoordinates.right-desc.DesktopCoordinates.left, desc.DesktopCoordinates.bottom-desc.DesktopCoordinates.top,
desc.AttachedToDesktop ? L"true" : L"false");
output->Release();
}
}
}
else
AppWarning(TEXT("Could not query adapter %u"), i);
giAdapter->Release();
}
factory->Release();
}
}
示例3: LogVideoCardStats
void LogVideoCardStats()
{
HRESULT err;
#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)
{
DXGI_ADAPTER_DESC adapterDesc;
if(SUCCEEDED(err = giAdapter->GetDesc(&adapterDesc)))
{
if (adapterDesc.DedicatedVideoMemory > 0) {
Log(TEXT("------------------------------------------"));
Log(TEXT("Adapter %u"), i);
Log(TEXT(" Video Adapter: %s"), adapterDesc.Description);
Log(TEXT(" Video Adapter Dedicated Video Memory: %u"), adapterDesc.DedicatedVideoMemory);
Log(TEXT(" Video Adapter Shared System Memory: %u"), adapterDesc.SharedSystemMemory);
}
}
else
AppWarning(TEXT("Could not query adapter %u"), i);
giAdapter->Release();
}
factory->Release();
}
}
示例4: sizeof
bool Direct3D::Initialize(int _screenWidth, int _screenHeight, bool _vsync, HWND _hwnd, bool _fullscreen, float _screenDepth, float _screenNear, TextClass* _timer)
{
HRESULT result;
IDXGIFactory1* factory;
IDXGIAdapter1* adapter;
IDXGIOutput* adapterOutput;
unsigned int numModes, i, numerator, denominator, stringLength;
DXGI_MODE_DESC* displayModeList;
DXGI_ADAPTER_DESC adapterDesc;
int error;
DXGI_SWAP_CHAIN_DESC swapChainDesc;
D3D_FEATURE_LEVEL featureLevel;
ID3D11Texture2D* backBufferPtr;
D3D11_TEXTURE2D_DESC depthBufferDesc;
D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc;
D3D11_RASTERIZER_DESC rasterDesc;
float fieldOfView, screenAspect;
D3D11_BLEND_DESC blendStateDescription;
bool success;
// Store the vsync setting.
vsync_enabled = _vsync;
// Create a DirectX graphics interface factory.
result = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&factory);
if (FAILED(result))
{
return false;
}
// Use the factory to create an adapter for the primary graphics interface (video card).
result = factory->EnumAdapters1(0, &adapter);
if (FAILED(result))
{
return false;
}
// Enumerate the primary adapter output (monitor).
result = adapter->EnumOutputs(0, &adapterOutput);
if (FAILED(result))
{
return false;
}
// Get the number of modes that fit the DXGI_FORMAT_R8G8B8A8_UNORM display format for the adapter output (monitor).
result = adapterOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, NULL);
if (FAILED(result))
{
return false;
}
// Create a list to hold all the possible display modes for this monitor/video card combination.
displayModeList = new DXGI_MODE_DESC[numModes];
if (!displayModeList)
{
return false;
}
// Now fill the display mode list structures.
result = adapterOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, displayModeList);
if (FAILED(result))
{
return false;
}
// Now go through all the display modes and find the one that matches the screen width and height.
// When a match is found store the numerator and denominator of the refresh rate for that monitor.
for (i = 0; i<numModes; i++)
{
if (displayModeList[i].Width == (unsigned int)_screenWidth)
{
if (displayModeList[i].Height == (unsigned int)_screenHeight)
{
numerator = displayModeList[i].RefreshRate.Numerator;
denominator = displayModeList[i].RefreshRate.Denominator;
}
}
}
// Get the adapter (video card) description.
result = adapter->GetDesc(&adapterDesc);
if (FAILED(result))
{
return false;
}
// Store the dedicated video card memory in megabytes.
videoCardMemory = (int)(adapterDesc.DedicatedVideoMemory / 1024 / 1024);
// Convert the name of the video card to a character array and store it.
error = wcstombs_s(&stringLength, videoCardDescription, 128, adapterDesc.Description, 128);
if (error != 0)
{
return false;
}
// Release the display mode list.
delete[] displayModeList;
//.........这里部分代码省略.........
示例5: Init
bool RenderCore::Init(int screenWidth, int screenHeight, HWND hWnd)
{
HRESULT hr;
IDXGIAdapter1 *adapter;
IDXGIOutput *adapterOutput;
IDXGIOutput1 *adapterOutput1;
DXGI_ADAPTER_DESC adapterDesc;
DXGI_MODE_DESC *displayModeList;
DXGI_SWAP_CHAIN_DESC swapChainDesc;
ID3D11Texture2D *pBackBuffer;
D3D11_TEXTURE2D_DESC depthBufferDesc;
D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
D3D11_DEPTH_STENCIL_DESC depthDisabledStencilDesc;
D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc;
D3D11_RASTERIZER_DESC rasterDesc;
uint32_t numModes, fpsNumerator, fpsDenominator;
size_t stringLength;
int error;
float fov, aspect;
if (!EnumerateDisplayAdapters(&g_DXGIAdapters)) {
return false;
}
adapter = g_DXGIAdapters.at(0);
hr = adapter->EnumOutputs(0, &adapterOutput);
if (FAILED(hr)) {
return false;
}
// desktop duplication stuff
hr = adapterOutput->QueryInterface(&adapterOutput1);
hr = adapterOutput1->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, nullptr);
if (FAILED(hr)) {
return false;
}
displayModeList = new DXGI_MODE_DESC[numModes];
if (!displayModeList) {
return false;
}
hr = adapterOutput1->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, displayModeList);
if (FAILED(hr)) {
return false;
}
for (UINT i = 0; i < numModes; i++) {
if (displayModeList[i].Width == (unsigned int)screenWidth) {
if (displayModeList[i].Height == (unsigned int)screenHeight) {
fpsNumerator = displayModeList[i].RefreshRate.Numerator;
fpsDenominator = displayModeList[i].RefreshRate.Denominator;
}
}
}
hr = adapter->GetDesc(&adapterDesc);
if (FAILED(hr)) {
return false;
}
// retrieve video adapter memory and name
m_VideoMemory = (int)(adapterDesc.DedicatedVideoMemory / 1024 / 1024);
error = wcstombs_s(&stringLength, m_VideoCardDesc, 128, adapterDesc.Description, 128);
if (error != 0) {
return false;
}
DebugOut("Found graphics adapter: %s (%dMB VRAM)\n", m_VideoCardDesc, m_VideoMemory);
delete[] displayModeList;
displayModeList = nullptr;
adapterOutput->Release();
adapter->Release();
// set single back buffer
ZeroMemory(&swapChainDesc, sizeof(swapChainDesc));
swapChainDesc.BufferCount = 1;
swapChainDesc.BufferDesc.Width = screenWidth;
swapChainDesc.BufferDesc.Height = screenHeight;
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.OutputWindow = hWnd;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.Windowed = true;
//swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
//swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
//swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
//swapChainDesc.Flags = 0;
//.........这里部分代码省略.........
示例6: OSGetVersion
D3D10System::D3D10System()
{
HRESULT err;
#ifdef USE_DXGI1_2
REFIID iidVal = OSGetVersion() >= 8 ? __uuidof(IDXGIFactory2) : __uuidof(IDXGIFactory1);
#else
REFIID iidVal = __uuidof(IDXGIFactory1);
#endif
UINT adapterID = GlobalConfig->GetInt(TEXT("Video"), TEXT("Adapter"), 0);
if(FAILED(err = CreateDXGIFactory1(iidVal, (void**)&factory)))
CrashError(TEXT("Could not create DXGI factory"));
IDXGIAdapter1 *adapter;
if(FAILED(err = factory->EnumAdapters1(adapterID, &adapter)))
CrashError(TEXT("Could not get DXGI adapter"));
//------------------------------------------------------------------
DXGI_SWAP_CHAIN_DESC swapDesc;
zero(&swapDesc, sizeof(swapDesc));
swapDesc.BufferCount = 2;
swapDesc.BufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
swapDesc.BufferDesc.Width = App->renderFrameWidth;
swapDesc.BufferDesc.Height = App->renderFrameHeight;
swapDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapDesc.OutputWindow = hwndRenderFrame;
swapDesc.SampleDesc.Count = 1;
swapDesc.Windowed = TRUE;
bDisableCompatibilityMode = 1;//AppConfig->GetInt(TEXT("Video"), TEXT("DisableD3DCompatibilityMode"), 1) != 0;
UINT createFlags = D3D10_CREATE_DEVICE_BGRA_SUPPORT;
if(GlobalConfig->GetInt(TEXT("General"), TEXT("UseDebugD3D")))
createFlags |= D3D10_CREATE_DEVICE_DEBUG;
D3D10_FEATURE_LEVEL1 level = bDisableCompatibilityMode ? D3D10_FEATURE_LEVEL_10_1 : D3D10_FEATURE_LEVEL_9_3;
String adapterName;
DXGI_ADAPTER_DESC desc;
if (adapter->GetDesc(&desc) == S_OK)
adapterName = desc.Description;
else
adapterName = TEXT("<unknown>");
adapterName.KillSpaces();
Log(TEXT("Loading up D3D10 on %s (Adapter %u)..."), adapterName.Array(), adapterID+1);
//D3D10_CREATE_DEVICE_DEBUG
//D3D11_DRIVER_TYPE_REFERENCE, D3D11_DRIVER_TYPE_HARDWARE
err = D3D10CreateDeviceAndSwapChain1(adapter, D3D10_DRIVER_TYPE_HARDWARE, NULL, createFlags, level, D3D10_1_SDK_VERSION, &swapDesc, &swap, &d3d);
if(FAILED(err))
{
bDisableCompatibilityMode = !bDisableCompatibilityMode;
level = bDisableCompatibilityMode ? D3D10_FEATURE_LEVEL_10_1 : D3D10_FEATURE_LEVEL_9_3;
err = D3D10CreateDeviceAndSwapChain1(adapter, D3D10_DRIVER_TYPE_HARDWARE, NULL, createFlags, level, D3D10_1_SDK_VERSION, &swapDesc, &swap, &d3d);
}
if(FAILED(err))
CrashError(TEXT("Could not initialize DirectX 10 on %s. This error can happen for one of the following reasons:\r\n\r\n1.) Your GPU is not supported (DirectX 10 is required - note that many integrated laptop GPUs do not support DX10)\r\n2.) You're running Windows Vista without the \"Platform Update\"\r\n3.) Your video card drivers are out of date\r\n\r\nIf you are using a laptop with NVIDIA Optimus or AMD Switchable Graphics, make sure OBS is set to run on the high performance GPU in your driver settings."), adapterName.Array());
adapter->Release();
//------------------------------------------------------------------
D3D10_DEPTH_STENCIL_DESC depthDesc;
zero(&depthDesc, sizeof(depthDesc));
depthDesc.DepthEnable = FALSE;
err = d3d->CreateDepthStencilState(&depthDesc, &depthState);
if(FAILED(err))
CrashError(TEXT("Unable to create depth state"));
d3d->OMSetDepthStencilState(depthState, 0);
//------------------------------------------------------------------
D3D10_RASTERIZER_DESC rasterizerDesc;
zero(&rasterizerDesc, sizeof(rasterizerDesc));
rasterizerDesc.FillMode = D3D10_FILL_SOLID;
rasterizerDesc.CullMode = D3D10_CULL_NONE;
rasterizerDesc.FrontCounterClockwise = FALSE;
rasterizerDesc.DepthClipEnable = TRUE;
err = d3d->CreateRasterizerState(&rasterizerDesc, &rasterizerState);
if(FAILED(err))
CrashError(TEXT("Unable to create rasterizer state"));
d3d->RSSetState(rasterizerState);
//------------------------------------------------------------------
rasterizerDesc.ScissorEnable = TRUE;
err = d3d->CreateRasterizerState(&rasterizerDesc, &scissorState);
if(FAILED(err))
CrashError(TEXT("Unable to create scissor state"));
//.........这里部分代码省略.........