2020-02-20 21:04:59 +00:00
|
|
|
using RecrownedGTK.Types;
|
|
|
|
using OpenTK.Graphics;
|
2020-02-22 05:01:16 +00:00
|
|
|
using System;
|
2020-02-20 21:33:45 +00:00
|
|
|
namespace RecrownedGTK.Graphics.Render {
|
2020-02-20 21:04:59 +00:00
|
|
|
public class RectTexture : Rectangle, IDrawable {
|
2020-02-20 23:07:17 +00:00
|
|
|
private uint[] indices;
|
2020-02-20 21:04:59 +00:00
|
|
|
private VertexInformation[] vertices;
|
|
|
|
private TextureData textureData;
|
|
|
|
public Color4 Color {
|
|
|
|
get {
|
|
|
|
return vertices[0].color;
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
for (int vert = 0; vert < vertices.Length; vert++) {
|
|
|
|
vertices[vert].color = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public override float Width {
|
|
|
|
get {
|
|
|
|
return vertices[1].coords.X - vertices[0].coords.X;
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
vertices[1].coords.X = vertices[0].coords.X + value;
|
|
|
|
vertices[2].coords.X = vertices[3].coords.X + value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public override float Height {
|
|
|
|
set {
|
|
|
|
vertices[3].coords.Y = vertices[0].coords.Y + value;
|
|
|
|
vertices[2].coords.Y = vertices[1].coords.Y + value;
|
|
|
|
}
|
|
|
|
|
|
|
|
get {
|
|
|
|
return vertices[3].coords.Y - vertices[0].coords.Y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public override float X {
|
|
|
|
set {
|
|
|
|
float width = Width;
|
|
|
|
vertices[0].coords.X = value;
|
|
|
|
Width = width;
|
|
|
|
}
|
|
|
|
get {
|
|
|
|
return vertices[0].coords.X;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public override float Y {
|
|
|
|
set {
|
|
|
|
float height = Height;
|
|
|
|
vertices[0].coords.Y = value;
|
|
|
|
Height = height;
|
|
|
|
}
|
|
|
|
get {
|
|
|
|
return vertices[0].coords.Y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public RectTexture(TextureData textureData) {
|
2020-02-22 05:01:16 +00:00
|
|
|
this.textureData = textureData ?? throw new ArgumentNullException("Texture data can't be Null.");
|
2020-02-20 21:04:59 +00:00
|
|
|
this.textureData = textureData;
|
2020-02-20 23:07:17 +00:00
|
|
|
vertices = new VertexInformation[4];
|
|
|
|
indices = new uint[] {0, 1, 3,
|
|
|
|
1, 2, 3};
|
2020-02-20 21:04:59 +00:00
|
|
|
}
|
2020-02-20 23:07:17 +00:00
|
|
|
public void Draw(out VertexInformation[] vertices, out uint[] indices, out TextureData textureData) {
|
|
|
|
indices = this.indices;
|
2020-02-20 21:04:59 +00:00
|
|
|
vertices = this.vertices;
|
|
|
|
textureData = this.textureData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|