示例#1
0
 public void DrawQuad(int texture, AGSBoundingBox box, float r, float g, float b, float a)
 {
     _quad[0] = new GLVertex(box.BottomLeft.Xy, _bottomLeft, r, g, b, a);
     _quad[1] = new GLVertex(box.BottomRight.Xy, _bottomRight, r, g, b, a);
     _quad[2] = new GLVertex(box.TopRight.Xy, _topRight, r, g, b, a);
     _quad[3] = new GLVertex(box.TopLeft.Xy, _topLeft, r, g, b, a);
     DrawQuad(texture, _quad);
 }
示例#2
0
 public GLUtils(IGraphicsBackend graphics, IRenderMessagePump messagePump)
 {
     _graphics               = graphics;
     _messagePump            = messagePump;
     _quad                   = new GLVertex[4];
     _line                   = new GLVertex[2];
     CurrentGlobalResolution = new SizeF();
 }
示例#3
0
        public void DrawQuad(int texture, AGSBoundingBox box, IGLColor color, FourCorners <Vector2> texturePos)
        {
            _quad[0] = new GLVertex(box.BottomLeft.Xy, texturePos.BottomLeft, color);
            _quad[1] = new GLVertex(box.BottomRight.Xy, texturePos.BottomRight, color);
            _quad[2] = new GLVertex(box.TopRight.Xy, texturePos.TopRight, color);
            _quad[3] = new GLVertex(box.TopLeft.Xy, texturePos.TopLeft, color);

            DrawQuad(texture, _quad);
        }
示例#4
0
 public GLUtils(IGraphicsBackend graphics, IRenderMessagePump messagePump, IGameState state)
 {
     _state            = state;
     _graphics         = graphics;
     _messagePump      = messagePump;
     _quad             = new GLVertex[4];
     _line             = new GLVertex[2];
     CurrentResolution = new SizeF();
 }
示例#5
0
        public void DrawQuad(int texture, Vector3 bottomLeft, Vector3 bottomRight,
                             Vector3 topLeft, Vector3 topRight, float r, float g, float b, float a)
        {
            GLVertex[] vertices = new GLVertex[] { new GLVertex(bottomLeft.Xy, _bottomLeft, r, g, b, a),
                                                   new GLVertex(bottomRight.Xy, _bottomRight, r, g, b, a), new GLVertex(topRight.Xy, _topRight, r, g, b, a),
                                                   new GLVertex(topLeft.Xy, _topLeft, r, g, b, a) };

            DrawQuad(texture, vertices);
        }
示例#6
0
        public void DrawQuad(int texture, Vector3 bottomLeft, Vector3 bottomRight,
                             Vector3 topLeft, Vector3 topRight, IGLColor color, FourCorners <Vector2> texturePos)
        {
            GLVertex[] vertices = new GLVertex[] { new GLVertex(bottomLeft.Xy, texturePos.BottomLeft, color),
                                                   new GLVertex(bottomRight.Xy, texturePos.BottomRight, color), new GLVertex(topRight.Xy, texturePos.TopRight, color),
                                                   new GLVertex(topLeft.Xy, texturePos.TopLeft, color) };

            DrawQuad(texture, vertices);
        }
示例#7
0
 public void DrawQuad(int texture, Vector3 bottomLeft, Vector3 bottomRight,
                      Vector3 topLeft, Vector3 topRight, IGLColor bottomLeftColor, IGLColor bottomRightColor,
                      IGLColor topLeftColor, IGLColor topRightColor)
 {
     _quad[0] = new GLVertex(bottomLeft.Xy, _bottomLeft, bottomLeftColor);
     _quad[1] = new GLVertex(bottomRight.Xy, _bottomRight, bottomRightColor);
     _quad[2] = new GLVertex(topRight.Xy, _topRight, topRightColor);
     _quad[3] = new GLVertex(topLeft.Xy, _topLeft, topLeftColor);
     DrawQuad(texture, _quad);
 }
示例#8
0
        public void DrawQuad(int texture, Vector3 bottomLeft, Vector3 bottomRight,
                             Vector3 topLeft, Vector3 topRight, IGLColor bottomLeftColor, IGLColor bottomRightColor,
                             IGLColor topLeftColor, IGLColor topRightColor)
        {
            GLVertex[] vertices = new GLVertex[] { new GLVertex(bottomLeft.Xy, _bottomLeft, bottomLeftColor),
                                                   new GLVertex(bottomRight.Xy, _bottomRight, bottomRightColor), new GLVertex(topRight.Xy, _topRight, topRightColor),
                                                   new GLVertex(topLeft.Xy, _topLeft, topLeftColor) };

            DrawQuad(texture, vertices);
        }
示例#9
0
        public void DrawLine(float x1, float y1, float x2, float y2,
                             float width, float r, float g, float b, float a)
        {
            int texture = getTexture(0);

            _graphics.BindTexture2D(texture);
            _graphics.LineWidth(width);
            _line[0] = new GLVertex(new Vector2(x1, y1), _bottomLeft, r, g, b, a);
            _line[1] = new GLVertex(new Vector2(x2, y2), _bottomRight, r, g, b, a);

            drawArrays(PrimitiveMode.Lines, _line);
        }
示例#10
0
 public bool DrawQuad(IFrameBuffer frameBuffer, AGSBoundingBox square, GLVertex[] vertices)
 {
     if (frameBuffer == null)
     {
         return(false);
     }
     vertices[0] = new GLVertex(square.BottomLeft.Xy, _bottomLeft, Colors.White);
     vertices[1] = new GLVertex(square.BottomRight.Xy, _bottomRight, Colors.White);
     vertices[2] = new GLVertex(square.TopRight.Xy, _topRight, Colors.White);
     vertices[3] = new GLVertex(square.TopLeft.Xy, _topLeft, Colors.White);
     DrawQuad(frameBuffer.Texture.ID, vertices);
     return(true);
 }
示例#11
0
        public void DrawCross(float x, float y, float width, float height,
                              float r, float g, float b, float a)
        {
            _quad[0] = new GLVertex(new Vector2(x - width, y - height / 10), _bottomLeft, r, g, b, a);
            _quad[1] = new GLVertex(new Vector2(x + width, y - height / 10), _bottomRight, r, g, b, a);
            _quad[2] = new GLVertex(new Vector2(x + width, y + height / 10), _topRight, r, g, b, a);
            _quad[3] = new GLVertex(new Vector2(x - width, y + height / 10), _topLeft, r, g, b, a);
            DrawQuad(0, _quad);

            _quad[0] = new GLVertex(new Vector2(x - width / 10, y - height), _bottomLeft, r, g, b, a);
            _quad[1] = new GLVertex(new Vector2(x + width / 10, y - height), _bottomRight, r, g, b, a);
            _quad[2] = new GLVertex(new Vector2(x + width / 10, y + height), _topRight, r, g, b, a);
            _quad[3] = new GLVertex(new Vector2(x - width / 10, y + height), _topLeft, r, g, b, a);
            DrawQuad(0, _quad);
        }
示例#12
0
        public void DrawCross(float x, float y, float width, float height,
                              float r, float g, float b, float a)
        {
            GLVertex[] vertices = new GLVertex[] {
                new GLVertex(new Vector2(x - width, y - height / 10), _bottomLeft, r, g, b, a),
                new GLVertex(new Vector2(x + width, y - height / 10), _bottomRight, r, g, b, a),
                new GLVertex(new Vector2(x + width, y + height / 10), _topRight, r, g, b, a),
                new GLVertex(new Vector2(x - width, y + height / 10), _topLeft, r, g, b, a)
            };
            DrawQuad(0, vertices);

            vertices = new GLVertex[] {
                new GLVertex(new Vector2(x - width / 10, y - height), _bottomLeft, r, g, b, a),
                new GLVertex(new Vector2(x + width / 10, y - height), _bottomRight, r, g, b, a),
                new GLVertex(new Vector2(x + width / 10, y + height), _topRight, r, g, b, a),
                new GLVertex(new Vector2(x - width / 10, y + height), _topLeft, r, g, b, a)
            };

            DrawQuad(0, vertices);
        }
示例#13
0
        private void drawRoundCorner(Vector3 center, float radius, float angle, AGSBoundingBox border, FourCorners <IGLColor> colors)
        {
            Vector2  tex          = new Vector2();
            GLVertex centerVertex = new GLVertex(center.Xy, tex, getColor(colors, border, center));

            _roundCorner[0] = centerVertex;
            float step = (90f / (_roundCorner.Length - 2));

            for (int i = 1; i < _roundCorner.Length; i++)
            {
                float anglerad = (float)Math.PI * angle / 180.0f;
                float x        = (float)Math.Sin(anglerad) * radius;
                float y        = (float)Math.Cos(anglerad) * radius;
                angle += step;
                Vector3 point = new Vector3(x + center.X, y + center.Y, 0f);
                _roundCorner[i] = new GLVertex(point.Xy, tex, getColor(colors, border, point));
            }

            _glUtils.DrawTriangleFan(0, _roundCorner);
        }
示例#14
0
        private void drawVertices(GLVertex[] vertices)
        {
            _graphics.BufferData(vertices, GLVertex.Size, BufferType.ArrayBuffer);
            _graphics.BufferData(_quadIndices, sizeof(short), BufferType.ElementArrayBuffer);
            _graphics.SetShaderAppVars();

            _graphics.DrawElements(PrimitiveMode.Triangles, 6, _quadIndices);
        }
示例#15
0
        public void DrawQuad(int texture, Vector3 bottomLeft, Vector3 bottomRight, 
			Vector3 topLeft, Vector3 topRight, IGLColor color, FourCorners<Vector2> texturePos)
		{
            texture = getTexture(texture);
            _graphics.BindTexture2D (texture);

			GLVertex[] vertices = new GLVertex[]{ new GLVertex(bottomLeft.Xy, texturePos.BottomLeft, color), 
				new GLVertex(bottomRight.Xy, texturePos.BottomRight, color), new GLVertex(topRight.Xy, texturePos.TopRight, color),
				new GLVertex(topLeft.Xy, texturePos.TopLeft, color)};

            drawVertices(vertices);
		}
示例#16
0
		public void DrawTriangleFan(int texture, GLVertex[] vertices)
		{
            texture = getTexture(texture);
            _graphics.BindTexture2D(texture);

            drawVertices(vertices);
		}
示例#17
0
		public void DrawCross(float x, float y, float width, float height,
			float r, float g, float b, float a)
		{
            int texture = getTexture(0);
            _graphics.BindTexture2D(texture);

			GLVertex[] vertices = new GLVertex[]{ 
				new GLVertex(new Vector2(x - width, y - height/10), _bottomLeft, r,g,b,a), 
				new GLVertex(new Vector2(x + width, y - height/10), _bottomRight, r,g,b,a), 
				new GLVertex(new Vector2(x + width, y + height/10), _topRight, r,g,b,a),
				new GLVertex(new Vector2(x - width, y + height/10), _topLeft, r,g,b,a),

				new GLVertex(new Vector2(x - width/10, y - height), _bottomLeft, r,g,b,a), 
				new GLVertex(new Vector2(x + width/10, y - height), _bottomRight, r,g,b,a), 
				new GLVertex(new Vector2(x + width/10, y + height), _topRight, r,g,b,a),
				new GLVertex(new Vector2(x - width/10, y + height), _topLeft, r,g,b,a)
			};

            drawVertices(vertices);
		}
示例#18
0
		public void DrawLine(float x1, float y1, float x2, float y2, 
			float width, float r, float g, float b, float a)
		{
            int texture = getTexture(0);
            _graphics.BindTexture2D(texture);
			_graphics.LineWidth (width);
			GLVertex[] vertices = new GLVertex[]{ new GLVertex(new Vector2(x1,y1), _bottomLeft, r,g,b,a), 
				new GLVertex(new Vector2(x2,y2), _bottomRight, r,g,b,a)};

            drawVertices(vertices);
		}
示例#19
0
		public void DrawQuad(int texture, Vector3 bottomLeft, Vector3 bottomRight, 
			Vector3 topLeft, Vector3 topRight, IGLColor bottomLeftColor, IGLColor bottomRightColor,
			IGLColor topLeftColor, IGLColor topRightColor)
		{
            texture = getTexture(texture);
            _graphics.BindTexture2D(texture);

			GLVertex[] vertices = new GLVertex[]{ new GLVertex(bottomLeft.Xy, _bottomLeft, bottomLeftColor), 
				new GLVertex(bottomRight.Xy, _bottomRight, bottomRightColor), new GLVertex(topRight.Xy, _topRight, topRightColor),
				new GLVertex(topLeft.Xy, _topLeft, topLeftColor)};

            drawVertices(vertices);
		}
示例#20
0
		private void drawRoundCorner(PointF center, float radius, float angle, ISquare border, FourCorners<IGLColor> colors)
		{
			Vector2 tex = new Vector2 ();
			GLVertex centerVertex = new GLVertex (center.ToVector2(), tex, getColor(colors, border, center));
			_roundCorner[0] = centerVertex;
			float step = (90f / (_roundCorner.Length - 2));
			for (int i = 1; i < _roundCorner.Length; i++)
			{
				float anglerad = (float)Math.PI * angle / 180.0f;
				float x = (float)Math.Sin(anglerad) * radius; 
				float y = (float)Math.Cos(anglerad) * radius;
				angle += step;
				PointF point = new PointF (x + center.X, y + center.Y);
				_roundCorner[i] = new GLVertex (point.ToVector2(), tex, getColor(colors, border, point));
			}

            _glUtils.DrawTriangleFan(0, _roundCorner);
		}
示例#21
0
		public void DrawQuad(int texture, Vector3 bottomLeft, Vector3 bottomRight, 
			Vector3 topLeft, Vector3 topRight, float r, float g, float b, float a)
		{
            texture = getTexture(texture);
            _graphics.BindTexture2D(texture);

			GLVertex[] vertices = new GLVertex[]{ new GLVertex(bottomLeft.Xy, _bottomLeft, r,g,b,a), 
				new GLVertex(bottomRight.Xy, _bottomRight, r,g,b,a), new GLVertex(topRight.Xy, _topRight, r,g,b,a),
				new GLVertex(topLeft.Xy, _topLeft, r,g,b,a)};

            drawVertices(vertices);
		}