本文整理汇总了C++中IDXGIFactory::CreateSwapChain方法的典型用法代码示例。如果您正苦于以下问题:C++ IDXGIFactory::CreateSwapChain方法的具体用法?C++ IDXGIFactory::CreateSwapChain怎么用?C++ IDXGIFactory::CreateSwapChain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDXGIFactory
的用法示例。
在下文中一共展示了IDXGIFactory::CreateSwapChain方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2:
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();
}
示例3: return
/*
* Class: org_lwjgl_d3d11_impl_DXGIFactoryImpl
* Method: nCreateSwapChain
* Signature: (JJJJ)J
*/
extern "C" JNIEXPORT jlong JNICALL Java_org_lwjgl_d3d11_impl_DXGIFactoryImpl_nCreateSwapChain
(JNIEnv * env, jclass clazz, jlong thisPtr, jlong devicePtr, jlong swapChainDescPtr, jlong swapChainOutPtr) {
IDXGIFactory* factory = (IDXGIFactory*)(intptr_t)thisPtr;
IUnknown* device = (IUnknown*)(intptr_t)devicePtr;
DXGI_SWAP_CHAIN_DESC* swapChainDesc = (DXGI_SWAP_CHAIN_DESC*)(intptr_t)swapChainDescPtr;
IDXGISwapChain** swapChain = (IDXGISwapChain**)(intptr_t)swapChainOutPtr;
return (jlong)factory->CreateSwapChain(device, swapChainDesc, swapChain);
}
示例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: GetCurrentProcessId
EGLint SwapChain11Api::createSwapChain(
int backbufferWidth, int backbufferHeight, IDXGISwapChain **outSwapChain)
{
// We cannot create a swap chain for an HWND that is owned by a
// different process
DWORD currentProcessId = GetCurrentProcessId();
DWORD wndProcessId;
GetWindowThreadProcessId((HWND)mWindow, &wndProcessId);
if (currentProcessId != wndProcessId)
{
ERR("Could not create swap chain, window owned by different process");
return EGL_BAD_NATIVE_WINDOW;
}
ID3D11Device *device = getRenderer()->getDevice();
IDXGIFactory *factory = getRenderer()->getDxgiFactory();
DXGI_FORMAT format = gl_d3d11::ConvertRenderbufferFormat(mBackBufferFormat);
DXGI_SWAP_CHAIN_DESC swapChainDesc = {0};
swapChainDesc.BufferCount = 2;
swapChainDesc.BufferDesc.Format = format;
swapChainDesc.BufferDesc.Width = backbufferWidth;
swapChainDesc.BufferDesc.Height = backbufferHeight;
swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.Flags = 0;
swapChainDesc.OutputWindow = mWindow;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.Windowed = TRUE;
IDXGISwapChain *swapChain;
HRESULT result = factory->CreateSwapChain(device, &swapChainDesc, &swapChain);
if (SUCCEEDED(result))
{
*outSwapChain = swapChain;
d3d11::ResourceTracker::Track(swapChain);
return EGL_SUCCESS;
}
else
{
if (d3d11::isDeviceLostError(result))
return EGL_CONTEXT_LOST;
else
return EGL_BAD_ALLOC;
}
}
示例7: 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;
}
示例8: 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;
}
示例9: CreateSwapChain
HRESULT STDMETHODCALLTYPE CDXGIFactoryDWM::CreateSwapChain(IUnknown *pDevice, DXGI_SWAP_CHAIN_DESC *pDesc, IDXGIOutput *pOutput, IDXGISwapChainDWM **ppSwapChain)
{
IDXGISwapChain *pSwapChain = NULL;
if (retrace::forceWindowed) {
pDesc->Windowed = TRUE;
}
HRESULT hr = m_pFactory->CreateSwapChain(pDevice, pDesc, &pSwapChain);
if (SUCCEEDED(hr)) {
if (!retrace::forceWindowed) {
pSwapChain->SetFullscreenState(TRUE, pOutput);
}
*ppSwapChain = new CDXGISwapChainDWM(pSwapChain);
}
return hr;
}
示例10: CreateSwapChain
Error::E RenderSystem::CreateSwapChain(const Window &window) {
assert(_device);
_swapDesc = kDefaultSwapDesc;
_swapDesc.SampleDesc.Count = 4;
_swapDesc.SampleDesc.Quality = _msaaQualityLevel - 1;
_swapDesc.OutputWindow = window.GetHandle();
_swapDesc.BufferDesc.Width = window.GetWidth();
_swapDesc.BufferDesc.Height = window.GetHeight();
IDXGIFactory *factory = FactoryFromDevice(_device);
DEBUG_HR(factory->CreateSwapChain(_device, &_swapDesc, &_swapChain));
ReleaseCom(factory);
return Error::OK;
}
示例11: defined
void D3DApplication::InitDirect3D()
{
// Create the device.
UINT createDeviceFlags = 0;
#if defined(DEBUG) || defined(_DEBUG)
createDeviceFlags |= D3D10_CREATE_DEVICE_DEBUG;
#endif
HR(D3D10CreateDevice(0, m_DriverType, 0, createDeviceFlags, D3D10_SDK_VERSION, &m_pDevice));
IDXGIFactory* pFactory;
HR(CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)(&pFactory)));
// Fill out a DXGI_SWAP_CHAIN_DESC to describe our swap chain.
DXGI_SWAP_CHAIN_DESC swapChainDescription;
swapChainDescription.BufferDesc.Width = m_ClientWidth;
swapChainDescription.BufferDesc.Height = m_ClientHeight;
swapChainDescription.BufferDesc.RefreshRate.Numerator = 60;
swapChainDescription.BufferDesc.RefreshRate.Denominator = 1;
swapChainDescription.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDescription.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapChainDescription.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
// No multisampling.
swapChainDescription.SampleDesc.Count = 1;
swapChainDescription.SampleDesc.Quality = 0;
swapChainDescription.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDescription.BufferCount = 1;
swapChainDescription.OutputWindow = m_hMainWindow;
swapChainDescription.Windowed = true;
swapChainDescription.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
swapChainDescription.Flags = 0;
HR(pFactory->CreateSwapChain(m_pDevice, &swapChainDescription, &m_pSwapChain));
HR(pFactory->MakeWindowAssociation(m_hMainWindow, DXGI_MWA_NO_WINDOW_CHANGES));
// 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.
OnResize();
}
示例12: 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;
}
示例13:
boolean RendererD3D11::assembleUnit()
{
ProcessingUnitPtr windowUnit = ProcessingUnitPtr::null;
window->getData( windowUnit );
if( !windowUnit.isNull() )
{
WindowPtr wnd = staticCast<Window>( windowUnit );
RenderDeviceD3D11* rd = static_cast<RenderDeviceD3D11*>( owner );
IDXGIFactory* dxgiFactory = rd->getDXGIFactory();
DXGI_SWAP_CHAIN_DESC desc;
desc.BufferCount = 1;
desc.BufferDesc.Width = wnd->getWidth();
desc.BufferDesc.Height = wnd->getHeight();
desc.BufferDesc.Format = MapperD3D11::mapPixelFormat( Render::PF_RGBA8UN );
desc.BufferDesc.RefreshRate.Numerator = 60;
desc.BufferDesc.RefreshRate.Denominator = 1;
desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
desc.OutputWindow = (HWND)wnd->getHandle();
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Windowed = !wnd->isFullscreen();
desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
IDXGISwapChain* sc = 0;
HRESULT hr = dxgiFactory->CreateSwapChain( rd->getD3DDevice(), &desc, &sc );
if( SUCCEEDED( hr ) )
{
swapchains.add( sc );
wnd->setSwapChain( sc );
return true;
}
}
return false;
}
示例14: sizeof
//.........这里部分代码省略.........
else
md3dpp.AutoDepthStencilFormat = D3DFMT_D24X8;
}
}
else
// 16-bit depth, software stencil
md3dpp.AutoDepthStencilFormat = D3DFMT_D16;
*/
md3dpp.SampleDesc.Count = mFSAAType.Count;
md3dpp.SampleDesc.Quality = mFSAAType.Quality;
if (mIsSwapChain)
{
IDXGIFactory* mpDXGIFactory;
HRESULT hr;
hr = CreateDXGIFactory( IID_IDXGIFactory, (void**)&mpDXGIFactory );
if( FAILED(hr) )
{
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"Unable to create a DXGIFactory for the swap chain",
"D3D10RenderWindow::createD3DResources");
}
// get the dxgi device
IDXGIDevice* pDXGIDevice = NULL;
hr = mDevice->QueryInterface( IID_IDXGIDevice, (void**)&pDXGIDevice );
if( FAILED(hr) )
{
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"Unable to create a DXGIDevice for the swap chain",
"D3D10RenderWindow::createD3DResources");
}
// Create swap chain
hr = mpDXGIFactory->CreateSwapChain(
pDXGIDevice,&md3dpp,&mpSwapChain);
if (FAILED(hr))
{
// Try a second time, may fail the first time due to back buffer count,
// which will be corrected by the runtime
hr = mpDXGIFactory->CreateSwapChain(pDXGIDevice,&md3dpp,&mpSwapChain);
}
if (FAILED(hr))
{
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"Unable to create an additional swap chain",
"D3D10RenderWindow::createD3DResources");
}
// Store references to buffers for convenience
//mpSwapChain->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &mpRenderSurface );
// Additional swap chains need their own depth buffer
// to support resizing them
hr = mpSwapChain->GetBuffer( 0, __uuidof( ID3D10Texture2D ), (LPVOID*)&mpBackBuffer );
if( FAILED(hr) )
{
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"Unable to Get Back Buffer for swap chain",
"D3D10RenderWindow::createD3DResources");
}
// get the backbuffer desc
D3D10_TEXTURE2D_DESC BBDesc;
mpBackBuffer->GetDesc( &BBDesc );
示例15: defined
// ´ÙÀÌ·ºÆ® °´Ã¼ ÃʱâÈ
// - °¢Á¾±â´ÉÀ» Áö¿øÇϴ°¡ üũÇÏ°í(´ÙÁß »ùÇøµ µî), ½º¿ÒüÀÎ, ÄÄ °´Ã¼ µîÀ» »ý¼º, Á¦°ÅÇÑ´Ù.
bool cInitD3D::InitDirect3D()
{
// µð¹ÙÀ̽º, µð¹ÙÀ̽º ÄÁÅؽºÆ® »ý¼º
UINT createDeviceFlags = 0;
#if defined(DEBUG) || defined(_DEBUG)
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
D3D_FEATURE_LEVEL featureLevel;
HRESULT hr = D3D11CreateDevice(
0, // default adapter
md3dDriverType,
0, // no software device
createDeviceFlags,
0, 0, // default feature level array
D3D11_SDK_VERSION,
&md3dDevice,
&featureLevel,
&md3dImmediateContext);
if (FAILED(hr))
{
MessageBox(0, L"D3D11CreateDevice Failed.", 0, 0);
return false;
}
if (featureLevel != D3D_FEATURE_LEVEL_11_0)
{
MessageBox(0, L"Direct3D Feature Level 11 unsupported.", 0, 0);
return false;
}
// ¹é¹öÆÛ¿¡ 4X MSAA Ç°Áú Áö¿øÀ» È®ÀÎ
HR(md3dDevice->CheckMultisampleQualityLevels(
DXGI_FORMAT_R8G8B8A8_UNORM, 4, &m4xMsaaQuality));
assert(m4xMsaaQuality > 0);
// ½º¿ÒüÀÎ »ý¼º
DXGI_SWAP_CHAIN_DESC sd;
sd.BufferDesc.Width = mClientWidth;
sd.BufferDesc.Height = mClientHeight;
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 = 1;
sd.OutputWindow = mhMainWnd;
sd.Windowed = true;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
sd.Flags = 0;
// µð¹ÙÀ̽º »ý¼º
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);
// â Å©±â Á¶Àý (ÄÚµå Áߺ¹ ÇÇÇϱâ À§ÇØ »ç¿ë)
OnResize();
return true;
}