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


C++ D3D11RenderSystem::_addManualDepthBuffer方法代码示例

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


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

示例1: assert

//---------------------------------------------------------------------
void D3D11RenderWindowBase::_createSizeDependedD3DResources(void)
{
    assert(mpBackBuffer && !mRenderTargetView && !mDepthStencilView);

    HRESULT hr;

    // get the backbuffer desc
    D3D11_TEXTURE2D_DESC BBDesc;
    mpBackBuffer->GetDesc( &BBDesc );

    // create the render target view
    D3D11_RENDER_TARGET_VIEW_DESC RTVDesc;
    ZeroMemory( &RTVDesc, sizeof(RTVDesc) );

    RTVDesc.Format = BBDesc.Format;
    RTVDesc.ViewDimension = mFSAA ? D3D11_RTV_DIMENSION_TEXTURE2DMS : D3D11_RTV_DIMENSION_TEXTURE2D;
    RTVDesc.Texture2D.MipSlice = 0;
    hr = mDevice->CreateRenderTargetView( mpBackBuffer, &RTVDesc, &mRenderTargetView );

    if( FAILED(hr) )
    {
        String errorDescription = mDevice.getErrorDescription(hr);
        OGRE_EXCEPT_EX(Exception::ERR_RENDERINGAPI_ERROR, hr,
                       "Unable to create rendertagert view\nError Description:" + errorDescription,
                       "D3D11RenderWindow::_createSizeDependedD3DResources");
    }


    if( mDepthBufferPoolId != DepthBuffer::POOL_NO_DEPTH )
    {
        // Create depth stencil texture
        ID3D11Texture2D* pDepthStencil = NULL;
        D3D11_TEXTURE2D_DESC descDepth;

        descDepth.Width = BBDesc.Width;
        descDepth.Height = BBDesc.Height;
        descDepth.MipLevels = 1;
        descDepth.ArraySize = 1;
        descDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
        descDepth.SampleDesc.Count = mFSAAType.Count;
        descDepth.SampleDesc.Quality = mFSAAType.Quality;
        descDepth.Usage = D3D11_USAGE_DEFAULT;
        descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL;
        descDepth.CPUAccessFlags = 0;
        descDepth.MiscFlags = 0;

        hr = mDevice->CreateTexture2D( &descDepth, NULL, &pDepthStencil );
        if( FAILED(hr) || mDevice.isError())
        {
            String errorDescription = mDevice.getErrorDescription(hr);
            OGRE_EXCEPT_EX(Exception::ERR_RENDERINGAPI_ERROR, hr,
                           "Unable to create depth texture\nError Description:" + errorDescription,
                           "D3D11RenderWindow::_createSizeDependedD3DResources");
        }

        // Create the depth stencil view
        D3D11_DEPTH_STENCIL_VIEW_DESC descDSV;
        ZeroMemory( &descDSV, sizeof(D3D11_DEPTH_STENCIL_VIEW_DESC) );

        descDSV.Format =  descDepth.Format;
        descDSV.ViewDimension = mFSAA ? D3D11_DSV_DIMENSION_TEXTURE2DMS : D3D11_DSV_DIMENSION_TEXTURE2D;
        descDSV.Texture2D.MipSlice = 0;
        hr = mDevice->CreateDepthStencilView( pDepthStencil, &descDSV, &mDepthStencilView );

        SAFE_RELEASE(pDepthStencil);

        if( FAILED(hr) )
        {
            String errorDescription = mDevice.getErrorDescription(hr);
            OGRE_EXCEPT_EX(Exception::ERR_RENDERINGAPI_ERROR, hr,
                           "Unable to create depth stencil view\nError Description:" + errorDescription,
                           "D3D11RenderWindow::_createSizeDependedD3DResources");
        }

        D3D11RenderSystem* rsys = static_cast<D3D11RenderSystem*>(Root::getSingleton().getRenderSystem());
        DepthBuffer *depthBuf = rsys->_addManualDepthBuffer( mDepthStencilView, mWidth, mHeight,
                                mFSAAType.Count, mFSAAType.Quality );

        //Don't forget we want this window to use _this_ depth buffer
        this->attachDepthBuffer( depthBuf );
    }
}
开发者ID:ahlekoofe,项目名称:gamekit,代码行数:83,代码来源:OgreD3D11RenderWindow.cpp

示例2: ZeroMemory


//.........这里部分代码省略.........
            descDepth.SampleDesc.Count = mFSAAType.Count;
            descDepth.SampleDesc.Quality = mFSAAType.Quality;
            descDepth.Usage = D3D11_USAGE_DEFAULT;
            descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL;
            descDepth.CPUAccessFlags = 0;
            descDepth.MiscFlags = 0;

            hr = mDevice->CreateTexture2D( &descDepth, NULL, &pDepthStencil );
            if( FAILED(hr) || mDevice.isError())
            {
                String errorDescription = mDevice.getErrorDescription(hr);
                OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
                            "Unable to create depth texture\nError Description:" + errorDescription,
                            "D3D11RenderWindow::createD3DResources");
            }

            // Create the depth stencil view
            D3D11_DEPTH_STENCIL_VIEW_DESC descDSV;
            ZeroMemory( &descDSV, sizeof(D3D11_DEPTH_STENCIL_VIEW_DESC) );

            descDSV.Format = DXGI_FORMAT_D32_FLOAT;
            descDSV.ViewDimension = mFSAA ? D3D11_DSV_DIMENSION_TEXTURE2DMS : D3D11_DSV_DIMENSION_TEXTURE2D;
            descDSV.Texture2D.MipSlice = 0;
            hr = mDevice->CreateDepthStencilView( pDepthStencil, &descDSV, &mDepthStencilView );
            SAFE_RELEASE( pDepthStencil );
            if( FAILED(hr) )
            {
                String errorDescription = mDevice.getErrorDescription();
                OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
                            "Unable to create depth stencil view\nError Description:" + errorDescription,
                            "D3D11RenderWindow::createD3DResources");
            }

            DepthBuffer *depthBuf = rsys->_addManualDepthBuffer( mDepthStencilView, mWidth, mHeight,
                                    mFSAAType.Count, mFSAAType.Quality );

            //Don't forget we want this window to use _this_ depth buffer
            this->attachDepthBuffer( depthBuf );
        }
        else
        {
            //				mpRenderZBuffer = 0;
        }
    }
    /*else
    {
    if (!mDevice)
    {
    // We haven't created the device yet, this must be the first time

    // Do we want to preserve the FPU mode? Might be useful for scientific apps
    DWORD extraFlags = 0;
    ConfigOptionMap& options = Root::getSingleton().getRenderSystem()->getConfigOptions();
    ConfigOptionMap::iterator opti = options.find("Floating-point mode");
    if (opti != options.end() && opti->second.currentValue == "Consistent")
    extraFlags |= D3DCREATE_FPU_PRESERVE;

    #if OGRE_THREAD_SUPPORT
    extraFlags |= D3DCREATE_MULTITHREADED;
    #endif
    // Set default settings (use the one Ogre discovered as a default)
    UINT adapterToUse = mDriver->getAdapterNumber();

    if (mUseNVPerfHUD)
    {
    // Look for 'NVIDIA NVPerfHUD' adapter (<= v4)
开发者ID:gbruce,项目名称:ogre3d_trunk,代码行数:67,代码来源:OgreD3D11RenderWindow.cpp


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