当前位置: 首页>>代码示例>>C++>>正文


C++ IDXGIFactory::CreateSwapChainForCoreWindow方法代码示例

本文整理汇总了C++中IDXGIFactory::CreateSwapChainForCoreWindow方法的典型用法代码示例。如果您正苦于以下问题:C++ IDXGIFactory::CreateSwapChainForCoreWindow方法的具体用法?C++ IDXGIFactory::CreateSwapChainForCoreWindow怎么用?C++ IDXGIFactory::CreateSwapChainForCoreWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDXGIFactory的用法示例。


在下文中一共展示了IDXGIFactory::CreateSwapChainForCoreWindow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: resetOffscreenTexture

EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swapInterval)
{
    ID3D11Device *device = mRenderer->getDevice();

    if (device == NULL)
    {
        return EGL_BAD_ACCESS;
    }

    // Release specific resources to free up memory for the new render target, while the
    // old render target still exists for the purpose of preserving its contents.
    SafeRelease(mSwapChain);
    SafeRelease(mBackBufferTexture);
    SafeRelease(mBackBufferRTView);

    mSwapInterval = static_cast<unsigned int>(swapInterval);
    if (mSwapInterval > 4)
    {
        // IDXGISwapChain::Present documentation states that valid sync intervals are in the [0,4] range
        return EGL_BAD_PARAMETER;
    }

    // EGL allows creating a surface with 0x0 dimension, however, DXGI does not like 0x0 swapchains
    if (backbufferWidth < 1 || backbufferHeight < 1)
    {
        releaseOffscreenTexture();
        return EGL_SUCCESS;
    }

    if (mWindow)
    {
#if !defined(ANGLE_OS_WINRT)
        IDXGIFactory *factory = mRenderer->getDxgiFactory();

        DXGI_SWAP_CHAIN_DESC swapChainDesc = {0};
        swapChainDesc.BufferDesc.Format = gl_d3d11::ConvertRenderbufferFormat(mBackBufferFormat);
        swapChainDesc.BufferDesc.Width = backbufferWidth;
        swapChainDesc.BufferDesc.Height = backbufferHeight;
        swapChainDesc.BufferCount = 2;
        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.Windowed = TRUE;
        swapChainDesc.OutputWindow = mWindow;
#else
        IDXGIFactory2 *factory;
        HRESULT result = mRenderer->getDxgiFactory()->QueryInterface(IID_PPV_ARGS(&factory));
        ASSERT(SUCCEEDED(result));

        DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
        swapChainDesc.Format = gl_d3d11::ConvertRenderbufferFormat(mBackBufferFormat);
        swapChainDesc.Width = backbufferWidth;
        swapChainDesc.Height = backbufferHeight;
        swapChainDesc.Stereo = FALSE;
#if !defined(ANGLE_OS_WINPHONE)
        swapChainDesc.BufferCount = 2;
        swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
#else
        swapChainDesc.BufferCount = 1;
        swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
#endif
#endif
        swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
        swapChainDesc.Flags = 0;
        swapChainDesc.SampleDesc.Count = 1;
        swapChainDesc.SampleDesc.Quality = 0;

#if !defined(ANGLE_OS_WINRT)
        HRESULT result = factory->CreateSwapChain(device, &swapChainDesc, &mSwapChain);
#else
        IDXGISwapChain1 *swapChain;
        result = factory->CreateSwapChainForCoreWindow(device, mWindow, &swapChainDesc, NULL, &swapChain);
        mSwapChain = swapChain;
#endif

        if (FAILED(result))
        {
            ERR("Could not create additional swap chains or offscreen surfaces: %08lX", result);
            release();

            if (d3d11::isDeviceLostError(result))
            {
                return EGL_CONTEXT_LOST;
            }
#if !defined(ANGLE_OS_WINRT)
            else
            {
                // We cannot create a swap chain for an HWND that is owned by a different process on some versions of
                // windows
                DWORD currentProcessId = GetCurrentProcessId();
                DWORD wndProcessId;
                GetWindowThreadProcessId(mWindow, &wndProcessId);

                if (currentProcessId != wndProcessId)
                {
                    ERR("Could not create swap chain, window owned by different process");
                    return EGL_BAD_NATIVE_WINDOW;
                }
                else
//.........这里部分代码省略.........
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:101,代码来源:SwapChain11.cpp


注:本文中的IDXGIFactory::CreateSwapChainForCoreWindow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。