本文整理汇总了C++中IDXGIFactory::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IDXGIFactory::Release方法的具体用法?C++ IDXGIFactory::Release怎么用?C++ IDXGIFactory::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDXGIFactory
的用法示例。
在下文中一共展示了IDXGIFactory::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDefaultAdapterLuid
static ovrGraphicsLuid GetDefaultAdapterLuid()
{
ovrGraphicsLuid luid = ovrGraphicsLuid();
#if defined(_WIN32)
IDXGIFactory* factory = nullptr;
if (SUCCEEDED(CreateDXGIFactory(IID_PPV_ARGS(&factory))))
{
IDXGIAdapter* adapter = nullptr;
if (SUCCEEDED(factory->EnumAdapters(0, &adapter)))
{
DXGI_ADAPTER_DESC desc;
adapter->GetDesc(&desc);
memcpy(&luid, &desc.AdapterLuid, sizeof(luid));
adapter->Release();
}
factory->Release();
}
#endif
return luid;
}
示例2: sizeof
//========================================================================
// Initialize hardware for rendering. Member of AbstractRender
//========================================================================
HRESULT DX10Render::initDevice()
{
UINT createDeviceFlags = 0;
#ifdef _DEBUG
createDeviceFlags |= D3D10_CREATE_DEVICE_DEBUG;
#endif
HRESULT hr = D3D10CreateDevice(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, D3D10_SDK_VERSION, &this->device);
if (FAILED(hr)) return hr;
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 1;
sd.BufferDesc.Width = this->resolution.width;
sd.BufferDesc.Height = this->resolution.height;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = this->hWindow;
sd.SampleDesc.Count = 4;
sd.SampleDesc.Quality = 4;
sd.Windowed = !this->fullscreen;
IDXGIFactory *factory = getDeviceFactory(device);
if (factory == NULL) return E_FAIL;
hr = factory->CreateSwapChain(device, &sd, &swapChain);
if (FAILED(hr)) return hr;
factory->Release();
return S_OK;
}
示例3: LogVideoCardStats
void LogVideoCardStats()
{
HRESULT err;
IDXGIFactory *factory;
if(SUCCEEDED(err = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory)))
{
UINT i=0;
IDXGIAdapter *giAdapter;
while(factory->EnumAdapters(i++, &giAdapter) == S_OK)
{
Log(TEXT("------------------------------------------"));
DXGI_ADAPTER_DESC adapterDesc;
if(err = SUCCEEDED(giAdapter->GetDesc(&adapterDesc)))
{
Log(TEXT("Adapter %u"), i);
Log(TEXT(" Video Adapter: %s"), adapterDesc.Description);
Log(TEXT(" Video Adapeter Dedicated Video Memory: %u"), adapterDesc.DedicatedVideoMemory);
Log(TEXT(" Video Adapeter Shared System Memory: %u"), adapterDesc.SharedSystemMemory);
}
else
AppWarning(TEXT("Could not query adapter %u"), i);
giAdapter->Release();
}
factory->Release();
}
}
示例4: wstring
std::wstring
DXGI::GetGPUInfo (void)
{
static wchar_t adapters [4096];
*adapters = L'\0';
if (!NVAPI::CountPhysicalGPUs ()) {
IDXGIFactory* pFactory = NULL;
CreateDXGIFactory (__uuidof(IDXGIFactory), (void **)&pFactory);
IDXGIAdapter* pDXGIAdapter;
for (UINT i = 0; pFactory->EnumAdapters (i, &pDXGIAdapter) != DXGI_ERROR_NOT_FOUND; ++i) {
DXGI_ADAPTER_DESC adapterDesc;
pDXGIAdapter->GetDesc (&adapterDesc);
// Skip Microsoft's virtual adapters...
if (adapterDesc.VendorId != 0x1414) {
swprintf (adapters, L"%sAdapter %02u (Vendor ID: %04X):\r\n"
L"----------------------------------------\r\n\r\n"
L" %s\r\n\r\n"
L" %4.1f GiB Dedicated VRAM\r\n"
L" %4.1f GiB Shared Memory (GART)\r\n\r\n",
adapters,
i,
adapterDesc.VendorId,
adapterDesc.Description,
(float)adapterDesc.DedicatedVideoMemory / 1024.0f / 1024.0f / 1024.0f,
(float)adapterDesc.SharedSystemMemory / 1024.0f / 1024.0f / 1024.0f);
}
pDXGIAdapter->Release ();
}
pFactory->Release ();
}
else {
DXGI_ADAPTER_DESC* adapter_descs = NVAPI::EnumGPUs_DXGI ();
int i = 0;
while (*adapter_descs [i].Description != L'\0') {
swprintf (adapters, L"%sAdapter %02d (Vendor ID: %04X):\r\n"
L"----------------------------------------\r\n\r\n"
L" %s\r\n\r\n"
L" %4.1f GiB Dedicated VRAM\r\n"
L" %4.1f GiB Shared Memory (GART)\r\n\r\n",
adapters,
i,
adapter_descs [i].VendorId,
adapter_descs [i].Description,
(float)adapter_descs [i].DedicatedVideoMemory / 1024.0f / 1024.0f / 1024.0f,
(float)adapter_descs [i].SharedSystemMemory / 1024.0f / 1024.0f / 1024.0f);
++i;
}
}
return std::wstring (adapters);
}
示例5: CreateContext
HRESULT CContextManager::CreateContext(HWND hWnd, int Width, int Height)
{
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
};
UINT numFeatureLevels = ARRAYSIZE(featureLevels);
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 1;
sd.BufferDesc.Width = Width;
sd.BufferDesc.Height = Height;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = hWnd;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE;
sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
/*#if _DEBUG
int flags = D3D11_CREATE_DEVICE_DEBUG;
#else
int flags = 0;
#endif*/
int flags = 0;
if (FAILED(D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, featureLevels, numFeatureLevels,
D3D11_SDK_VERSION, &sd, &m_SwapChain, &m_D3DDevice, NULL, &m_DeviceContext)))
{
return S_FALSE;
}
#if _DEBUG
HRESULT hr = m_D3DDevice->QueryInterface(__uuidof(ID3D11Debug), reinterpret_cast<void**>(&m_D3DDebug));
if (FAILED(hr))
return hr;
#endif
// treure el ALT+INTRO automàtic
IDXGIFactory* dxgiFactory;
hr = m_SwapChain->GetParent(__uuidof(IDXGIFactory), (void **)&dxgiFactory);
assert(hr == S_OK);
hr = dxgiFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER);
assert(hr == S_OK);
dxgiFactory->Release();
return S_OK;
}
示例6: 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();
}
示例7: REV_InitErrorToOvrError
OVR_PUBLIC_FUNCTION(ovrResult) ovr_Create(ovrSession* pSession, ovrGraphicsLuid* pLuid)
{
// Initialize the opaque pointer with our own OpenVR-specific struct
ovrSession session = new struct ovrHmdStruct();
memset(session->ColorTexture, 0, sizeof(ovrHmdStruct::ColorTexture));
session->ThumbStick[ovrHand_Left] = true;
// Get the compositor interface
session->compositor = (vr::IVRCompositor*)VR_GetGenericInterface(vr::IVRCompositor_Version, &g_InitError);
if (g_InitError != vr::VRInitError_None)
return REV_InitErrorToOvrError(g_InitError);
session->compositor->SetTrackingSpace(vr::TrackingUniverseSeated);
// Get the settings interface
session->settings = (vr::IVRSettings*)VR_GetGenericInterface(vr::IVRSettings_Version, &g_InitError);
if (g_InitError != vr::VRInitError_None)
return REV_InitErrorToOvrError(g_InitError);
// Get the overlay interface
session->overlay = (vr::IVROverlay*)VR_GetGenericInterface(vr::IVROverlay_Version, &g_InitError);
if (g_InitError != vr::VRInitError_None)
return REV_InitErrorToOvrError(g_InitError);
// Apply settings
session->ThumbStickRange = session->settings->GetFloat(REV_SETTINGS_SECTION, "ThumbStickRange", 0.8f);
// Get the LUID for the adapter
int32_t index;
g_VRSystem->GetDXGIOutputInfo(&index);
if (index == -1)
index = 0;
// Create the DXGI factory
IDXGIFactory* pFactory;
HRESULT hr = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)(&pFactory));
if (FAILED(hr))
return ovrError_IncompatibleGPU;
IDXGIAdapter* pAdapter;
hr = pFactory->EnumAdapters(index, &pAdapter);
if (FAILED(hr))
return ovrError_MismatchedAdapters;
DXGI_ADAPTER_DESC desc;
hr = pAdapter->GetDesc(&desc);
if (FAILED(hr))
return ovrError_MismatchedAdapters;
// Copy the LUID into the structure
memcpy(pLuid, &desc.AdapterLuid, sizeof(LUID));
// Cleanup and return
pFactory->Release();
pAdapter->Release();
*pSession = session;
return ovrSuccess;
}
示例8: CreateDXGIFactory
size_t
DXGI::GetAdapterPool (DXGI::GPUMemoryPool pool)
{
if (! NVAPI::CountPhysicalGPUs ()) {
IDXGIFactory* pFactory = NULL;
CreateDXGIFactory (__uuidof(IDXGIFactory), (void **)&pFactory);
IDXGIAdapter * pDXGIAdapter;
for (UINT i = 0; pFactory->EnumAdapters (i, &pDXGIAdapter) != DXGI_ERROR_NOT_FOUND; ++i) {
DXGI_ADAPTER_DESC adapterDesc;
pDXGIAdapter->GetDesc (&adapterDesc);
// Skip Microsoft's virtual adapters...
if (adapterDesc.VendorId != 0x1414) {
pDXGIAdapter->Release ();
pFactory->Release ();
if (pool == GART)
return adapterDesc.SharedSystemMemory;
else
return adapterDesc.DedicatedVideoMemory;
}
pDXGIAdapter->Release ();
}
pFactory->Release ();
}
else {
DXGI_ADAPTER_DESC* adapter_descs = NVAPI::EnumGPUs_DXGI ();
int i = 0;
while (*adapter_descs [i].Description != L'\0') {
if (pool == GART)
return adapter_descs [i].SharedSystemMemory;
else
return adapter_descs [i].DedicatedVideoMemory;
}
}
return 0;
}
示例9: adapterDesc
// Constructor. Creates a Direct3D device.
D3D() : _Device(NULL), _ImmediateContext(NULL)
{
IDXGIFactory* factory;
if (FAILED(CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory))) return;
HRESULT hr = S_OK;
UINT createDeviceFlags = 0;
#ifdef _DEBUG
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
D3D_DRIVER_TYPE driverTypes[] =
{
D3D_DRIVER_TYPE_UNKNOWN,
};
UINT numDriverTypes = sizeof(driverTypes) / sizeof(driverTypes[0]);
D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_0 };
unsigned int numFeatureLevels = 1;
D3D_FEATURE_LEVEL usedFeatureLevel = D3D_FEATURE_LEVEL_11_0;
// iterate the display adapters and look for a DirectX 11 capable device.
for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++)
{
D3D_DRIVER_TYPE driverType = driverTypes[driverTypeIndex];
IDXGIAdapter* adapter;
for (UINT i = 0;
factory->EnumAdapters(i, &adapter) != DXGI_ERROR_NOT_FOUND;
++i)
{
DXGI_ADAPTER_DESC desc;
adapter->GetDesc(&desc);
std::wstring adapterDesc(desc.Description);
hr = D3D11CreateDevice(adapter, driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels, D3D11_SDK_VERSION, &_Device, &usedFeatureLevel, &_ImmediateContext);
if (SUCCEEDED(hr))
{
wprintf(L"D3D is using: %s\n", adapterDesc.c_str());
break;
}
}
if (!_Device) {
printf("Couldn't create DirectX device.\nMaybe DirectX 11 is not supported on your machine?\n");
exit(-1);
}
if (adapter) adapter->Release();
if (SUCCEEDED(hr))
break;
}
factory->Release();
}
示例10: 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;
}
示例11: CreateDXGIFactory
GPA_Status DX12GetAdapterDesc(IUnknown* pDevice, DXGI_ADAPTER_DESC& adapterDesc)
{
GPA_Status status = GPA_STATUS_OK;
if (nullptr == pDevice)
{
GPA_LogError("Parameter 'pDevice' is NULL.");
status = GPA_STATUS_ERROR_NULL_POINTER;
}
else
{
ID3D12Device* dx12Device = static_cast<ID3D12Device*>(pDevice);
LUID adapterLuid = dx12Device->GetAdapterLuid();
IDXGIFactory* pDXGIFactory = nullptr;
HRESULT hr = CreateDXGIFactory(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&pDXGIFactory));
if (FAILED(hr) || (nullptr == pDXGIFactory))
{
GPA_LogError("Unable to get IDXGIFactory interface from ID3D12Device.");
status = GPA_STATUS_ERROR_FAILED;
}
else
{
IDXGIAdapter* pAdapter = nullptr;
for (UINT index = 0; pDXGIFactory->EnumAdapters(index, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++index)
{
memset(&adapterDesc, 0, sizeof(adapterDesc));
hr = pAdapter->GetDesc(&adapterDesc);
if (FAILED(hr))
{
GPA_LogError("Could not get adapter description, hardware cannot be supported.");
status = GPA_STATUS_ERROR_FAILED;
}
else
{
if (adapterDesc.AdapterLuid.HighPart == adapterLuid.HighPart && adapterDesc.AdapterLuid.LowPart == adapterLuid.LowPart)
{
// We found the matching adapter luid, so we're done.
break;
}
}
}
}
pDXGIFactory->Release();
}
return status;
}
示例12: OpenPlugin
void SysMtgsThread::OpenPlugin()
{
if( m_PluginOpened ) return;
memcpy( RingBuffer.Regs, PS2MEM_GS, sizeof(PS2MEM_GS) );
GSsetBaseMem( RingBuffer.Regs );
GSirqCallback( dummyIrqCallback );
int result;
if( GSopen2 != NULL )
result = GSopen2( (void*)pDsp, 1 | (renderswitch ? 4 : 0) );
else
result = GSopen( (void*)pDsp, "PCSX2", renderswitch ? 2 : 1 );
GSsetVsync(EmuConfig.GS.FrameLimitEnable && EmuConfig.GS.VsyncEnable);
if( result != 0 )
{
DevCon.WriteLn( "GSopen Failed: return code: 0x%x", result );
throw Exception::PluginOpenError( PluginId_GS );
}
// This is the preferred place to implement DXGI fullscreen overrides, using LoadLibrary.
// But I hate COM, I don't know to make this work, and I don't have DX10, so I give up
// and enjoy my working DX9 alt-enter instead. Someone else can fix this mess. --air
// Also: Prolly needs some DX10 header includes? Which ones? Too many, I gave up.
#if 0 // defined(__WXMSW__) && defined(_MSC_VER)
wxDynamicLibrary dynlib( L"dxgi.dll" );
SomeFuncTypeIDunno isThisEvenTheRightFunctionNameIDunno = dynlib.GetSymbol("CreateDXGIFactory");
if( isThisEvenTheRightFunctionNameIDunno )
{
// Is this how LoadLibrary for COM works? I dunno. I dont care.
IDXGIFactory* pFactory;
hr = isThisEvenTheRightFunctionNameIDunno(__uuidof(IDXGIFactory), (void**)(&pFactory) );
pFactory->MakeWindowAssociation((HWND)&pDsp, DXGI_MWA_NO_WINDOW_CHANGES);
pFactory->Release();
}
#endif
m_PluginOpened = true;
m_sem_OpenDone.Post();
GSsetGameCRC( ElfCRC, 0 );
}
示例13: 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;
}
示例14: 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();
}
示例15: 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;
}