本文整理汇总了C++中CPUTAssetLibraryDX11::AddTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ CPUTAssetLibraryDX11::AddTexture方法的具体用法?C++ CPUTAssetLibraryDX11::AddTexture怎么用?C++ CPUTAssetLibraryDX11::AddTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPUTAssetLibraryDX11
的用法示例。
在下文中一共展示了CPUTAssetLibraryDX11::AddTexture方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Present
// incoming resize event to be handled and translated
//-----------------------------------------------------------------------------
void CPUT_DX11::ResizeWindow(UINT width, UINT height)
{
HRESULT hr;
CPUTResult result;
CPUTAssetLibraryDX11 *pAssetLibrary = (CPUTAssetLibraryDX11*)CPUTAssetLibraryDX11::GetAssetLibrary();
// TODO: Making the back and depth buffers into CPUTRenderTargets should simplify this (CPUTRenderTarget* manages RTV, SRV, UAV, etc.)
if( mpBackBuffer ) ((CPUTBufferDX11*)mpBackBuffer)->ReleaseBuffer();
if( mpDepthBuffer ) ((CPUTBufferDX11*)mpDepthBuffer)->ReleaseBuffer();
if( mpBackBufferTexture ) ((CPUTTextureDX11*)mpBackBufferTexture)->ReleaseTexture();
if( mpDepthBufferTexture ) ((CPUTTextureDX11*)mpDepthBufferTexture)->ReleaseTexture();
// Make sure we don't have any buffers bound.
mpContext->ClearState();
Present();
mpContext->Flush();
SAFE_RELEASE(mpBackBufferRTV);
SAFE_RELEASE(mpBackBufferSRV);
SAFE_RELEASE(mpBackBufferUAV);
SAFE_RELEASE(mpDepthStencilSRV);
CPUT::ResizeWindow( width, height );
// Call the sample's clean up code if present.
ReleaseSwapChain();
// handle the internals of a resize
int windowWidth, windowHeight;
CPUTOSServices *pServices = CPUTOSServices::GetOSServices();
pServices->GetClientDimensions( &windowWidth, &windowHeight);
// resize the swap chain
hr = mpSwapChain->ResizeBuffers(mSwapChainBufferCount, windowWidth, windowHeight, mSwapChainFormat, 0);
ASSERT( SUCCEEDED(hr), _L("Error resizing swap chain") );
// re-create the render-target view
ID3D11Texture2D *pSwapChainBuffer = NULL;
hr = mpSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D), (LPVOID*) (&pSwapChainBuffer));
ASSERT(SUCCEEDED(hr), _L(""));
hr = mpD3dDevice->CreateRenderTargetView( pSwapChainBuffer, NULL, &mpBackBufferRTV);
ASSERT(SUCCEEDED(hr), _L(""));
hr = mpD3dDevice->CreateShaderResourceView( pSwapChainBuffer, NULL, &mpBackBufferSRV);
ASSERT(SUCCEEDED(hr), _L(""));
#ifdef CREATE_SWAP_CHAIN_UAV
// Not every DXGI format supports UAV. So, create UAV only if sample chooses to do so.
hr = mpD3dDevice->CreateUnorderedAccessView( pSwapChainBuffer, NULL, &mpBackBufferUAV);
ASSERT(SUCCEEDED(hr), _L(""));
#endif
// Add the back buffer to the asset library. Create CPUTBuffer and a CPUTTexture forms and add them.
if( mpBackBuffer )
{
((CPUTBufferDX11*)mpBackBuffer)->SetBufferAndViews( NULL, mpBackBufferSRV, mpBackBufferUAV );
}
else
{
cString backBufferName = _L("$BackBuffer");
mpBackBuffer = new CPUTBufferDX11( backBufferName, NULL, mpBackBufferUAV );
pAssetLibrary->AddBuffer( backBufferName, mpBackBuffer );
}
if( mpBackBufferTexture )
{
((CPUTTextureDX11*)mpBackBufferTexture)->SetTextureAndShaderResourceView( NULL, mpBackBufferSRV );
}
else
{
cString backBufferName = _L("$BackBuffer");
mpBackBufferTexture = new CPUTTextureDX11( backBufferName, NULL, mpBackBufferSRV );
pAssetLibrary->AddTexture( backBufferName, mpBackBufferTexture );
}
// release the old depth buffer objects
// release the temporary swap chain buffer
SAFE_RELEASE(pSwapChainBuffer);
SAFE_RELEASE(mpDepthStencilBuffer);
SAFE_RELEASE(mpDepthStencilState);
SAFE_RELEASE(mpDepthStencilView);
result = CreateAndBindDepthBuffer(windowWidth, windowHeight);
if(CPUTFAILED(result))
{
// depth buffer creation error
ASSERT(0,_L(""));
}
if( mpDepthBuffer )
{
((CPUTBufferDX11*)mpDepthBuffer)->SetBufferAndViews( NULL, mpDepthStencilSRV, NULL );
}
else
{
cString depthBufferName = _L("$DepthBuffer");
mpDepthBuffer = new CPUTBufferDX11( depthBufferName, NULL, mpDepthStencilSRV );
pAssetLibrary->AddBuffer( depthBufferName, mpDepthBuffer );
}
if( mpDepthBufferTexture )
{
((CPUTTextureDX11*)mpDepthBufferTexture)->SetTextureAndShaderResourceView( NULL, mpDepthStencilSRV );
//.........这里部分代码省略.........