示例#1
0
        /// <summary>
        /// Clears the current viewport to `color`.
        /// </summary>
        public void Clear(Color c)
        {
            _drawBuffer.Clear();
            _drawOp = new DrawOp();

            if (Device.RasterizerState.ScissorTestEnable)
            {
                Rectangle sr = Device.ScissorRectangle;
                float     x  = sr.X;
                float     y  = sr.Y;
                float     w  = sr.Width;
                float     h  = sr.Height;

                unsafe
                {
                    var ptr = AddDrawOp((int)PrimType.Quad, 1, null, _defaultEffect, BlendMode.Opaque);

                    ptr[0].Transform(x + 0, y + 0, c);
                    ptr[1].Transform(x + w, y + 0, c);
                    ptr[2].Transform(x + w, y + h, c);
                    ptr[3].Transform(x + 0, y + h, c);
                }
            }
            else
            {
                Device.Clear(c);
            }
        }
示例#2
0
        internal unsafe MojoVertex *AddDrawOp(int primType, int primCount, Image img, Effect effect, BlendMode blendMode)
        {
            if (_drawBuffer.Size + primCount * (int)primType > Global.MAX_VERTS)
            {
                Flush();
            }

            if (blendMode == BlendMode.None)
            {
                BlendMode = _blendMode;
            }

            if (img != _drawOp.Image || effect != _drawOp.Effect || primType != _drawOp.PrimType || blendMode != _drawOp.BlendMode)
            {
                _drawOp            = _drawBuffer.AddDrawOp();
                _drawOp.Image      = img;
                _drawOp.Effect     = effect;
                _drawOp.PrimType   = primType;
                _drawOp.BlendMode  = blendMode;
                _drawOp.PrimCount  = primCount;
                _drawOp.PrimOffset = _drawBuffer.Size;
            }
            else
            {
                _drawOp.PrimCount += primCount;
            }

            return(_drawBuffer.AddVertices(primType * primCount));
        }
示例#3
0
        public DrawOp AddDrawOp()
        {
            var op = new DrawOp();

            DrawOps.Add(op);
            return(op);
        }
示例#4
0
        public void Flush()
        {
            if (_drawBuffer.DrawOps.Count == 0)
            {
                return;
            }

            if (_lighting)
            {
                if (NormalmapEnabled && SpecularEnabled)
                {
                    Device.SetRenderTargets(_gBufferDiffuseNormalSpecular);
                }
                else if (NormalmapEnabled)
                {
                    Device.SetRenderTargets(_gBufferDiffuseNormal);
                }
                else
                {
                    Device.SetRenderTargets(_gBufferDiffuse);
                }

                RenderDrawOps();

                // back to default rendertarget
                //
                Device.SetRenderTarget(RenderTarget);
            }
            else
            {
                RenderDrawOps();
            }

            _drawBuffer.Clear();
            _drawOp = new DrawOp();
        }
示例#5
0
 public void ClearBuffer()
 {
     _drawBuffer.Clear();
     _drawOp = new DrawOp();
 }