public void DrawRectangle( float x, float y, float width, float height, ITexture texture, PackedLinearColorA color, SamplerType2d samplerType = SamplerType2d.CLAMP ) { // Generate the vertex data Span <Vertex2d> vertices = stackalloc Vertex2d[4]; // Upper Left vertices[0].pos = new Vector4(x, y, 0.5f, 1); vertices[0].uv = new Vector2(0, 0); vertices[0].diffuse = color; // Upper Right vertices[1].pos = new Vector4(x + width, y, 0.5f, 1); vertices[1].uv = new Vector2(1, 0); vertices[1].diffuse = color; // Lower Right vertices[2].pos = new Vector4(x + width, y + height, 0.5f, 1); vertices[2].uv = new Vector2(1, 1); vertices[2].diffuse = color; // Lower Left vertices[3].pos = new Vector4(x, y + height, 0.5f, 1); vertices[3].uv = new Vector2(0, 1); vertices[3].diffuse = color; DrawRectangle(vertices, texture, null, samplerType); }
public void DrawRectangle( Rectangle rectangle, ITexture texture, PackedLinearColorA color, SamplerType2d samplerType = SamplerType2d.CLAMP ) { DrawRectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, texture, color, samplerType); }
public void DrawRectangle(Span <Vertex2d> corners, ITexture texture, ITexture mask = null, SamplerType2d samplerType = SamplerType2d.CLAMP, bool blending = true) { var samplerState = getSamplerState(samplerType); if (texture != null && mask != null) { Trace.Assert(blending); _device.SetMaterial(texturedWithMaskMaterial); _device.SetSamplerState(0, samplerState); _device.SetSamplerState(1, samplerState); _device.SetTexture(0, texture); _device.SetTexture(1, mask); } else if (texture != null) { if (blending) { _device.SetMaterial(texturedMaterial); } else { _device.SetMaterial(texturedWithoutBlendingMaterial); } _device.SetSamplerState(0, samplerState); _device.SetTexture(0, texture); } else { _device.SetMaterial(untexturedMaterial); } DrawRectangle(corners); if (texture != null) { _device.SetTexture(0, Textures.InvalidTexture); } if (mask != null) { _device.SetTexture(1, Textures.InvalidTexture); } }