コード例 #1
0
ファイル: render_window.cpp プロジェクト: untgames/funner
///Обработка события изменения размеров окна
  void OnSizeChanged (unsigned int width, unsigned int height)
  {
    try
    {
      UpdateSizes (width, height);  
      
      if (signals [WindowEvent_OnResize].empty ())
        return;
      
      if (color_buffer)
      {
        color_buffer->Resize (width, height);
        depth_stencil_buffer->Resize (width, height);
      }
      
      Window window = Wrappers::Wrap<Window> (owner);
        
      signals [WindowEvent_OnResize] (window);
    }
    catch (std::exception& e)
    {
      log.Printf ("%s\n    at render::manager::WindowImpl::Impl::OnResize", e.what ());
    }
    catch (...)
    {
      log.Printf ("unknown exception\n    at render::manager::WindowImpl::Impl::OnResize");
    }
  }
コード例 #2
0
ファイル: render_window.cpp プロジェクト: untgames/funner
///Обработчик события изменения области вывода
  void OnViewportChanged (const Rect& viewport)
  {
    try
    {
      log.Printf ("Window viewport changed: x=%d, y=%d, width=%u, height=%u", viewport.x, viewport.y, viewport.width, viewport.height);
      
      if (color_buffer)
      {
        color_buffer->Resize (viewport.width, viewport.height);
        color_buffer->SetViewportOffset (math::vec2ui (viewport.x, viewport.y));
      }
      
      if (depth_stencil_buffer)
      {
        depth_stencil_buffer->Resize (viewport.width, viewport.height);
        depth_stencil_buffer->SetViewportOffset (math::vec2ui (viewport.x, viewport.y));
      }
    }
    catch (std::exception& e)
    {
      log.Printf ("%s\n    at render::manager::WindowImpl::Impl::OnChangeViewport", e.what ());      
    }
    catch (...)
    {
      log.Printf ("unknown exception\n    at render::manager::WindowImpl::Impl::OnChangeViewport");
    }
  }  
コード例 #3
0
ファイル: render_window.cpp プロジェクト: untgames/funner
///Создание целей рендеринга
  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;
    }
  }