예제 #1
0
///Создание целей рендеринга
  void CreateRenderTargets ()
  {
    try
    {
      if (!swap_chain)
        throw xtl::format_operation_exception ("", "Null swap chain");
        
      log.Printf ("Initialize render targets for swap chain");
      
      LowLevelTexturePtr color_texture (device_manager->Device ().CreateRenderTargetTexture (swap_chain.get (), swap_chain_desc.buffers_count - 1), false),
                         depth_stencil_texture (device_manager->Device ().CreateDepthStencilTexture (swap_chain.get ()), false);
 
      if (!color_buffer)
      {
        RenderTargetPtr new_color_buffer (new RenderTargetImpl (device_manager, color_texture.get ()), false),
                        new_depth_stencil_buffer (new RenderTargetImpl (device_manager, depth_stencil_texture.get ()), false);
        
        color_buffer         = new_color_buffer;
        depth_stencil_buffer = new_depth_stencil_buffer;
      }
      else
      {
        try
        {
          color_buffer->SetTarget (color_texture.get ());
          depth_stencil_buffer->SetTarget (depth_stencil_texture.get ());
        }
        catch (...)
        {
          color_buffer->SetTarget (0);
          depth_stencil_buffer->SetTarget (0);

          throw;
        }
      }
      
      color_buffer->Resize (width, height);
      depth_stencil_buffer->Resize (width, height);
      
      log.Printf ("...render targets for swap chain created");
    }
    catch (xtl::exception& e)
    {
      e.touch ("render::manager::WindowImpl::Impl::CreateRenderTargets");
      throw;
    }
  }
예제 #2
0
///Обработка события смены оконного дескриптора
  void OnHandleChanged (void* handle)
  {
    try
    {
      log.Printf ("Swap chain handle changed (handle=%p)", handle);
      
      swap_chain = 0;
      
      if (!handle)
        return;

      CreateSwapChain (handle);
      
      try
      {        
        CreateRenderTargets ();
      }
      catch (...)
      {
        swap_chain = 0;
        
        if (color_buffer)         color_buffer->SetTarget (0);
        if (depth_stencil_buffer) depth_stencil_buffer->SetTarget (0);
        
        throw;
      }
    }
    catch (std::exception& e)
    {
      log.Printf ("%s\n    at render::manager::WindowImpl::Impl::OnChangeHandle", e.what ());
    }
    catch (...)
    {
      log.Printf ("unknown exception\n    at render::manager::WindowImpl::Impl::OnChangeHandle");
    }
  }