コード例 #1
0
 public static void FreeRenderTarget(RenderTargetAsset Asset)
 {
     if (Asset != null)
     {
         Asset.InUse = false;
     }
 }
コード例 #2
0
 public override void SetupBrush(FrameworkElement parent, ref PositionColoredTextured[] verts, float zOrder, bool adaptVertsToBrushTexture)
 {
     base.SetupBrush(parent, ref verts, zOrder, adaptVertsToBrushTexture);
     _visualTexture = ContentManager.Instance.GetRenderTexture(_renderTextureKey);
     _visualSurface = ContentManager.Instance.GetRenderTarget(_renderSurfaceKey);
     _screen        = parent.Screen;
     PrepareVisual();
 }
コード例 #3
0
 public override void BeginRender()
 {
     // Remember current backbuffer and set internal surface as new render target.
     _backbuffer   = GraphicsDevice.Device.GetRenderTarget(0);
     _renderTarget = ContentManager.Instance.GetRenderTarget(GLOBAL_RENDER_SURFACE_ASSET_KEY);
     _renderTarget.AllocateRenderTarget(GraphicsDevice.Width, GraphicsDevice.Height);
     _renderRect = new Rectangle(0, 0, GraphicsDevice.Width, GraphicsDevice.Height);
     GraphicsDevice.Device.SetRenderTarget(0, _renderTarget.Surface);
     GraphicsDevice.RenderPass = RenderPassType.SingleOrFirstPass;
     GraphicsDevice.Device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0);
     GraphicsDevice.Device.BeginScene();
 }
コード例 #4
0
 public override void BeginRender()
 {
   // Remember current backbuffer and set internal surface as new render target.
   _backbuffer = GraphicsDevice.Device.GetRenderTarget(0);
   _renderTarget = ContentManager.Instance.GetRenderTarget(GLOBAL_RENDER_SURFACE_ASSET_KEY);
   _renderTarget.AllocateRenderTarget(GraphicsDevice.Width, GraphicsDevice.Height);
   _renderRect = new Rectangle(0, 0, GraphicsDevice.Width, GraphicsDevice.Height);
   GraphicsDevice.Device.SetRenderTarget(0, _renderTarget.Surface);
   GraphicsDevice.RenderPass = RenderPassType.SingleOrFirstPass;
   GraphicsDevice.Device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0);
   GraphicsDevice.Device.BeginScene();
 }
コード例 #5
0
 /// <summary>
 /// Renders the <see cref="FrameworkElement"/> to the given <paramref name="renderTarget"/>. This method works with
 /// surfaces that are created as render target, which do support multisampling.
 /// </summary>
 /// <param name="renderTarget">Render target.</param>
 /// <param name="renderContext">Render context.</param>
 public void RenderToSurface(RenderTargetAsset renderTarget, RenderContext renderContext)
 {
   RenderToSurfaceInternal(renderTarget.Surface, renderContext);
 }
コード例 #6
0
ファイル: VisualBrush.cs プロジェクト: BigGranu/MediaPortal-2
 public override void SetupBrush(FrameworkElement parent, ref PositionColoredTextured[] verts, float zOrder, bool adaptVertsToBrushTexture)
 {
   base.SetupBrush(parent, ref verts, zOrder, adaptVertsToBrushTexture);
   _visualTexture = ContentManager.Instance.GetRenderTexture(_renderTextureKey);
   _visualSurface = ContentManager.Instance.GetRenderTarget(_renderSurfaceKey);
   _screen = parent.Screen;
   PrepareVisual();
 }
コード例 #7
0
    public void RenderToSurface(RenderTargetAsset renderTarget, RenderContext renderContext)
    {
      // We do the following here:
      // 1. Set the transformation matrix to match the render surface's size
      // 2. Set the rendertarget to the given surface
      // 3. Clear the surface with an alpha value of 0
      // 4. Render the control (into the surface)
      // 5. Restore the rendertarget to the backbuffer
      // 6. Restore previous transformation matrix

      // Set transformation matrix
      Matrix? oldTransform = null;
      if (renderTarget.Width != GraphicsDevice.Width || renderTarget.Height != GraphicsDevice.Height)
      {
        oldTransform = GraphicsDevice.FinalTransform;
        GraphicsDevice.SetCameraProjection(renderTarget.Width, renderTarget.Height);
      }
      // Get the current backbuffer
      using (Surface backBuffer = GraphicsDevice.Device.GetRenderTarget(0))
      {
        // Change the rendertarget to the render texture
        GraphicsDevice.Device.SetRenderTarget(0, renderTarget.Surface);

        // Fill the background of the texture with an alpha value of 0
        GraphicsDevice.Device.Clear(ClearFlags.Target, Color.FromArgb(0, Color.Black), 1.0f, 0);

        // Render the control into the given texture
        DoRender(renderContext);

        // Restore the backbuffer
        GraphicsDevice.Device.SetRenderTarget(0, backBuffer);
      }
      // Restore standard transformation matrix
      if (oldTransform.HasValue)
        GraphicsDevice.FinalTransform = oldTransform.Value;
    }