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


C++ IDirect3DSwapChain9::Present方法代码示例

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


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

示例1: Present

//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
bool Renderer::Present()
{
	HRESULT hr;

	// ガンマ
	if (m_isSRGBMode)
	{
		IDirect3DSwapChain9* swapChain = nullptr;
		m_d3d_device->GetSwapChain(0, &swapChain);
		
		hr = swapChain->Present(nullptr, nullptr, nullptr, nullptr, D3DPRESENT_LINEAR_CONTENT);
		
		ES_SAFE_RELEASE(swapChain);
	}
	else
	{
		hr = m_d3d_device->Present(NULL, NULL, NULL, NULL);
	}

	switch ( hr )
	{
		// ドライバ内部の意味不明なエラー
	case D3DERR_DRIVERINTERNALERROR:
		return false;

		// デバイスロスト
	case D3DERR_DEVICELOST:
		while ( FAILED( hr = m_d3d_device->TestCooperativeLevel() ) )
		{
			switch ( hr )
			{
				// デバイスロスト
			case D3DERR_DEVICELOST:
				::SleepEx( 1000, true );
				break;
				// デバイスロスト:リセット可
			case D3DERR_DEVICENOTRESET:
				ResetDevice();
				break;
			}
		}
		break;
	}

	return true;
}
开发者ID:AraiYuhki,项目名称:Effekseer,代码行数:49,代码来源:EffekseerTool.Renderer.cpp

示例2:

/* Called when a drawing pass has ended
 */
void D3DRenderer::OnDrawEnd()
{
	mDeviceLost = false;

	mD3DDevice->SetSamplerState(0, D3DSAMP_MIPMAPLODBIAS, 0);
	mD3DDevice->EndScene();

	HRESULT result = 0;

	result = mD3DDevice->TestCooperativeLevel();
	if(result == D3DERR_DEVICELOST)
		return;

	if(result == D3DERR_DEVICENOTRESET)
	{
		mDeviceLost = true;

		// Release the existing swap chains
		SwapChainMap::iterator swapChainIt = mSwapChains.begin();
		for(; swapChainIt != mSwapChains.end(); swapChainIt++)
		{
			IDirect3DSwapChain9* pSwapChain = swapChainIt->second.mD3DSwapChain;
			if(pSwapChain)
			{
				pSwapChain->Release();
			}
		}

		// Release the shaders
		ShaderMap::iterator shaderIt = mShaders.begin();
		for(; shaderIt != mShaders.end(); shaderIt++)
		{
			(*shaderIt).second.mEffect->Release();
		}

		// Release the vbuffer
		mVertexBuffer->Release();
		mVertexBuffer = NULL;

		// Release the vertex decl
		mVertexDeclaration->Release();
		mVertexDeclaration = NULL;

		// Reset the device
		D3DPRESENT_PARAMETERS d3dpp;
		GetPresentParams(d3dpp);   
		HRESULT hr = mD3DDevice->Reset(&d3dpp);
		if(FAILED(hr))
		{
			printf("FAILED\n");
		}

		// Recreate the swap chains
		swapChainIt = mSwapChains.begin();
		for(; swapChainIt != mSwapChains.end(); swapChainIt++)
		{
			SwapChain swapChain = swapChainIt->second;
			CreateContext(swapChain.mWindow, swapChain.mWidth, swapChain.mHeight, swapChainIt->first);
		}

		// Create the Vertex Buffer
		CreateBuffers();

		// Recreate the shaders
		ShaderMap tmp = mShaders;
		mShaders.clear();

		CreateShaders();

		shaderIt = tmp.begin();
		for(; shaderIt != tmp.end(); shaderIt++)
		{
			Shader& shader = shaderIt->second;
			if(shader.mSource != "")
				LoadShader(shader.mName.c_str(), shader.mSource.c_str());
		}

		// By setting mContext to zero, we force the back-buffer changes in the next frame
		long oldContext = mContext;
		mContext = 0;
		SetContext(oldContext);
	}

	SwapChainMap::iterator it = mSwapChains.find(mContext);
	if(it != mSwapChains.end())
	{
		IDirect3DSwapChain9* pSwapChain = it->second.mD3DSwapChain;
		if(pSwapChain)
			result = pSwapChain->Present(NULL, NULL, NULL, NULL, 0);
	}
}
开发者ID:Mismael,项目名称:OtterUI,代码行数:93,代码来源:D3DRenderer.cpp


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