Cromon

Rendertarget9.cs

Oct 12th, 2012
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.07 KB | None | 0 0
  1.         public Rendertarget9(Device targetDevice, Viewport dstViewport)
  2.         {
  3.             mViewport = dstViewport;
  4.             mDevice = targetDevice;
  5.             Surface backBuffer = targetDevice.GetBackBuffer(0, 0);
  6.  
  7.             mTargetTexture = new Texture(
  8.                 mDevice,
  9.                 mViewport.Width,
  10.                 mViewport.Height,
  11.                 1,
  12.                 Usage.RenderTarget,
  13.                 backBuffer.Description.Format,
  14.                 Pool.Default
  15.             );
  16.  
  17.             backBuffer.Dispose();
  18.  
  19.             mTargetSurface = mTargetTexture.GetSurfaceLevel(0);
  20.  
  21.             mDeclaration = new VertexDeclaration(targetDevice,
  22.                 new VertexElement[]
  23.                 {
  24.                     new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0),
  25.                     new VertexElement(0, 12, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0),
  26.                     new VertexElement(0, 16, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
  27.                     VertexElement.VertexDeclarationEnd
  28.                 }
  29.             );
  30.  
  31.             mShader = new Shader9(targetDevice);
  32.             LoadVertices();
  33.  
  34.             mScreenMatrix = Matrix.OrthoLH(mViewport.Width, mViewport.Height, 0, 1);
  35.  
  36.             mDevice.SetRenderState(RenderState.AlphaBlendEnable, true);
  37.             mDevice.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
  38.             mDevice.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
  39.  
  40.             mRectDrawProvider = new DrawRectangle(this, mDevice);
  41.             mEllipseProvider = new EllipseProvider(mDevice, this);
  42.         }
  43.  
  44.         public override void BeginUI()
  45.         {
  46.             if (mBaseRendertarget != null)
  47.                 mBaseRendertarget.Dispose();
  48.  
  49.             mBaseRendertarget = mDevice.GetRenderTarget(0);
  50.             mDevice.SetRenderTarget(0, mTargetSurface);
  51.             mDevice.Clear(ClearFlags.Target, 0, 0, 0);
  52.         }
Advertisement
Add Comment
Please, Sign In to add comment