private void ApplyStateCore(GraphicsContext ctx, ShaderProgram program, ViewportState currentState) { if (_Viewport[0] != currentState._Viewport[0] || _Viewport[1] != currentState._Viewport[1] || _Viewport[2] != currentState._Viewport[2] || _Viewport[3] != currentState._Viewport[3]) { Gl.Viewport(_Viewport[0], _Viewport[1], _Viewport[2], _Viewport[3]); } }
/// <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 ViewportState); ViewportState otherState = (ViewportState)other; return(true); }
/// <summary> /// Set ShaderProgram 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 Apply(GraphicsContext ctx, ShaderProgram program) { if (ctx == null) { throw new ArgumentNullException("ctx"); } ViewportState currentState = (ViewportState)ctx.GetCurrentState(StateIndex); if (currentState != null) { ApplyStateCore(ctx, program, currentState); } else { ApplyStateCore(ctx, program); } ctx.SetCurrentState(this); }