本文整理汇总了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;
}
示例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);
}
}