示例#1
0
        void LineDraw(DrawState drawstate)
        {
            if (drawstate == null) throw new ArgumentNullException("drawstate");
            if (drawstate.Mode != DrawMode.Lines) throw new ArgumentException("Incorrect drawstate");

            m_effect.CurrentTechnique = (UseOldShader == true) ? m_effect.Techniques["DrawOLD"] : m_effect.Techniques["Draw"];

            SetShaderParameters(drawstate.ShaderParameters, drawstate.Pixels, drawstate.Palette);

            Int32 count = 0;
            Boolean point = false;
            foreach (DrawData data in drawstate)
            {
                if (point == false)
                {
                    point = true;

                    m_drawbuffer[count * 2 + 0] = new Vertex(data.Location + CameraShift, Vector2.Zero, data.Tint);
                }
                else
                {
                    point = false;

                    m_drawbuffer[count * 2 + 1] = new Vertex(data.Location + CameraShift, Vector2.Zero, data.Tint);
                    ++count;
                }
            }

            if (count > 0) FinishDrawing(PrimitiveType.LineList, count);
        }
示例#2
0
 static void SetTextureCoords(Vertex[] buffer, Int32 offset, SpriteEffects flip)
 {
     SetTextureCoords(buffer, offset, new Point(1, 1), new Rectangle(0, 0, 1, 1), flip);
 }
示例#3
0
        static void SetPosition(Vertex[] buffer, Int32 offset, FRect r, Single rotation, Vector2 axis)
        {
            Vector2 v1 = RotatePoint(new Vector2(r.Left, r.Top), rotation, axis);
            Vector2 v2 = RotatePoint(new Vector2(r.Right, r.Bottom), rotation, axis);

            buffer[offset + 0].Position = new Vector2(v1.X, v1.Y);
            buffer[offset + 1].Position = new Vector2(v2.X, v1.Y);
            buffer[offset + 2].Position = new Vector2(v2.X, v2.Y);

            buffer[offset + 3].Position = new Vector2(v1.X, v1.Y);
            buffer[offset + 4].Position = new Vector2(v2.X, v2.Y);
            buffer[offset + 5].Position = new Vector2(v1.X, v2.Y);
        }
示例#4
0
        static void SetTextureCoords(Vertex[] buffer, Int32 offset, Point textsize, Rectangle textrect, SpriteEffects flip)
        {
            Single x1 = (Single)textrect.Left / (Single)textsize.X;
            Single x2 = (Single)textrect.Right / (Single)textsize.X;
            Single y1 = (Single)textrect.Top / (Single)textsize.Y;
            Single y2 = (Single)textrect.Bottom / (Single)textsize.Y;

            if ((flip & SpriteEffects.FlipHorizontally) == SpriteEffects.FlipHorizontally)
            {
                Single temp = x1;
                x1 = x2;
                x2 = temp;
            }

            if ((flip & SpriteEffects.FlipVertically) == SpriteEffects.FlipVertically)
            {
                Single temp = y1;
                y1 = y2;
                y2 = temp;
            }

            buffer[offset + 0].TextureCoordinate = new Vector2(x1, y1);
            buffer[offset + 1].TextureCoordinate = new Vector2(x2, y1);
            buffer[offset + 2].TextureCoordinate = new Vector2(x2, y2);

            buffer[offset + 3].TextureCoordinate = new Vector2(x1, y1);
            buffer[offset + 4].TextureCoordinate = new Vector2(x2, y2);
            buffer[offset + 5].TextureCoordinate = new Vector2(x1, y2);
        }
示例#5
0
        static void SetColor(Vertex[] buffer, Int32 offset, Color c)
        {
            buffer[offset + 0].Tint = c;
            buffer[offset + 1].Tint = c;
            buffer[offset + 2].Tint = c;

            buffer[offset + 3].Tint = c;
            buffer[offset + 4].Tint = c;
            buffer[offset + 5].Tint = c;
        }