Exemple #1
0
        /// <summary>
        /// Merge this state with another one.
        /// </summary>
        /// <param name="state">
        /// A <see cref="IGraphicsState"/> having the same <see cref="StateIdentifier"/> of this state.
        /// </param>
        public override void Merge(IGraphicsState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            DepthTestState otherState = state as DepthTestState;

            if (otherState == null)
            {
                throw new ArgumentException("not a DepthTestState", "state");
            }

            _Function = otherState._Function;
        }
Exemple #2
0
        /// <summary>
        /// Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <param name="other">
        /// A <see cref="GraphicsState"/> to compare to this GraphicsState.
        /// </param>
        /// <returns>
        /// It returns true if the current object is equal to <paramref name="other"/>.
        /// </returns>
        /// <remarks>
        /// <para>
        /// This method test only whether <paramref name="other"/> type equals to this type.
        /// </para>
        /// </remarks>
        /// <exception cref="ArgumentNullException">
        /// This exception is thrown if the parameter <paramref name="other"/> is null.
        /// </exception>
        public override bool Equals(IGraphicsState other)
        {
            if (base.Equals(other) == false)
            {
                return(false);
            }
            Debug.Assert(other is DepthTestState);

            DepthTestState otherState = (DepthTestState)other;

            if (otherState.Function != Function)
            {
                return(false);
            }

            return(true);
        }
Exemple #3
0
        /// <summary>
        /// Apply this depth test render state.
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="GraphicsContext"/> which has defined the shader program <paramref name="program"/>.
        /// </param>
        /// <param name="program">
        /// The <see cref="ShaderProgram"/> which has the state set.
        /// </param>
        public override void ApplyState(GraphicsContext ctx, ShaderProgram program)
        {
            if (ctx == null)
            {
                throw new ArgumentNullException("ctx");
            }

            DepthTestState currentState = (DepthTestState)ctx.GetCurrentState(StateIndex);

            if (currentState != null)
            {
                ApplyStateCore(ctx, program, currentState);
            }
            else
            {
                ApplyStateCore(ctx, program);
            }

            ctx.SetCurrentState(this);
        }
Exemple #4
0
 private void ApplyStateCore(GraphicsContext ctx, ShaderProgram program, DepthTestState currentState)
 {
     if (_Enabled)
     {
         // Enable depth test
         if (currentState.Enabled == false)
         {
             Gl.Enable(EnableCap.DepthTest);
         }
         // Specify depth function
         if (currentState.Function != Function)
         {
             Gl.DepthFunc(Function);
         }
     }
     else
     {
         // Disable depth test
         if (currentState != null && currentState.Enabled == true)
         {
             Gl.Disable(EnableCap.DepthTest);
         }
     }
 }