本文整理汇总了C++中IDXGIAdapter::GetParent方法的典型用法代码示例。如果您正苦于以下问题:C++ IDXGIAdapter::GetParent方法的具体用法?C++ IDXGIAdapter::GetParent怎么用?C++ IDXGIAdapter::GetParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDXGIAdapter
的用法示例。
在下文中一共展示了IDXGIAdapter::GetParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SafeRelease
static IDXGIFactory *GetDXGIFactoryFromDevice(ID3D11Device *device)
{
IDXGIDevice *dxgiDevice = nullptr;
HRESULT result =
device->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void **>(&dxgiDevice));
if (FAILED(result))
{
return nullptr;
}
IDXGIAdapter *dxgiAdapter = nullptr;
result = dxgiDevice->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast<void **>(&dxgiAdapter));
SafeRelease(dxgiDevice);
if (FAILED(result))
{
return nullptr;
}
IDXGIFactory *dxgiFactory = nullptr;
result =
dxgiAdapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void **>(&dxgiFactory));
SafeRelease(dxgiAdapter);
if (FAILED(result))
{
return nullptr;
}
return dxgiFactory;
}
示例2:
bool DX11Engine::CreateSwapChain(HWND handle, UINT xSize, UINT ySize)
{
mXsize = xSize;
mYSize = ySize;
IDXGIDevice* dxgiDevice = nullptr;
HRESULT hr = m_pDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice);
if (hr != S_OK)
{
return false;
}
IDXGIAdapter* dxgiAdapter = nullptr;
hr = dxgiDevice->GetAdapter(&dxgiAdapter);
if (hr != S_OK)
{
return false;
}
IDXGIFactory1* dxgiFactory1 = nullptr;
hr = dxgiAdapter->GetParent(__uuidof(IDXGIFactory1), (void**)&dxgiFactory1);
if (hr != S_OK)
{
return false;
}
DXGI_SWAP_CHAIN_DESC desc;
desc.BufferDesc.Width = xSize;
desc.BufferDesc.Height = ySize;
desc.BufferDesc.RefreshRate.Numerator = 0;
desc.BufferDesc.RefreshRate.Denominator = 1;
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.BufferUsage = DXGI_USAGE_BACK_BUFFER | DXGI_USAGE_RENDER_TARGET_OUTPUT;
desc.BufferCount = 2;
desc.OutputWindow = handle;
desc.Windowed = TRUE;
desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
desc.Flags = 0;
hr = dxgiFactory1->CreateSwapChain(dxgiDevice, &desc, &m_pSwapChain);
if (hr != S_OK)
{
return false;
}
dxgiDevice->Release();
dxgiAdapter->Release();
dxgiFactory1->Release();
return true;
}
示例3:
void D3D11RenderWindow::_createSwapChain()
{
// Fill out a DXGI_SWAP_CHAIN_DESC to describe our swap chain.
DXGI_SWAP_CHAIN_DESC sd;
sd.BufferDesc.Width = mWidth;
sd.BufferDesc.Height = mHeight;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
// Use 4X MSAA?
if (mEnable4xMsaa)
{
sd.SampleDesc.Count = 4;
sd.SampleDesc.Quality = m4xMsaaQuality - 1;
}
// No MSAA
else
{
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
}
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferCount = 2;
sd.OutputWindow = mhMainWnd;
sd.Windowed = true;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
sd.Flags = 0;
// To correctly create the swap chain, we must use the IDXGIFactory that was
// used to create the device. If we tried to use a different IDXGIFactory instance
// (by calling CreateDXGIFactory), we get an error: "IDXGIFactory::CreateSwapChain:
// This function is being called with a device from a different IDXGIFactory."
IDXGIDevice* dxgiDevice = 0;
HR(md3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice));
IDXGIAdapter* dxgiAdapter = 0;
HR(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter));
IDXGIFactory* dxgiFactory = 0;
HR(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory));
HR(dxgiFactory->CreateSwapChain(md3dDevice, &sd, &mSwapChain));
ReleaseCOM(dxgiDevice);
ReleaseCOM(dxgiAdapter);
ReleaseCOM(dxgiFactory);
// The remaining steps that need to be carried out for d3d creation
// also need to be executed every time the window is resized. So
// just call the OnResize method here to avoid code duplication.
_updateSwapChain();
}
示例4: sizeof
void D3DContext::InitD3D(HWND hWnd)
{
m_MSAAEnabled = true;
HRESULT hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, m_DebugLayerEnabled ? D3D11_CREATE_DEVICE_DEBUG : D3D11_CREATE_DEVICE_SINGLETHREADED, NULL, NULL, D3D11_SDK_VERSION, &dev, &m_D3DFeatureLevel, &devcon);
dev->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, 4, &m_MSAAQuality);
// assert(m_MSAAQuality > 0);
DXGI_SWAP_CHAIN_DESC scd;
ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC));
scd.BufferDesc.Width = m_Properties.width;
scd.BufferDesc.Height = m_Properties.height;
scd.BufferDesc.RefreshRate.Numerator = 60;
scd.BufferDesc.RefreshRate.Denominator = 1;
scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
scd.SampleDesc.Count = m_MSAAEnabled ? 4 : 1;
scd.SampleDesc.Quality = m_MSAAEnabled ? (m_MSAAQuality - 1) : 0;
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scd.BufferCount = 3;
scd.OutputWindow = hWnd;
scd.Windowed = !m_Properties.fullscreen;
scd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
IDXGIDevice* dxgiDevice = 0;
IDXGIAdapter* dxgiAdapter = 0;
IDXGIFactory* dxgiFactory = 0;
dev->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice);
dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter);
dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory);
dxgiFactory->CreateSwapChain(dev, &scd, &swapchain);
dxgiFactory->Release();
dxgiAdapter->Release();
dxgiDevice->Release();
if (m_DebugLayerEnabled)
{
dev->QueryInterface(__uuidof(ID3D11Debug), reinterpret_cast<void**>(&m_DebugLayer));
m_DebugLayer->ReportLiveDeviceObjects(D3D11_RLDO_SUMMARY);
ID3D11InfoQueue* infoQueue;
dev->QueryInterface(__uuidof(ID3D11InfoQueue), reinterpret_cast<void**>(&infoQueue));
D3D11_MESSAGE_ID hide[] = { D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLER_NOT_SET };
D3D11_INFO_QUEUE_FILTER filter;
memset(&filter, 0, sizeof(filter));
filter.DenyList.NumIDs = 1;
filter.DenyList.pIDList = hide;
infoQueue->AddStorageFilterEntries(&filter);
}
Resize();
}
示例5: CreateSwapChain
bool TRenderDevice::CreateSwapChain(){
IDXGIDevice* device;
if (FAILED(Device->QueryInterface(__uuidof(IDXGIDevice), (void**) &device))){
MessageBox(0,L"获取设备接口失败",0,0);
return false;
}
IDXGIAdapter* adapter;
if (FAILED(device->GetParent(__uuidof(IDXGIAdapter), (void**) &adapter))){
MessageBox(0,L"获取适配器接口失败",0,0);
return false;
}
IDXGIFactory* factory;
if (FAILED(adapter->GetParent(__uuidof(IDXGIFactory), (void**) &factory))){
MessageBox(0,L"获取Factory接口失败",0,0);
return false;
}
DXGI_SWAP_CHAIN_DESC sd;
sd.BufferDesc.Width = RenderSize->GetRenderWidth();
sd.BufferDesc.Height = RenderSize->GetRenderHeight();
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
if (MsaaQuality>0){
sd.SampleDesc.Count = MsaaQuality;
sd.SampleDesc.Quality = MsaaQuality - 1;
}else{
sd.SampleDesc.Count=1;
sd.SampleDesc.Quality=0;
}
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferCount = 1;
sd.OutputWindow = RenderWindow->GetHWnd();
sd.Windowed = true;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
sd.Flags = 0;
if (FAILED(factory->CreateSwapChain(Device, &sd, &SwapChain))){
MessageBox(0,L"创建SwapChain失败",0,0);
return false;
}
device->Release();
adapter->Release();
factory->Release();
return true;
}
示例6: createSwapChain
//*************************************************************************************************
// Create the swap chain for the device
//*************************************************************************************************
SBOOL RenderContext::createSwapChain(HWND clientWindow, SUINT clientWidth, SUINT clientHeight)
{
// Fill out DXGI swap chain description
DXGI_SWAP_CHAIN_DESC sd;
sd.BufferDesc.Width = clientWidth;
sd.BufferDesc.Height = clientHeight;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
// Use 4x Msaa
if(_4xMsaaEnabled)
{
sd.SampleDesc.Count = 4;
sd.SampleDesc.Quality = _4xMsaaQuality - 1;
}
// No Msaa
else
{
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
}
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferCount = 1;
sd.OutputWindow = clientWindow;
sd.Windowed = true;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
sd.Flags = 0;
// Generate an IDXGI factory to properly initialize the swap chain
IDXGIDevice* dxgiDevice = 0;
HR(_d3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice));
IDXGIAdapter* dxgiAdapter = 0;
HR(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter));
IDXGIFactory* dxgiFactory = 0;
HR(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory));
HR(dxgiFactory->CreateSwapChain(_d3dDevice, &sd, &_swapChain));
ReleaseCOM(dxgiDevice);
ReleaseCOM(dxgiAdapter);
ReleaseCOM(dxgiFactory);
return true;
}
示例7: ZeroMemory
std::shared_ptr<SwapChain> Device::createSwapChain(const Window& window)
{
std::shared_ptr<SwapChain> swapChain;
IDXGIDevice* dxgiDevice = nullptr;
if (SUCCEEDED(m_device->QueryInterface<IDXGIDevice>(&dxgiDevice)))
{
IDXGIAdapter* adapter = nullptr;
if (SUCCEEDED(dxgiDevice->GetAdapter(&adapter)))
{
IDXGIFactory* dxgiFactory = nullptr;
if (SUCCEEDED(adapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&dxgiFactory))))
{
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 1;
sd.BufferDesc.Width = window.getWidth();
sd.BufferDesc.Height = window.getHeight();
sd.BufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 0;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = window.getPlatformData()->getHandle();
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE;
IDXGISwapChain* nativeSwapChain = nullptr;
if (SUCCEEDED(dxgiFactory->CreateSwapChain(m_device, &sd, &nativeSwapChain)))
{
ID3D11Texture2D* backBufferTexture = nullptr;
if (SUCCEEDED(nativeSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBufferTexture))))
{
auto texture = std::make_shared<Texture2d>(backBufferTexture);
auto backBufferRenderCommandEncoder = createRenderCommandEncoder(1, &texture, nullptr, false);
swapChain = std::make_shared<SwapChain>(nativeSwapChain, backBufferRenderCommandEncoder);
}
dxgiFactory->Release();
}
adapter->Release();
}
}
dxgiDevice->Release();
}
return swapChain;
}
示例8: DisableDXGIWindowChanges
inline void DisableDXGIWindowChanges(IUnknown* device, HWND window)
{
IDXGIDevice * pDXGIDevice;
ThrowIfFailed(device->QueryInterface(IID_PPV_ARGS(&pDXGIDevice)));
IDXGIAdapter * pDXGIAdapter;
ThrowIfFailed(pDXGIDevice->GetParent(IID_PPV_ARGS(&pDXGIAdapter)));
IDXGIFactory * pIDXGIFactory;
ThrowIfFailed(pDXGIAdapter->GetParent(IID_PPV_ARGS(&pIDXGIFactory)));
ThrowIfFailed(pIDXGIFactory->MakeWindowAssociation(window, DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER));
pIDXGIFactory->Release();
pDXGIAdapter->Release();
pDXGIDevice->Release();
}
示例9: FactoryFromDevice
static IDXGIFactory* FactoryFromDevice(ID3D11Device *device) {
assert(device);
IDXGIDevice *dxgiDevice = nullptr;
DEBUG_HR(device->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&dxgiDevice)));
IDXGIAdapter *dxgiAdapter = nullptr;
DEBUG_HR(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast<void**>(&dxgiAdapter)));
IDXGIFactory *dxgiFactory = nullptr;
DEBUG_HR(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&dxgiFactory)));
ReleaseCom(dxgiAdapter);
ReleaseCom(dxgiDevice);
return dxgiFactory;
}
示例10:
//========================================================================
// For specified ID3D10Device returns IDXGIFactory used to create it
//========================================================================
IDXGIFactory *getDeviceFactory(ID3D10Device *device)
{
IDXGIDevice *dxgiDevice = 0;
IDXGIAdapter *dxgiAdapter = 0;
IDXGIFactory *dxgiFactory = 0;
if (SUCCEEDED( device->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice) ))
{
if (SUCCEEDED( dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter) ))
{
dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory);
dxgiAdapter->Release();
}
dxgiDevice->Release();
}
return dxgiFactory;
}
示例11: CreateSwapChain
bool Renderer::CreateSwapChain() {
// Determine buffer size
RECT rect;
GetClientRect(hwnd,&rect);
// Create swap chain
DXGI_SWAP_CHAIN_DESC SwapChainDesc;
SwapChainDesc.BufferCount = 1;
SwapChainDesc.BufferDesc.Width = rect.right - rect.left;
SwapChainDesc.BufferDesc.Height = rect.bottom - rect.top;
SwapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
SwapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
SwapChainDesc.BufferDesc.RefreshRate.Denominator = 1; // 60/1 = 60 Hz
SwapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
SwapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
SwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
SwapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
SwapChainDesc.OutputWindow = hwnd;
SwapChainDesc.SampleDesc.Count = 1;
SwapChainDesc.SampleDesc.Quality = 0; // no AA
SwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
SwapChainDesc.Windowed = true;
// Obtain DXGI factory that was used to create the device
// ???
IDXGIDevice* DXGIDevice;
D3DDevice->QueryInterface(__uuidof(IDXGIDevice),(void**)&DXGIDevice);
IDXGIAdapter* DXGIAdapter;
DXGIDevice->GetParent(__uuidof(IDXGIAdapter),(void**)&DXGIAdapter);
IDXGIFactory* DXGIFactory;
DXGIAdapter->GetParent(__uuidof(IDXGIFactory),(void**)&DXGIFactory);
// Use it
if(DXGIFactory->CreateSwapChain(D3DDevice,&SwapChainDesc,&SwapChain) != S_OK) {
MessageBox(hwnd,"Error creating swap chain","Error",MB_OK);
return false;
}
// Release unused stuff
DXGIDevice->Release();
DXGIAdapter->Release();
DXGIFactory->Release();
return true;
}
示例12: Initialize
void DirectXController::Initialize( void )
{
WindowController::Get()->Initialize();
WindowController::Get()->OpenWindow();
driverType = D3D_DRIVER_TYPE_HARDWARE;
enable4xMsaa = false;
msaa4xQuality = 0;
device.dx = nullptr;
deviceContext.dx = nullptr;
swapChain = nullptr;
depthStencilBuffer = nullptr;
renderTargetView = nullptr;
depthStencilView = nullptr;
ZeroMemory( &viewport, sizeof(D3D11_VIEWPORT) );
UINT createDeviceFlags = 0;
#if defined(_DEBUG) || defined(DEBUG)
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
D3D_FEATURE_LEVEL requiredFeatureLevel = D3D_FEATURE_LEVEL_11_0;
D3D_FEATURE_LEVEL featureLevel;
HRESULT hResult = D3D11CreateDevice(
NULL, // Adapter
driverType, // Driver Type
NULL, // Software
createDeviceFlags, // Flags
&requiredFeatureLevel, // Feature levels
1, // num Feature levels
D3D11_SDK_VERSION, // SDK Version
&device.dx, // Device
&featureLevel, // Feature Level
&deviceContext.dx ); // Device Context
// Handle any device creation or DirectX version errors
if( FAILED(hResult) )
{
MessageBox(NULL, L"D3D11CreateDevice Failed", NULL, NULL);
//return false;
}
if( featureLevel != requiredFeatureLevel )
{
MessageBox(NULL, L"Direct3D Feature Level 11 unsupported", NULL, NULL);
//return false;
}
// Check for 4X MSAA quality support
HR(device.dx->CheckMultisampleQualityLevels(
DXGI_FORMAT_R8G8B8A8_UNORM,
4,
&msaa4xQuality));
//assert( msaa4xQuality > 0 ); // Potential problem if quality is 0
// set up swap chain
DXGI_SWAP_CHAIN_DESC swapChainDesc;
ZeroMemory(&swapChainDesc, sizeof(swapChainDesc) );
swapChainDesc.BufferCount = 1;
swapChainDesc.BufferDesc.Width = WindowController::Get()->GetWidth();//windowWidth;
swapChainDesc.BufferDesc.Height = WindowController::Get()->GetHeight();//windowHeight;
swapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.OutputWindow = Win32Controller::Get()->GetHWnd();//hMainWnd;
swapChainDesc.Windowed = true;
swapChainDesc.Flags = 0;
if( enable4xMsaa )
{ // Set up 4x MSAA
swapChainDesc.SampleDesc.Count = 4;
swapChainDesc.SampleDesc.Quality = msaa4xQuality - 1;
}
else
{ // No MSAA
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
}
// To correctly create the swap chain, we must use the IDXGIFactory that
// was used to create the device.
IDXGIDevice* dxgiDevice = 0;
IDXGIAdapter* dxgiAdapter = 0;
IDXGIFactory* dxgiFactory = 0;
HR(device.dx->QueryInterface( __uuidof(IDXGIDevice), (void**)&dxgiDevice));
HR(dxgiDevice->GetParent( __uuidof(IDXGIAdapter), (void**)&dxgiAdapter));
HR(dxgiAdapter->GetParent( __uuidof(IDXGIFactory), (void**)&dxgiFactory));
// Finally make the swap chain and release the DXGI stuff
HR(dxgiFactory->CreateSwapChain(device.dx, &swapChainDesc, &swapChain));
ReleaseCOMobjMacro(dxgiDevice);
ReleaseCOMobjMacro(dxgiAdapter);
ReleaseCOMobjMacro(dxgiFactory);
// The remaining steps also need to happen each time the window
//.........这里部分代码省略.........
示例13: defined
//.........这里部分代码省略.........
//! DXGI_SWAP_EFFECT SwapEffect;
// (Optional) flags
// Notes: If you use DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH, then when you switch to full-screen mode, the application
// will select a display mode that best matches the current back buffer settings.
//! UINT Flags;
*/
DXGI_SWAP_CHAIN_DESC SwapChainDesc;
/* --------------------------
//? DXGI_DESC_MODE Notes
--------------------------
//! Structure Signature
typedef struct DXGI_MODE_DESC {
UINT Width;
UINT Height;
DXGI_RATIONAL RefreshRate;
DXGI_FORMAT Format;
DXGI_MODE_SCANLINE_ORDER ScanlineOrdering;
DXGI_MODE_SCALING Scaling;
} DXGI_MODE_DESC;
//! Member Descriptions
// Window resolution width
//! UINT Width;
// Window resolution height
//! UINT Height;
// Refresh rate defined in Hz (Numerator and Denominator)
//! DXGI_RATIONAL RefreshRate;
// Display format
//! DXGI_FORMAT Format;
// Scanline Drawing Mode
//! DXGI_MODE_SCANLINE_ORDER ScanlineOrdering;
// Scaling Mode
// Notes: Indicates how an image is stretched to fit the screen resolution.
//! DXGI_MODE_SCALING Scaling;
*/
DXGI_MODE_DESC BackBufferDesc;
BackBufferDesc.Width = 800;
BackBufferDesc.Height = 600;
// Most monitors cannot output more than 24-bit color, so extra precision would be wasted
// Even though the monitor cannot output the 8-bit alpha, those bits can be used for other things like effects
BackBufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
BackBufferDesc.RefreshRate.Numerator = 60;
BackBufferDesc.RefreshRate.Denominator = 1;
BackBufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
BackBufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
SwapChainDesc.BufferDesc = BackBufferDesc;
if (mEnableMultisample) {
SwapChainDesc.SampleDesc.Count = 4;
SwapChainDesc.SampleDesc.Quality = mMultisampleQuality - 1;
}
else {
SwapChainDesc.SampleDesc.Count = 1;
SwapChainDesc.SampleDesc.Quality = 0;
}
SwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
SwapChainDesc.BufferCount = 1;
SwapChainDesc.OutputWindow = mMainWindow;
SwapChainDesc.Windowed = true;
SwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
SwapChainDesc.Flags = 0;
/* ---------------------
Create the swap chain
--------------------- */
IDXGIDevice* dxgiDevice = 0;
mDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice);
IDXGIAdapter* dxgiAdapter = 0;
dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter);
IDXGIFactory* dxgiFactory = 0;
dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory);
dxgiFactory->CreateSwapChain(mDevice, &SwapChainDesc, &mSwapChain);
ReleaseCOM(dxgiDevice);
ReleaseCOM(dxgiAdapter);
ReleaseCOM(dxgiFactory);
OnResize();
return true;
}
示例14:
//.........这里部分代码省略.........
0,
creationFlags,
featureLevels,
ARRAYSIZE(featureLevels),
D3D11_SDK_VERSION,
&device,
&_featureLevel,
&context ) );
DXASS( device->QueryInterface( __uuidof( ID3D11Device1 ),(void**)&_d3dDevice ) );
DXASS( context->QueryInterface( __uuidof( ID3D11DeviceContext1 ),(void**)&_d3dContext ) );
device->Release();
context->Release();
//create swap chain
if( _swapChain ){
DXASS( _swapChain->ResizeBuffers( 2,width,height,DXGI_FORMAT_B8G8R8A8_UNORM,0 ) );
}else{
#if WINDOWS_8
DXGI_SWAP_CHAIN_DESC1 swapChainDesc={0};
swapChainDesc.Width=width;
swapChainDesc.Height=height;
swapChainDesc.Format=DXGI_FORMAT_B8G8R8A8_UNORM;
swapChainDesc.Stereo=false;
swapChainDesc.SampleDesc.Count=1;
swapChainDesc.SampleDesc.Quality=0;
swapChainDesc.BufferUsage=DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferCount=2;
swapChainDesc.Scaling=DXGI_SCALING_NONE;
swapChainDesc.SwapEffect=DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
swapChainDesc.Flags=0;
#elif WINDOWS_PHONE_8
DXGI_SWAP_CHAIN_DESC1 swapChainDesc={0};
swapChainDesc.Width=width;
swapChainDesc.Height=height;
swapChainDesc.Format=DXGI_FORMAT_B8G8R8A8_UNORM;
swapChainDesc.Stereo=false;
swapChainDesc.SampleDesc.Count=1;
swapChainDesc.SampleDesc.Quality=0;
swapChainDesc.BufferUsage=DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferCount=1;
swapChainDesc.Scaling=DXGI_SCALING_STRETCH;
swapChainDesc.SwapEffect=DXGI_SWAP_EFFECT_DISCARD;
swapChainDesc.Flags=0;
#endif
IDXGIDevice1 *dxgiDevice;
DXASS( _d3dDevice->QueryInterface( __uuidof( IDXGIDevice1 ),(void**)&dxgiDevice ) );
IDXGIAdapter *dxgiAdapter;
DXASS( dxgiDevice->GetAdapter( &dxgiAdapter ) );
IDXGIFactory2 *dxgiFactory;
DXASS( dxgiAdapter->GetParent( __uuidof( IDXGIFactory2 ),(void**)&dxgiFactory ) );
DXASS( dxgiFactory->CreateSwapChainForCoreWindow( _d3dDevice,(IUnknown*)window,&swapChainDesc,0,&_swapChain ) );
DXASS( dxgiDevice->SetMaximumFrameLatency( 1 ) );
dxgiFactory->Release();
dxgiAdapter->Release();
dxgiDevice->Release();
}
// Create a render target view of the swap chain back buffer.
//
ID3D11Texture2D *backBuffer;
DXASS( _swapChain->GetBuffer( 0,__uuidof( ID3D11Texture2D ),(void**)&backBuffer ) );
DXASS( _d3dDevice->CreateRenderTargetView( backBuffer,0,&_renderTargetView ) );
backBuffer->Release();
/*
// Create a depth stencil view
//
D3D11_TEXTURE2D_DESC dsdesc;
ZEROMEM( dsdesc );
dsdesc.Width=width;
dsdesc.Height=height;
dsdesc.MipLevels=1;
dsdesc.ArraySize=1;
dsdesc.Format=DXGI_FORMAT_D24_UNORM_S8_UINT;
dsdesc.SampleDesc.Count=1;
dsdesc.SampleDesc.Quality=0;
dsdesc.Usage=D3D11_USAGE_DEFAULT;
dsdesc.BindFlags=D3D11_BIND_DEPTH_STENCIL;
dsdesc.CpuAccessFlags=0;
dsdesc.MiscFlags=0;
ID3D11Texture2D *depthStencil;
DXASS( _d3dDevice->CreateTexture2D( &dsdesc,0,&depthStencil ) );
DXASS( _d3dDevice->CreateDepthStencilView( depthStencil,0,&_depthStencilView ) );
depthStencil->Release();
*/
D3D11_VIEWPORT viewport={ 0,0,width,height,0,1 };
_d3dContext->RSSetViewports( 1,&viewport );
}
示例15: HWND
//.........这里部分代码省略.........
}
if ( adapter )
{
adapter->Release();
}
if ( FAILED( factory->CreateSwapChain( _device, &swap_chain_desc, &_swap_chain ) ) )
{
return false;
}
ID3D11Texture2D* backbuffer = nullptr;
HRESULT hr = _swap_chain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&backbuffer);
if (FAILED(hr))
return false;
hr = _device->CreateRenderTargetView(backbuffer, nullptr, &_back_buffer);
if (FAILED(hr))
return false;
SetWidth( width );
SetHeight( height );
if ( backbuffer )
{
backbuffer->Release();
}
if ( factory )
{
factory->Release();
}
if ( VRIsEnabled() )
{
{
D3D11_BUFFER_DESC cbuffer_desc;
cbuffer_desc.ByteWidth = sizeof(OculusBlit_cbuffer);
cbuffer_desc.Usage = D3D11_USAGE_DYNAMIC;
cbuffer_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
cbuffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
cbuffer_desc.MiscFlags = 0;
cbuffer_desc.StructureByteStride = sizeof(OculusBlit_cbuffer);
if ( FAILED( Device()->CreateBuffer( &cbuffer_desc, nullptr, &_oculus_blit_cbuffer ) ) )
{
return false;
}
}
_swap_chain->SetFullscreenState( 1, nullptr );
}
if (0)
{
// Get the dxgi factory and disable fullscreen toggling with alt+enter.
IDXGIDevice* dxgi_device = nullptr;
if ( FAILED( _device->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgi_device) ) )
{
//LogError( "F11", "Cannot initialise F11Graphics; cannot get DXGI device." );
return false;
}
if ( FAILED( dxgi_device->GetParent(__uuidof(IDXGIAdapter), (void **)&adapter) ) )
{
//LogError( "F11", "Cannot initialise F11Graphics; cannot get DXGI adapter." );
return false;
}
IDXGIFactory * factory = nullptr;
if ( FAILED( adapter->GetParent(__uuidof(IDXGIFactory), (void **)&factory) ) )
{
//LogError( "F11", "Cannot initialise F11Graphics; cannot get DXGI factory." );
return false;
}
factory->MakeWindowAssociation( HWND(GetGame()->GetHWND()), DXGI_MWA_NO_WINDOW_CHANGES );
dxgi_device->Release();
adapter->Release();
factory->Release();
}
// Create the back buffer by resizing
//Resize( width, height );
_resources.SetConfig(GetGraphicsSettings());
if ( !_resources.Initialise() )
{
return false;
}
Resize( width, height );
_is_initialised = true;
return true;
}