本文整理汇总了C++中IDriver::CreateSwapChain方法的典型用法代码示例。如果您正苦于以下问题:C++ IDriver::CreateSwapChain方法的具体用法?C++ IDriver::CreateSwapChain怎么用?C++ IDriver::CreateSwapChain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDriver
的用法示例。
在下文中一共展示了IDriver::CreateSwapChain方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main ()
{
printf ("Results of render_targets1_test:\n");
try
{
ViewPtr view [4];
{
Test test (L"OpenGL device test first window (render_targets1)");
syslib::Window window (syslib::WindowStyle_Overlapped, 400, 200);
window.SetTitle (L"OpenGL device test second window (render_targets1)");
SwapChainDesc swap_chain_desc;
test.swap_chain->GetDesc (swap_chain_desc);
swap_chain_desc.window_handle = window.Handle ();
IAdapter* adapter = test.swap_chain->GetAdapter ();
IDriver* driver = DriverManager::FindDriver ("DX11");
if (!driver || !adapter)
{
printf ("Wrong DX11 driver configuration\n");
return 0;
}
SwapChainPtr swap_chain (driver->CreateSwapChain (test.device.get (), swap_chain_desc), false);
TexturePtr texture [4] = {
TexturePtr (test.device->CreateRenderTargetTexture (test.swap_chain.get (), 0), false),
TexturePtr (test.device->CreateDepthStencilTexture (test.swap_chain.get ()), false),
TexturePtr (test.device->CreateRenderTargetTexture (swap_chain.get (), 0), false),
TexturePtr (test.device->CreateDepthStencilTexture (swap_chain.get ()), false)
};
ViewDesc view_desc;
memset (&view_desc, 0, sizeof (view_desc));
view_desc.layer = 0;
view_desc.mip_level = 0;
for (int i=0; i<4; i++)
view [i] = ViewPtr (test.device->CreateView (texture [i].get (), view_desc), false);
test.device->GetImmediateContext ()->OSSetRenderTargetView (0, view [Window1_RenderTarget].get ());
test.device->GetImmediateContext ()->OSSetDepthStencilView (view [Window2_DepthStencil].get ());
Color4f clear_color;
clear_color.red = 0;
clear_color.green = 0.7f;
clear_color.blue = 0.7f;
clear_color.alpha = 0;
size_t rt_index = 0;
test.device->GetImmediateContext ()->ClearViews (ClearFlag_All, 1, &rt_index, &clear_color, 0.5f, 12);
test.device->GetImmediateContext ()->Draw (PrimitiveType_PointList, 0, 0);
test.swap_chain->Present ();
swap_chain->Present ();
}
}
catch (std::exception& exception)
{
printf ("exception: %s\n", exception.what ());
}
return 0;
}