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


C++ IDriver::CreateSwapChain方法代码示例

本文整理汇总了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;
}
开发者ID:untgames,项目名称:funner,代码行数:74,代码来源:render_targets1.cpp


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