本文整理汇总了C++中IDXGIOutput::QueryInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ IDXGIOutput::QueryInterface方法的具体用法?C++ IDXGIOutput::QueryInterface怎么用?C++ IDXGIOutput::QueryInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDXGIOutput
的用法示例。
在下文中一共展示了IDXGIOutput::QueryInterface方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
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();
}
示例2:
bool CDuplicateOutputDx11::CreateOutputDuplicator()
{
SAFE_RELEASE(m_pOutputDuplication);
HRESULT hRes = S_OK;
IDXGIDevice* pDxgiDevice = nullptr;
hRes = m_pDevice->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&pDxgiDevice));
if (!SUCCEEDED(hRes))
{
DOLOG("m_pDevice->QueryInterface failed!");
return false;
}
IDXGIAdapter* pDxgiAdapter = nullptr;
hRes = pDxgiDevice->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast<void**>(&pDxgiAdapter));
SAFE_RELEASE(pDxgiDevice);
if (!SUCCEEDED(hRes))
{
DOLOG("pDxgiDevice->GetParent failed!");
return false;
}
DXGI_ADAPTER_DESC descAdapter;
pDxgiAdapter->GetDesc(&descAdapter);
// Get output
IDXGIOutput* pDxgiOutput = nullptr;
hRes = pDxgiAdapter->EnumOutputs(0, &pDxgiOutput);
SAFE_RELEASE(pDxgiAdapter);
if (!SUCCEEDED(hRes))
{
DOLOG("pDxgiAdapter->EnumOutputs failed!");
return false;
}
// Get output1
IDXGIOutput1* pDxgiOutput1 = nullptr;
hRes = pDxgiOutput->QueryInterface(__uuidof(IDXGIOutput1), reinterpret_cast<void**>(&pDxgiOutput1));
SAFE_RELEASE(pDxgiOutput);
if (!SUCCEEDED(hRes))
{
DOLOG("pDxgiOutput->QueryInterface failed!");
return false;
}
// Get duplicate
hRes = pDxgiOutput1->DuplicateOutput(m_pDevice, &m_pOutputDuplication);
SAFE_RELEASE(pDxgiOutput1);
if (!SUCCEEDED(hRes))
{
DOLOG("pDxgiOutput1->DuplicateOutput");
return false;
}
return true;
}
示例3: main
//.........这里部分代码省略.........
printf("Error: failed to create the D3D11 Device.\n");
if (E_INVALIDARG == hr) {
printf("Got INVALID arg passed into D3D11CreateDevice. Did you pass a adapter + a driver which is not the UNKNOWN driver?.\n");
}
exit(EXIT_FAILURE);
}
} /* End creating a D3D11 device. */
/*
Create a IDXGIOutputDuplication for the first monitor.
- From a IDXGIOutput which represents an monitor, we query a IDXGIOutput1
because the IDXGIOutput1 has the DuplicateOutput feature.
*/
IDXGIOutput1* output1 = NULL;
IDXGIOutputDuplication* duplication = NULL;
{ /* Start IDGIOutputDuplication init. */
int use_monitor = 0;
if (use_monitor >= outputs.size()) {
printf("Invalid monitor index: %d, we only have: %lu - 1\n", use_monitor, outputs.size());
exit(EXIT_FAILURE);
}
output = outputs[use_monitor];
if (NULL == output) {
printf("No valid output found. The output is NULL.\n");
exit(EXIT_FAILURE);
}
hr = output->QueryInterface(__uuidof(IDXGIOutput1), (void**)&output1);
if (S_OK != hr) {
printf("Error: failed to query the IDXGIOutput1 interface.\n");
exit(EXIT_FAILURE);
}
hr = output1->DuplicateOutput(d3d_device, &duplication);
if (S_OK != hr) {
printf("Error: failed to create the duplication output.\n");
exit(EXIT_FAILURE);
}
printf("Queried the IDXGIOutput1.\n");
} /* End IDGIOutputDuplication init. */
if (NULL == duplication) {
printf("Error: okay, we shouldn't arrive here but the duplication var is NULL.\n");
exit(EXIT_FAILURE);
}
/*
To download the pixel data from the GPU we need a
staging texture. Therefore we need to determine the width and
height of the buffers that we receive.
@TODO - We could also retrieve the width/height from the texture we got
from through the acquired frame (see the 'tex' variable below).
That may be a safer solution.
*/
DXGI_OUTPUT_DESC output_desc;
{
hr = output->GetDesc(&output_desc);
if (S_OK != hr) {
示例4: InitDupl
//
// Initialize duplication interfaces
//
DUPL_RETURN DUPLICATIONMANAGER::InitDupl(_In_ ID3D11Device* Device, UINT Output)
{
m_OutputNumber = Output;
// Take a reference on the device
m_Device = Device;
m_Device->AddRef();
// Get DXGI device
IDXGIDevice* DxgiDevice = nullptr;
HRESULT hr = m_Device->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&DxgiDevice));
if (FAILED(hr))
{
return ProcessFailure(nullptr, L"Failed to QI for DXGI Device", L"Error", hr);
}
// Get DXGI adapter
IDXGIAdapter* DxgiAdapter = nullptr;
hr = DxgiDevice->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast<void**>(&DxgiAdapter));
DxgiDevice->Release();
DxgiDevice = nullptr;
if (FAILED(hr))
{
return ProcessFailure(m_Device, L"Failed to get parent DXGI Adapter", L"Error", hr, SystemTransitionsExpectedErrors);
}
// Get output
IDXGIOutput* DxgiOutput = nullptr;
hr = DxgiAdapter->EnumOutputs(Output, &DxgiOutput);
DxgiAdapter->Release();
DxgiAdapter = nullptr;
if (FAILED(hr))
{
return ProcessFailure(m_Device, L"Failed to get specified output in DUPLICATIONMANAGER", L"Error", hr, EnumOutputsExpectedErrors);
}
DxgiOutput->GetDesc(&m_OutputDesc);
// QI for Output 1
IDXGIOutput1* DxgiOutput1 = nullptr;
hr = DxgiOutput->QueryInterface(__uuidof(DxgiOutput1), reinterpret_cast<void**>(&DxgiOutput1));
DxgiOutput->Release();
DxgiOutput = nullptr;
if (FAILED(hr))
{
return ProcessFailure(nullptr, L"Failed to QI for DxgiOutput1 in DUPLICATIONMANAGER", L"Error", hr);
}
// Create desktop duplication
hr = DxgiOutput1->DuplicateOutput(m_Device, &m_DeskDupl);
DxgiOutput1->Release();
DxgiOutput1 = nullptr;
if (FAILED(hr))
{
if (hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE)
{
MessageBoxW(nullptr, L"There is already the maximum number of applications using the Desktop Duplication API running, please close one of those applications and then try again.", L"Error", MB_OK);
return DUPL_RETURN_ERROR_UNEXPECTED;
}
return ProcessFailure(m_Device, L"Failed to get duplicate output in DUPLICATIONMANAGER", L"Error", hr, CreateDuplicationExpectedErrors);
}
return DUPL_RETURN_SUCCESS;
}
示例5: printf
int ScreenCaptureDuplicateOutputDirect3D11::configure(Settings cfg) {
HRESULT hr = E_FAIL;
/* Validate input. */
if (cfg.display >= displays.size()) {
printf("Error: given display index is invalid; out of bounds.\n");
return -1;
}
if (NULL == device) {
printf("Error: the D3D11 device is NULL. Did you call init?\n");
return -2;
}
if (SC_BGRA != cfg.pixel_format) {
printf("Trying to configure the Screen Capture, but we received an unsupported pixel format. %d\n", cfg.pixel_format);
return -3;
}
/* Check state */
if (NULL != output) {
output->Release();
output = NULL;
}
if (NULL != duplication) {
duplication->Release();
duplication = NULL;
}
if (0 != pixel_buffer.init(cfg.output_width, cfg.output_height, cfg.pixel_format)) {
printf("Error: failed to initialize the pixel buffer.");
return -4;
}
/* @todo > WE DON'T WANT TO MAKE THIS THE RESPONSIBILITY OF AN IMPLEMENTATION! */
pixel_buffer.user = user;
/*
When the renderer is already initialized, we first deallocate/release
all created objects that are used to perform the scaling.
*/
if (0 == renderer.isInit()) {
renderer.shutdown();
}
/* We can only initialize the transform, after we know the output width/height. */
ScreenCaptureRendererSettingsDirect3D11 trans_cfg;
trans_cfg.device = device;
trans_cfg.context = context;
trans_cfg.output_width = cfg.output_width;
trans_cfg.output_height = cfg.output_height;
trans_cfg.cb_scaled = on_scaled_pixels;
trans_cfg.cb_user = this;
if (0 != renderer.init(trans_cfg)) {
printf("Error: failed to initialize the tansform for the screen capture.\n");
return -5;
}
Display* display = displays[cfg.display];
if (NULL == display->info) {
printf("Error: The display doesn't a valid info member. Not supposed to happen.\n");
return -6;
}
IDXGIOutput* monitor = static_cast<IDXGIOutput*>(display->info);
if (NULL == monitor) {
printf("Error: failed to cast the info member of the display to IDXGIOutput*.\n");
return -7;
}
hr = monitor->QueryInterface(__uuidof(IDXGIOutput1), (void**)&output);
if (S_OK != hr) {
printf("Error: failed to query the IDXGIOutput1 which exposes the Output Duplication interface.\n");
return -8;
}
hr = output->DuplicateOutput(device, &duplication);
if (S_OK != hr) {
printf("Error: failed to duplicate the output.\n");
output->Release();
output = NULL;
return -9;
}
/* Get info about the output (monitor). */
ZeroMemory(&output_desc, sizeof(output_desc));
hr = output->GetDesc(&output_desc);
if (S_OK != hr) {
printf("Error: failed to retrieve output information.\n");
output->Release();
duplication->Release();
output = NULL;
duplication = NULL;
return -10;
}
//.........这里部分代码省略.........
示例6: 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;
//.........这里部分代码省略.........