idTech4.UI.idDeviceContext.DrawMaterial C# (CSharp) Method

DrawMaterial() public method

public DrawMaterial ( float x, float y, float width, float height, idMaterial material, Vector4 color, float scaleX = 1.0f, float scaleY = 1.0f ) : void
x float
y float
width float
height float
material idTech4.Renderer.idMaterial
color Vector4
scaleX float
scaleY float
return void
		public void DrawMaterial(float x, float y, float width, float height, idMaterial material, Vector4 color, float scaleX = 1.0f, float scaleY = 1.0f)
		{
			idE.RenderSystem.Color = color;

			float s0, s1, t0, t1;

			// 
			//  handle negative scales as well	
			if(scaleX < 0)
			{
				width *= -1;
				scaleX *= -1;
			}

			if(scaleY < 0)
			{
				height *= -1;
				scaleY *= -1;
			}

			// 
			if(width < 0)
			{
				// flip about vertical
				width = -width;
				s0 = 1 * scaleX;
				s1 = 0;
			}
			else
			{
				s0 = 0;
				s1 = 1 * scaleX;
			}

			if(height < 0)
			{
				// flip about horizontal
				height = -height;
				t0 = 1 * scaleY;
				t1 = 0;
			}
			else
			{
				t0 = 0;
				t1 = 1 * scaleY;
			}

			if(ClipCoordinates(ref x, ref y, ref width, ref height, ref s0, ref t0, ref s1, ref t1) == true)
			{
				return;
			}

			AdjustCoordinates(ref x, ref y, ref width, ref height);
			DrawStretchPicture(x, y, width, height, s0, t0, s1, t1, material);
		}

Usage Example

示例#1
0
        private void DrawBackground(idRectangle drawRect)
        {
            if (_backColor.W > 0)
            {
                _context.DrawFilledRectangle(_drawRect.X, _drawRect.Y, _drawRect.Width, _drawRect.Height, _backColor);
            }

            if (_background != null)
            {
                if (_materialColor.W > 0)
                {
                    float scaleX, scaleY;

                    if ((_flags & WindowFlags.NaturalMaterial) == WindowFlags.NaturalMaterial)
                    {
                        scaleX = _drawRect.Width / _background.ImageWidth;
                        scaleY = _drawRect.Height / _background.ImageHeight;
                    }
                    else
                    {
                        scaleX = _materialScaleX;
                        scaleY = _materialScaleY;
                    }

                    _context.DrawMaterial(_drawRect.X, _drawRect.Y, _drawRect.Width, _drawRect.Height, _background, _materialColor, scaleX, scaleY);
                }
            }
        }