public void RenderQuad(ref Vector2 position, ref Vector2 size, ref Vector2 texCoords, Texture texture) { if (_currentVertex + 4 >= _vertices.Length) Flush(); int index = _currentVertex; _vertices[index].Position.X = position.X; _vertices[index].Position.Y = position.Y; _vertices[++index].Position.X = position.X + size.X; _vertices[index].Position.Y = position.Y; _vertices[index].TextureCoordinate.X = texCoords.X; _vertices[++index].Position.X = position.X; _vertices[index].Position.Y = position.Y + size.Y; _vertices[index].TextureCoordinate.Y = texCoords.Y; _vertices[++index].Position.X = position.X + size.X; _vertices[index].Position.Y = position.Y + size.Y; _vertices[index].TextureCoordinate.X = texCoords.X; _vertices[index].TextureCoordinate.Y = texCoords.Y; int previousIndex = _textures.Count - 1; TextureBatch batch; if (_textures.Count > 0 && (batch = _textures[previousIndex]).Texture == texture && batch.VertexCount < _maxBatches) { batch.VertexCount += 4; } else { batch = new TextureBatch() { BaseVertex = _currentVertex, Texture = texture }; _textures.Add(batch); } _currentVertex = ++index; }
public void RenderQuad(ref Vector2 tl, ref Vector2 tr, ref Vector2 bl, ref Vector2 br, Texture texture) { if (_currentVertex + 4 >= _vertices.Length) Flush(); int index = _currentVertex; _vertices[index].Position.X = tl.X; _vertices[index++].Position.Y = tl.Y; _vertices[index].Position.X = tr.X; _vertices[index++].Position.Y = tr.Y; _vertices[index].Position.X = bl.X; _vertices[index++].Position.Y = bl.Y; _vertices[index].Position.X = br.X; _vertices[index++].Position.Y = br.Y; int previousIndex = _textures.Count - 1; TextureBatch batch; if (_textures.Count > 0 && (batch = _textures[previousIndex]).Texture == texture && batch.VertexCount < _maxBatches) { batch.VertexCount += 4; } else { batch = new TextureBatch() { BaseVertex = _currentVertex, Texture = texture }; _textures.Add(batch); } _currentVertex = index; }