Ejemplo n.º 1
0
 /// <summary>
 /// Pushes an effect on the stack that will cause all rendering not the specified region defined by a rectangle to be
 /// ignored. The rectangle is in the current coordinate space of the context.
 /// </summary>
 public void PushClip(Rectangle Clip)
 {
     if (this._TopTranslate != null)
     {
         Clip.Location += this._TopTranslate.Offset;
     }
     if (this._TopClip == null)
     {
         GL.Enable(EnableCap.ScissorTest);
     }
     else
     {
         Clip = Rectangle.Intersection(Clip, this._TopClip.Rectangle);
     }
     _ClipEffect ce = new _ClipEffect()
     {
         Previous = this._TopClip,
         Rectangle = Clip
     };
     ce.Apply(this._ViewSize.Y);
     this._Effects.Push(this._TopClip = ce);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Undoes the most recent command/effect given to the context.
        /// </summary>
        public void Pop()
        {
            _Effect e = this._Effects.Pop();

            // Remove clip effect
            _ClipEffect ce = e as _ClipEffect;
            if (ce != null)
            {
                this._TopClip = ce.Previous;
                if (this._TopClip == null)
                {
                    GL.Disable(EnableCap.ScissorTest);
                }
                else
                {
                    this._TopClip.Apply(this._ViewSize.Y);
                }
            }

            // Remove translate effect
            _TranslateEffect te = e as _TranslateEffect;
            if (te != null)
            {
                this._TopTranslate = te.Previous;
                if (this._TopTranslate != null)
                {
                    Point noffset = this._TopTranslate.Offset - te.Offset;
                    GL.Translate(noffset.X, noffset.Y, 0.0);
                }
                else
                {
                    GL.Translate(-te.Offset.X, -te.Offset.Y, 0.0);
                }
            }
        }