Exemplo n.º 1
0
 public CompositionPass(CompositionTargetPass parent)
 {
     this.parent                   = parent;
     this.type                     = CompositorPassType.RenderQuad;
     this.identifier               = 0;
     this.firstRenderQueue         = RenderQueueGroupID.Background;
     this.lastRenderQueue          = RenderQueueGroupID.SkiesLate;
     this.materialSchemeName       = string.Empty;
     this.clearBuffers             = FrameBufferType.Color | FrameBufferType.Depth;
     this.clearColor               = new ColorEx(0f, 0f, 0f, 0f);
     this.clearDepth               = 1.0f;
     this.clearStencil             = 0;
     this.stencilCheck             = false;
     this.stencilFunc              = CompareFunction.AlwaysPass;
     this.stencilRefValue          = 0;
     this.stencilMask              = 0x7FFFFFFF;
     this.stencilFailOp            = StencilOperation.Keep;
     this.stencilDepthFailOp       = StencilOperation.Keep;
     this.stencilPassOp            = StencilOperation.Keep;
     this.stencilTwoSidedOperation = false;
     this.quadCornerModified       = false;
     this.quadLeft                 = -1;
     this.quadTop                  = 1;
     this.quadRight                = 1;
     this.quadBottom               = -1;
     this.quadFarCorners           = false;
     this.quadFarCornersViewSpace  = false;
 }
Exemplo n.º 2
0
        /// <summary>
        ///		The constructor. Dimensions of the viewport are expressed as a pecentage between
        ///		0 and 100. This allows the dimensions to apply irrespective of
        ///		changes in the target's size: e.g. to fill the whole area,
        ///		values of 0,0,100,100 are appropriate.
        /// </summary>
        /// <param name="camera">Reference to the camera to be the source for the image.</param>
        /// <param name="target">Reference to the render target to be the destination for the rendering.</param>
        /// <param name="left">Left</param>
        /// <param name="top">Top</param>
        /// <param name="width">Width</param>
        /// <param name="height">Height</param>
        /// <param name="zOrder">Relative Z-order on the target. Lower = further to the front.</param>
        public Viewport(Camera camera, RenderTarget target, float left, float top, float width, float height, int zOrder)
            : base()
        {
            LogManager.Instance.Write(
                "Creating viewport rendering from camera '{0}', relative dimensions L:{1},T:{2},W:{3},H:{4}, Z-Order:{5}",
                camera.Name, left, top, width, height, zOrder);

            Camera = camera;
            Target = target;

            Left   = left;
            Top    = top;
            Width  = width;
            Height = height;

            ZOrder = zOrder;

            BackgroundColor = ColorEx.Black;

            ClearDepth      = 1.0;
            ClearEveryFrame = true;
            ClearBuffers    = FrameBufferType.Color | FrameBufferType.Depth;

            IsUpdated    = false;
            ShowOverlays = true;
            ShowSkies    = true;
            ShowShadows  = true;

            VisibilityMask = 0xFFFFFFFFu;

            IsAutoUpdated = true;

            OrientationMode = DefaultOrientationMode;

            // MaterialScheme = MaterialManager.DefaultSchemeName;
            MaterialScheme = Root.Instance.RenderSystem.DefaultViewportMaterialScheme;

            // Calculate actual dimensions
            UpdateDimensions();

            // notify camera
            if (camera != null)
            {
                camera.NotifyViewport(this);
            }
        }
Exemplo n.º 3
0
        public void Clear(FrameBufferType buffers, ColorEx col, Real depth, ushort stencil)
        {
            var rs = Root.Instance.RenderSystem;

            if (rs == null)
            {
                return;
            }

            var currentvp = rs.Viewport;

            rs.Viewport = this;
            rs.ClearFrameBuffer(buffers, col, depth, stencil);
            if (currentvp != null && currentvp != this)
            {
                rs.Viewport = currentvp;
            }
        }
Exemplo n.º 4
0
        public CompositorChain(Viewport vp)
        {
            this.viewport                  = vp;
            this.originalScene             = null;
            this.instances                 = new List <CompositorInstance>();
            this.dirty                     = true;
            this.anyCompositorsEnabled     = false;
            this.compiledState             = new List <CompositeTargetOperation>();
            this.outputOperation           = null;
            this.oldClearEveryFrameBuffers = this.viewport.ClearBuffers;
            this.renderSystemOperations    = new List <CompositeRenderSystemOperation>();

            CreateOriginalScene();
            this.listener = new RQListener();
            Debug.Assert(this.viewport != null);

            this.viewport.Target.BeforeUpdate         += BeforeRenderTargetUpdate;
            this.viewport.Target.AfterUpdate          += AfterRenderTargetUpdate;
            this.viewport.Target.BeforeViewportUpdate += BeforeViewportUpdate;
            this.viewport.Target.AfterViewportUpdate  += AfterViewportUpdate;
        }
Exemplo n.º 5
0
 private static extern void Viewport_clear4(IntPtr viewport, FrameBufferType buffers, Color color, float depth);
Exemplo n.º 6
0
 private static extern void Viewport_clear3(IntPtr viewport, FrameBufferType buffers, Color color);
Exemplo n.º 7
0
 private static extern void Viewport_clear2(IntPtr viewport, FrameBufferType buffers);
Exemplo n.º 8
0
 public void clear(FrameBufferType buffers, Color color, float depth, ushort stencil)
 {
     Viewport_clear5(viewport, buffers, color, depth, stencil);
 }
Exemplo n.º 9
0
		/// <summary>
		///		The constructor. Dimensions of the viewport are expressed as a pecentage between
		///		0 and 100. This allows the dimensions to apply irrespective of
		///		changes in the target's size: e.g. to fill the whole area,
		///		values of 0,0,100,100 are appropriate.
		/// </summary>
		/// <param name="camera">Reference to the camera to be the source for the image.</param>
		/// <param name="target">Reference to the render target to be the destination for the rendering.</param>
		/// <param name="left">Left</param>
		/// <param name="top">Top</param>
		/// <param name="width">Width</param>
		/// <param name="height">Height</param>
		/// <param name="zOrder">Relative Z-order on the target. Lower = further to the front.</param>
		public Viewport( Camera camera, RenderTarget target, float left, float top, float width, float height, int zOrder )
			: base()
		{
			LogManager.Instance.Write(
				"Creating viewport rendering from camera '{0}', relative dimensions L:{1},T:{2},W:{3},H:{4}, Z-Order:{5}",
				camera.Name, left, top, width, height, zOrder );

			Camera = camera;
			Target = target;

			Left = left;
			Top = top;
			Width = width;
			Height = height;

			ZOrder = zOrder;

			BackgroundColor = ColorEx.Black;

			ClearDepth = 1.0;
			ClearEveryFrame = true;
			ClearBuffers = FrameBufferType.Color | FrameBufferType.Depth;

			IsUpdated = false;
			ShowOverlays = true;
			ShowSkies = true;
			ShowShadows = true;

			VisibilityMask = 0xFFFFFFFFu;

			IsAutoUpdated = true;

			OrientationMode = DefaultOrientationMode;

			// MaterialScheme = MaterialManager.DefaultSchemeName;
			MaterialScheme = Root.Instance.RenderSystem.DefaultViewportMaterialScheme;

			// Calculate actual dimensions
			UpdateDimensions();

			// notify camera
			if ( camera != null )
			{
				camera.NotifyViewport( this );
			}
		}
Exemplo n.º 10
0
		public RSClearOperation( FrameBufferType buffers, ColorEx color, float depth, int stencil )
		{
			this.buffers = buffers;
			this.color = color;
			this.depth = depth;
			this.stencil = stencil;
		}
Exemplo n.º 11
0
		public CompositorChain( Viewport vp )
		{
			this.viewport = vp;
			this.originalScene = null;
			this.instances = new List<CompositorInstance>();
			this.dirty = true;
			this.anyCompositorsEnabled = false;
			this.compiledState = new List<CompositeTargetOperation>();
			this.outputOperation = null;
			this.oldClearEveryFrameBuffers = this.viewport.ClearBuffers;
			this.renderSystemOperations = new List<CompositeRenderSystemOperation>();

			CreateOriginalScene();
			this.listener = new RQListener();
			Debug.Assert( this.viewport != null );

			this.viewport.Target.BeforeUpdate += BeforeRenderTargetUpdate;
			this.viewport.Target.AfterUpdate += AfterRenderTargetUpdate;
			this.viewport.Target.BeforeViewportUpdate += BeforeViewportUpdate;
			this.viewport.Target.AfterViewportUpdate += AfterViewportUpdate;
		}
Exemplo n.º 12
0
		public override void ClearFrameBuffer( FrameBufferType buffers, ColorEx color, Real depth, ushort stencil )
		{
			bool colorMask = !this.colorWrite[ 0 ] || !this.colorWrite[ 1 ] || !this.colorWrite[ 2 ] || !this.colorWrite[ 3 ];

			int flags = 0;
			if ( ( buffers & FrameBufferType.Color ) == FrameBufferType.Color )
			{
				flags |= (int) GLenum.ColorBufferBit;
				//Enable buffer for writing if it isn't
				if ( colorMask )
				{
					GL.ColorMask( true, true, true, true );
					GLES2Config.GlCheckError( this );
				}
				GL.ClearColor( color.r, color.g, color.b, color.a );
				GLES2Config.GlCheckError( this );
			}
			if ( ( buffers & FrameBufferType.Depth ) == FrameBufferType.Depth )
			{
				flags |= (int) GLenum.DepthBufferBit;
				//Enable buffer for writing if it isn't
				if ( !this.depthWrite )
				{
					GL.DepthMask( true );
					GLES2Config.GlCheckError( this );
				}
				GL.ClearDepth( depth );
				GLES2Config.GlCheckError( this );
			}
			if ( ( buffers & FrameBufferType.Stencil ) == FrameBufferType.Stencil )
			{
				flags |= (int) GLenum.StencilBufferBit;
				//Enable buffer for writing if it isn't
				GL.StencilMask( 0xFFFFFFFF );
				GLES2Config.GlCheckError( this );
				GL.ClearStencil( stencil );
				GLES2Config.GlCheckError( this );
			}

			//Should be enable scissor test due the clear region
			// is relied on scissor box bounds.
			bool scissorTestEnabled = GL.IsEnabled( GLenum.ScissorTest );

			if ( !scissorTestEnabled )
			{
				GL.Enable( GLenum.ScissorTest );
				GLES2Config.GlCheckError( this );
			}
			//Sets the scissor box as same as viewport

			var viewport = new int[ 4 ];
			var scissor = new int[ 4 ];
			GL.GetInteger( GLenum.Viewport, viewport );
			GLES2Config.GlCheckError( this );
			GL.GetInteger( GLenum.ScissorBox, scissor );
			GLES2Config.GlCheckError( this );

			bool scissorBoxDifference = viewport[ 0 ] != scissor[ 0 ] || viewport[ 1 ] != scissor[ 1 ] || viewport[ 2 ] != scissor[ 2 ] || viewport[ 3 ] != scissor[ 3 ];

			if ( scissorBoxDifference )
			{
				GL.Scissor( viewport[ 0 ], viewport[ 1 ], viewport[ 2 ], viewport[ 3 ] );
				GLES2Config.GlCheckError( this );
			}

			this.DiscardBuffers = (int) buffers;

			//Clear buffers
			GL.Clear( flags );
			GLES2Config.GlCheckError( this );

			//Restore scissor box
			if ( scissorBoxDifference )
			{
				GL.Scissor( scissor[ 0 ], scissor[ 1 ], scissor[ 2 ], scissor[ 3 ] );
				GLES2Config.GlCheckError( this );
			}

			//Restore scissor test
			if ( !scissorTestEnabled )
			{
				GL.Disable( GLenum.ScissorTest );
				GLES2Config.GlCheckError( this );
			}

			//Reset buffer write state
			if ( this.depthWrite && ( buffers & FrameBufferType.Depth ) == FrameBufferType.Depth )
			{
				GL.DepthMask( false );
				GLES2Config.GlCheckError( this );
			}

			if ( colorMask && ( buffers & FrameBufferType.Color ) == FrameBufferType.Color )
			{
				GL.ColorMask( this.colorWrite[ 0 ], this.colorWrite[ 1 ], this.colorWrite[ 2 ], this.colorWrite[ 3 ] );
				GLES2Config.GlCheckError( this );
			}

			if ( ( buffers & FrameBufferType.Stencil ) == FrameBufferType.Stencil )
			{
				GL.StencilMask( this.stencilMask );
				GLES2Config.GlCheckError( this );
			}
		}
Exemplo n.º 13
0
 public void SetClearEveryFrame(bool inClear, FrameBufferType inBuffers)
 {
     ClearEveryFrame = inClear;
     ClearBuffers    = inBuffers;
 }
Exemplo n.º 14
0
		public override void ClearFrameBuffer( FrameBufferType buffers, ColorEx color, float depth, int stencil )
		{
			bool colorMask = !_colorWrite[ 0 ] || !_colorWrite[ 1 ] || !_colorWrite[ 2 ] || !_colorWrite[ 3 ];
			int flags = 0;
			if ( ( buffers & FrameBufferType.Color ) != 0 )
			{
				flags |= (int)All.ColorBufferBit;
				// Enable buffer for writing if it isn't
				if ( colorMask )
				{
					OpenGL.ColorMask( true, true, true, true );
					GLESConfig.GlCheckError( this );
				}
				OpenGL.ClearColor( color.r, color.g, color.b, color.a );
				GLESConfig.GlCheckError( this );
			}

			if ( ( buffers & FrameBufferType.Depth ) != 0 )
			{
				flags |= (int)All.DepthBufferBit;
				// Enable buffer for writing if it isn't
				if ( !depthWrite )
				{
					OpenGL.DepthMask( true );
					GLESConfig.GlCheckError( this );
				}
				OpenGL.ClearDepth( depth );
				GLESConfig.GlCheckError( this );
			}

			if ( ( buffers & FrameBufferType.Stencil ) != 0 )
			{
				flags |= (int)All.StencilBufferBit;
				// Enable buffer for writing if it isn't
				OpenGL.StencilMask( 0xFFFFFFFF );
				GLESConfig.GlCheckError( this );
				OpenGL.ClearStencil( stencil );
				GLESConfig.GlCheckError( this );
			}

			// Should be enable scissor test due the clear region is
			// relied on scissor box bounds.
			bool scissorTestEnabled = OpenGL.IsEnabled( All.ScissorTest );
			GLESConfig.GlCheckError( this );
			if ( !scissorTestEnabled )
			{
				OpenGL.Enable( All.ScissorTest );
				GLESConfig.GlCheckError( this );
			}

			// Sets the scissor box as same as viewport
			unsafe
			{
				int[] viewport = new int[ 4 ];
				int[] scissor = new int[ 4 ];
				//OpenGL.GetInteger(All.Viewport, viewport);
				GLESConfig.GlCheckError( this );
				//OpenGL.GetInteger(All.ScissorBox, scissor);
				GLESConfig.GlCheckError( this );
				bool scissorBoxDifference =
					viewport[ 0 ] != scissor[ 0 ] || viewport[ 1 ] != scissor[ 1 ] ||
					viewport[ 2 ] != scissor[ 2 ] || viewport[ 3 ] != scissor[ 3 ];
				if ( scissorBoxDifference )
				{
					OpenGL.Scissor( viewport[ 0 ], viewport[ 1 ], viewport[ 2 ], viewport[ 3 ] );
					GLESConfig.GlCheckError( this );
				}

				//clear buffers
				OpenGL.Clear( flags );
				GLESConfig.GlCheckError( this );

				//restore scissor box
				if ( scissorBoxDifference )
				{
					OpenGL.Scissor( scissor[ 0 ], scissor[ 1 ], scissor[ 2 ], scissor[ 3 ] );
					GLESConfig.GlCheckError( this );
				}
			}

			// Restore scissor test
			if ( !scissorTestEnabled )
			{
				OpenGL.Disable( All.ScissorTest );
				GLESConfig.GlCheckError( this );
			}

			// Reset buffer write state
			if ( !depthWrite && ( ( buffers & FrameBufferType.Depth ) != 0 ) )
			{
				OpenGL.DepthMask( false );
				GLESConfig.GlCheckError( this );
			}

			if ( colorMask && ( ( buffers & FrameBufferType.Color ) != 0 ) )
			{
				OpenGL.ColorMask( _colorWrite[ 0 ], _colorWrite[ 1 ], _colorWrite[ 2 ], _colorWrite[ 3 ] );
				GLESConfig.GlCheckError( this );
			}
			if ( ( buffers & FrameBufferType.Stencil ) != 0 )
			{
				OpenGL.StencilMask( _stencilMask );
				GLESConfig.GlCheckError( this );
			}


		}
Exemplo n.º 15
0
		public void SetClearEveryFrame( bool inClear, FrameBufferType inBuffers )
		{
			ClearEveryFrame = inClear;
			ClearBuffers = inBuffers;
		}
Exemplo n.º 16
0
            /// <see cref="Translator.Translate"/>
            public override void Translate(ScriptCompiler compiler, AbstractNode node)
            {
                var obj = (ObjectAbstractNode)node;

                this._Pass = (CompositionPass)obj.Parent.Context;

                // Should be no parameters, just children
                if (obj.Values.Count != 0)
                {
                    compiler.AddError(CompileErrorCode.UnexpectedToken, obj.File, obj.Line);
                }

                foreach (var i in obj.Children)
                {
                    if (i is ObjectAbstractNode)
                    {
                        processNode(compiler, i);
                    }
                    else if (i is PropertyAbstractNode)
                    {
                        var prop = (PropertyAbstractNode)i;
                        switch ((Keywords)prop.Id)
                        {
                            #region ID_BUFFERS

                        case Keywords.ID_BUFFERS:
                        {
                            FrameBufferType buffers = 0;
                            foreach (var k in prop.Values)
                            {
                                if (k is AtomAbstractNode)
                                {
                                    switch ((Keywords)((AtomAbstractNode)k).Id)
                                    {
                                    case Keywords.ID_COLOUR:
                                        buffers |= FrameBufferType.Color;
                                        break;

                                    case Keywords.ID_DEPTH:
                                        buffers |= FrameBufferType.Depth;
                                        break;

                                    case Keywords.ID_STENCIL:
                                        buffers |= FrameBufferType.Stencil;
                                        break;

                                    default:
                                        compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                                        break;
                                    }
                                }
                                else
                                {
                                    compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                                }
                            }
                            this._Pass.ClearBuffers = buffers;
                        }
                        break;

                            #endregion ID_BUFFERS

                            #region ID_COLOUR_VALUE

                        case Keywords.ID_COLOUR_VALUE:
                        {
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line);
                                return;
                            }

                            var val = ColorEx.White;
                            if (getColor(prop.Values, 0, out val))
                            {
                                this._Pass.ClearColor = val;
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        break;

                            #endregion ID_COLOUR_VALUE

                            #region ID_DEPTH_VALUE

                        case Keywords.ID_DEPTH_VALUE:
                        {
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line);
                                return;
                            }
                            Real val = 0;
                            if (getReal(prop.Values[0], out val))
                            {
                                this._Pass.ClearDepth = val;
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        break;

                            #endregion ID_DEPTH_VALUE

                            #region ID_STENCIL_VALUE

                        case Keywords.ID_STENCIL_VALUE:
                        {
                            if (prop.Values.Count == 0)
                            {
                                compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line);
                                return;
                            }

                            var val = 0;
                            if (getInt(prop.Values[0], out val))
                            {
                                this._Pass.ClearStencil = val;
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        break;

                            #endregion ID_STENCIL_VALUE

                        default:
                            compiler.AddError(CompileErrorCode.UnexpectedToken, prop.File, prop.Line,
                                              "token \"" + prop.Name + "\" is not recognized");
                            break;
                        }
                    }
                }
            }
Exemplo n.º 17
0
		public override void ClearFrameBuffer( FrameBufferType buffers, 
            ColorEx color, Real depth, ushort stencil )
		{


		    var colorMask = ColorWrite[ 0 ] == 0
		                    || ColorWrite[ 1 ] == 0
		                    || ColorWrite[ 2 ] == 0
		                    || ColorWrite[ 3 ] == 0;
            var flags = 0;

			if ( ( buffers & FrameBufferType.Color ) > 0 )
			{
				flags |= Gl.GL_COLOR_BUFFER_BIT;
                // Enable buffer for writing if it isn't
			    if (colorMask)
			    {
				    Gl.glColorMask(1, 1, 1, 1);
			    }
			    Gl.glClearColor(color.r, color.g, color.b, color.a);
			}
			if ( ( buffers & FrameBufferType.Depth ) > 0 )
			{
				flags |= Gl.GL_DEPTH_BUFFER_BIT;
			    // Enable buffer for writing if it isn't
			    if (!depthWrite)
			    {
				    Gl.glDepthMask( Gl.GL_TRUE );
			    }
			    Gl.glClearDepth(depth);
			}
			if ( ( buffers & FrameBufferType.Stencil ) > 0 )
			{
				flags |= Gl.GL_STENCIL_BUFFER_BIT;
                // Enable buffer for writing if it isn't
			    Gl.glStencilMask(0xFFFFFFFF);

			    Gl.glClearStencil(stencil);
			}

            // Should be enable scissor test due the clear region is
		    // relied on scissor box bounds.
		    var scissorTestEnabled = Gl.glIsEnabled(Gl.GL_SCISSOR_TEST) != 0;
		    if (!scissorTestEnabled)
		    {
			    Gl.glEnable(Gl.GL_SCISSOR_TEST);
		    }

            // Sets the scissor box as same as viewport
            var viewport = new []{ 0, 0, 0, 0 };
            var scissor = new[]{ 0, 0, 0, 0 };
		    Gl.glGetIntegerv(Gl.GL_VIEWPORT, viewport);
		    Gl.glGetIntegerv(Gl.GL_SCISSOR_BOX, scissor);
		    bool scissorBoxDifference =
			    viewport[0] != scissor[0] || viewport[1] != scissor[1] ||
			    viewport[2] != scissor[2] || viewport[3] != scissor[3];
		    if (scissorBoxDifference)
		    {
			    Gl.glScissor(viewport[0], viewport[1], viewport[2], viewport[3]);
		    }

            // Clear buffers
		    Gl.glClear(flags);

		    // Restore scissor box
		    if (scissorBoxDifference)
		    {
			    Gl.glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
		    }
		    // Restore scissor test
		    if (!scissorTestEnabled)
		    {
			    Gl.glDisable(Gl.GL_SCISSOR_TEST);
		    }

		    // Reset buffer write state
		    if (!depthWrite && ((buffers & FrameBufferType.Depth) != 0))
		    {
			    Gl.glDepthMask( Gl.GL_FALSE );
		    }
		    if (colorMask && ((buffers & FrameBufferType.Color) != 0))
		    {
			    Gl.glColorMask(ColorWrite[0], ColorWrite[1], ColorWrite[2], ColorWrite[3]);
		    }
            if ((buffers & FrameBufferType.Stencil) != 0)
		    {
			    Gl.glStencilMask(stencilMask);
		    }
		}
Exemplo n.º 18
0
		///<summary>
		///    Compile this Composition chain into a series of RenderTarget operations.
		///</summary>
		protected void Compile()
		{
			//remove original scen if it has the wrong material scheme
			if ( this.originalSceneMaterial != this.viewport.MaterialScheme )
			{
				DestroyOriginalScene();
				CreateOriginalScene();
			}

			ClearCompiledState();

			bool compositorsEnabled = false;

			// force default scheme so materials for compositor quads will determined correctly
			var matMgr = MaterialManager.Instance;
			var prevMaterialScheme = matMgr.ActiveScheme;
			matMgr.ActiveScheme = MaterialManager.DefaultSchemeName;

			// Set previous CompositorInstance for each compositor in the list
			var lastComposition = this.originalScene;
			this.originalScene.PreviousInstance = null;
			var pass = this.originalScene.Technique.OutputTarget.Passes[ 0 ];
			pass.ClearBuffers = this.viewport.ClearBuffers;
			pass.ClearColor = this.viewport.BackgroundColor;
			pass.ClearDepth = this.viewport.ClearDepth;

			foreach ( var instance in this.instances )
			{
				if ( instance.IsEnabled )
				{
					compositorsEnabled = true;
					instance.PreviousInstance = lastComposition;
					lastComposition = instance;
				}
			}

			// Compile misc targets
			lastComposition.CompileTargetOperations( this.compiledState );

			// Final target viewport (0)
			this.outputOperation.RenderSystemOperations.Clear();
			lastComposition.CompileOutputOperation( this.outputOperation );

			// Deal with viewport settings
			if ( compositorsEnabled != this.anyCompositorsEnabled )
			{
				this.anyCompositorsEnabled = compositorsEnabled;
				if ( this.anyCompositorsEnabled )
				{
					// Save old viewport clearing options
					this.oldClearEveryFrameBuffers = this.viewport.ClearBuffers;
					// Don't clear anything every frame since we have our own clear ops
					this.viewport.SetClearEveryFrame( false );
				}
				else
				{
					// Reset clearing options
					this.viewport.SetClearEveryFrame( this.oldClearEveryFrameBuffers > 0, this.oldClearEveryFrameBuffers );
				}
			}
			this.dirty = false;

			matMgr.ActiveScheme = prevMaterialScheme;
		}
Exemplo n.º 19
0
 private static extern void Viewport_clear5(IntPtr viewport, FrameBufferType buffers, Color color, float depth, ushort stencil);
Exemplo n.º 20
0
		/// <summary>
		/// Clears one or more frame buffers on the active render target.
		/// </summary>
		/// <param name="buffers">
		///  Combination of one or more elements of <see cref="Graphics.RenderTarget.FrameBuffer"/>
		///  denoting which buffers are to be cleared.
		/// </param>
		/// <param name="color">The color to clear the color buffer with, if enabled.</param>
		/// <param name="depth">The value to initialize the depth buffer with, if enabled.</param>
		/// <param name="stencil">The value to initialize the stencil buffer with, if enabled.</param>
		public override void ClearFrameBuffer(FrameBufferType buffers, ColorEx color, Real depth, ushort stencil)
		{
			ClearOptions flags = 0; //ClearFlags 

			if ((buffers & FrameBufferType.Color) > 0)
			{
				flags |= ClearOptions.Target;
			}
			if ((buffers & FrameBufferType.Depth) > 0)
			{
				flags |= ClearOptions.DepthBuffer;
			}
			// Only try to clear the stencil buffer if supported
			if ((buffers & FrameBufferType.Stencil) > 0
				 && Capabilities.HasCapability(Graphics.Capabilities.StencilBuffer))
			{
				flags |= ClearOptions.Stencil;
			}
			var col = XnaHelper.Convert(color);

			// clear the device using the specified params
			_device.Clear(flags, col, depth, stencil);
		}
Exemplo n.º 21
0
		public void Clear( FrameBufferType buffers, ColorEx col, Real depth, ushort stencil )
		{
			var rs = Root.Instance.RenderSystem;
			if ( rs == null )
			{
				return;
			}

			var currentvp = rs.Viewport;
			rs.Viewport = this;
			rs.ClearFrameBuffer( buffers, col, depth, stencil );
			if ( currentvp != null && currentvp != this )
			{
				rs.Viewport = currentvp;
			}
		}
Exemplo n.º 22
0
 public void setClearEveryFrame(bool clear, FrameBufferType buffers = FrameBufferType.FBT_COLOUR | FrameBufferType.FBT_DEPTH)
 {
     Viewport_setClearEveryFrame(viewport, clear, (uint)buffers);
 }
Exemplo n.º 23
0
 public void clear(FrameBufferType buffers)
 {
     Viewport_clear2(viewport, buffers);
 }
Exemplo n.º 24
0
        public override void ClearFrameBuffer( FrameBufferType buffers, ColorEx color, Real depth, ushort stencil )
        {
            ClearFlags flags = 0;

            if ( ( buffers & FrameBufferType.Color ) > 0 )
            {
                flags |= ClearFlags.Target;
            }
            if ( ( buffers & FrameBufferType.Depth ) > 0 )
            {
                flags |= ClearFlags.ZBuffer;
            }
            // Only try to clear the stencil buffer if supported
            if ( ( buffers & FrameBufferType.Stencil ) > 0
                && Capabilities.HasCapability( Graphics.Capabilities.StencilBuffer ) )
            {
                flags |= ClearFlags.Stencil;
            }

            // clear the device using the specified params
            ActiveD3D9Device.Clear(flags, color.ToARGB(), depth, stencil);
        }
Exemplo n.º 25
0
 public void clear(FrameBufferType buffers, Color color)
 {
     Viewport_clear3(viewport, buffers, color);
 }
Exemplo n.º 26
0
        ///<summary>
        ///    Compile this Composition chain into a series of RenderTarget operations.
        ///</summary>
        protected void Compile()
        {
            //remove original scen if it has the wrong material scheme
            if (this.originalSceneMaterial != this.viewport.MaterialScheme)
            {
                DestroyOriginalScene();
                CreateOriginalScene();
            }

            ClearCompiledState();

            bool compositorsEnabled = false;

            // force default scheme so materials for compositor quads will determined correctly
            var matMgr             = MaterialManager.Instance;
            var prevMaterialScheme = matMgr.ActiveScheme;

            matMgr.ActiveScheme = MaterialManager.DefaultSchemeName;

            // Set previous CompositorInstance for each compositor in the list
            var lastComposition = this.originalScene;

            this.originalScene.PreviousInstance = null;
            var pass = this.originalScene.Technique.OutputTarget.Passes[0];

            pass.ClearBuffers = this.viewport.ClearBuffers;
            pass.ClearColor   = this.viewport.BackgroundColor;
            pass.ClearDepth   = this.viewport.ClearDepth;

            foreach (var instance in this.instances)
            {
                if (instance.IsEnabled)
                {
                    compositorsEnabled        = true;
                    instance.PreviousInstance = lastComposition;
                    lastComposition           = instance;
                }
            }

            // Compile misc targets
            lastComposition.CompileTargetOperations(this.compiledState);

            // Final target viewport (0)
            this.outputOperation.RenderSystemOperations.Clear();
            lastComposition.CompileOutputOperation(this.outputOperation);

            // Deal with viewport settings
            if (compositorsEnabled != this.anyCompositorsEnabled)
            {
                this.anyCompositorsEnabled = compositorsEnabled;
                if (this.anyCompositorsEnabled)
                {
                    // Save old viewport clearing options
                    this.oldClearEveryFrameBuffers = this.viewport.ClearBuffers;
                    // Don't clear anything every frame since we have our own clear ops
                    this.viewport.SetClearEveryFrame(false);
                }
                else
                {
                    // Reset clearing options
                    this.viewport.SetClearEveryFrame(this.oldClearEveryFrameBuffers > 0, this.oldClearEveryFrameBuffers);
                }
            }
            this.dirty = false;

            matMgr.ActiveScheme = prevMaterialScheme;
        }
Exemplo n.º 27
0
 public void clear(FrameBufferType buffers, Color color, float depth)
 {
     Viewport_clear4(viewport, buffers, color, depth);
 }
Exemplo n.º 28
0
		public CompositionPass( CompositionTargetPass parent )
		{
			this.parent = parent;
			type = CompositorPassType.RenderQuad;
			identifier = 0;
			firstRenderQueue = RenderQueueGroupID.Background;
			lastRenderQueue = RenderQueueGroupID.SkiesLate;
			materialSchemeName = string.Empty;
			clearBuffers = FrameBufferType.Color | FrameBufferType.Depth;
			clearColor = new ColorEx( 0f, 0f, 0f, 0f );
			clearDepth = 1.0f;
			clearStencil = 0;
			stencilCheck = false;
			stencilFunc = CompareFunction.AlwaysPass;
			stencilRefValue = 0;
			stencilMask = 0x7FFFFFFF;
			stencilFailOp = StencilOperation.Keep;
			stencilDepthFailOp = StencilOperation.Keep;
			stencilPassOp = StencilOperation.Keep;
			stencilTwoSidedOperation = false;
			quadCornerModified = false;
			quadLeft = -1;
			quadTop = 1;
			quadRight = 1;
			quadBottom = -1;
			quadFarCorners = false;
			quadFarCornersViewSpace = false;
		}
Exemplo n.º 29
0
 public void clearFrameBuffer(FrameBufferType buffers, Color color, float depth = 1.0f, ushort stencil = 0)
 {
     RenderSystem_clearFrameBuffer(renderSystem, (uint)buffers, color, depth, stencil);
 }