示例#1
0
HRESULT STDMETHODCALLTYPE CDXGISwapChainDWM::ResizeBuffers(UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags)
{
    return m_pSwapChain->ResizeBuffers(BufferCount, Width, Height, NewFormat, SwapChainFlags);
}
示例#2
0
HRESULT ACD3D::Resize(UINT width, UINT height)
{
	HRESULT hr;

	//mata o anterior
	SAFE_RELEASE(mpVpComponents[mActiveWnd]->pRenderTargetView);
	SAFE_RELEASE(mpVpComponents[mActiveWnd]->pDepthStencilView);

	#pragma region RESIZE BACKBUFFER
	IDXGISwapChain* pSwapChain = mpVpComponents[mActiveWnd]->pSwapChain;
	hr = pSwapChain->ResizeBuffers(1, width, height, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH);
	if( FAILED( hr ) )
	{
		MessageBoxA(nullptr, "[ERROR] ResizeBuffer. Resize()", "Error", MB_OK | MB_ICONERROR);
		return hr;
	}
	#pragma endregion

	#pragma region CREATE RENDERTARGETVIEW
	//array de backbuffers, um pra cada janela
	ID3D11Texture2D* pBackBuffer;
	ID3D11RenderTargetView* pRenderTargetView;
	hr = pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer );
	if( FAILED( hr ) )
	{
		MessageBoxA(nullptr, "[ERROR] Create Buffer. Resize()", "Error", MB_OK | MB_ICONERROR);
		return hr;
	}

	hr = ACD3DGlobals::G_pD3dDevice->CreateRenderTargetView( pBackBuffer, nullptr, &pRenderTargetView );
	if( FAILED( hr ) )
	{
		MessageBoxA(nullptr, "[ERROR] Create render target view. Resize()", "Error", MB_OK | MB_ICONERROR);
		return hr;
	}

	mpVpComponents[mActiveWnd]->pRenderTargetView = pRenderTargetView;
	pBackBuffer->Release();
	#pragma endregion

	#pragma region CREATE DEPTHSTENCILVIEW
	//cria outro com as novas configuracoes
	ID3D11Texture2D* pDepthStencil;
	ID3D11DepthStencilView* pDepthStencilView;
	//define o stencil view
	hr = ACD3DConfigurations::DefineDepthStencilView(ACD3DGlobals::G_pD3dDevice,
													&pDepthStencil, &pDepthStencilView, 
													width, height);
	if( FAILED( hr ) )
	{
		MessageBoxA(nullptr, "[ERROR] Create depth stencil view. Resize()", "Error", MB_OK | MB_ICONERROR);
		return hr;
	}

	mpVpComponents[mActiveWnd]->pDepthStencilView = pDepthStencilView;

	pDepthStencil->Release();
	#pragma endregion

	#pragma region RESIZE VIEWPORT
	mpVpComponents[mActiveWnd]->Viewport.Width = width;
	mpVpComponents[mActiveWnd]->Viewport.Height = height;
	#pragma endregion

	//seta a viewport
	ACD3DGlobals::G_pContext->RSSetViewports( 1, &mpVpComponents[mActiveWnd]->Viewport );

	//seta o render target e o depthstencil
	ACD3DGlobals::G_pContext->OMSetRenderTargets( 1, &pRenderTargetView, pDepthStencilView );

	return AC_OK;
};
示例#3
-1
    HRESULT STDMETHODCALLTYPE SwapResizeBuffersHook(UINT bufferCount, UINT width, UINT height, DXGI_FORMAT giFormat, UINT flags)
    {
        IDXGISwapChain *swap = (IDXGISwapChain*)this;

        gi11swapResizeBuffers.Unhook();
        HRESULT hRes = swap->ResizeBuffers(bufferCount, width, height, giFormat, flags);
        gi11swapResizeBuffers.Rehook();

        if(lpCurrentSwap == NULL && !bTargetAcquired)
        {
            lpCurrentSwap = swap;
            bTargetAcquired = true;
        }

        if(lpCurrentSwap == swap)
            SetupD3D11(swap);

        return hRes;
    }