Skip to content

Commit 1963b2b

Browse files
refactor: timeline
1 parent 029cb93 commit 1963b2b

8 files changed

Lines changed: 629 additions & 852 deletions

File tree

FreeFrame/Camera.cs

Lines changed: 0 additions & 119 deletions
This file was deleted.

FreeFrame/Components/Shapes/Shape.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,28 @@ public Shape()
4343
Id = Guid.NewGuid();
4444
}
4545

46-
public virtual void Draw(Vector2i clientSize, Camera camera)
46+
public virtual void Draw(Vector2i clientSize)
4747
{
4848
//Console.WriteLine("Draw {0}, {1}, {2}", GetType().Name, Id, GetHashCode());
4949
foreach (Renderer vao in Vaos)
50-
vao.Draw(clientSize, camera, Color, this);
50+
vao.Draw(clientSize, Color, this);
5151
}
5252
public void DeleteObjects()
5353
{
5454
foreach (Renderer vao in Vaos)
5555
vao.DeleteObjects();
5656
Vaos.Clear();
5757
}
58-
public Shape Clone() => (Shape)MemberwiseClone();
58+
public Shape ShallowCopy() => (Shape)MemberwiseClone();
59+
public Shape DeepCopy()
60+
{
61+
Shape shape = (Shape)MemberwiseClone();
62+
shape.Id = Guid.NewGuid();
63+
shape.DeleteObjects();
64+
shape.Vaos = new List<Renderer>();
65+
shape.ImplementObject();
66+
return shape;
67+
}
5968

6069

6170
/// <summary>
@@ -86,6 +95,7 @@ public static string ColorToHexadecimal(Color4 color)
8695
a = (int)(color.A * 255);
8796
return '#' + r.ToString("X2") + g.ToString("X2") + b.ToString("X2") + a.ToString("X2");
8897
}
98+
8999
}
90100

91101
}

FreeFrame/IDrawable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ List<Renderer> Vaos
1616
/// <summary>
1717
/// Trigge draw element through OpenGL context
1818
/// </summary>
19-
public void Draw(Vector2i clientSize, Camera camera);
19+
public void Draw(Vector2i clientSize);
2020
public void DeleteObjects();
2121
}
2222
}

FreeFrame/Renderer.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public Renderer(float[] vertices, uint[] indexes, PrimitiveType primitiveType, S
4747
_shader = new Shader("Shaders/shader.vert", "Shaders/rectangle.frag");
4848
ImplementObjects(vertices, indexes);
4949
}
50-
public void Draw(Vector2i clientSize, Camera camera, Color4 color, Matrix4 transformation)
50+
public void Draw(Vector2i clientSize, Color4 color, Matrix4 transformation)
5151
{
5252
_shader.Use();
5353

@@ -66,17 +66,11 @@ public void Draw(Vector2i clientSize, Camera camera, Color4 color, Matrix4 trans
6666
int uTransformation = _shader.GetUniformLocation("u_Transformation");
6767
_shader.SetUniformMat4(uTransformation, transformation);
6868

69-
int uView = _shader.GetUniformLocation("u_View");
70-
_shader.SetUniformMat4(uView, camera.GetViewMatrix());
71-
72-
int uProjection = _shader.GetUniformLocation("u_Projection");
73-
_shader.SetUniformMat4(uProjection, camera.GetViewMatrix());
74-
7569
GL.BindVertexArray(VertexArrayObjectID);
7670

7771
GL.DrawElements(_primitiveType, _indexCount, DrawElementsType.UnsignedInt, 0);
7872
}
79-
public void Draw(Vector2i clientSize, Camera camera, Color4 color, Shape shape)
73+
public void Draw(Vector2i clientSize, Color4 color, Shape shape)
8074
{
8175
_shader.Use();
8276
// Applied projection matrix
@@ -95,12 +89,6 @@ public void Draw(Vector2i clientSize, Camera camera, Color4 color, Shape shape)
9589
Matrix4 rotation = Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(shape.Angle));
9690
_shader.SetUniformMat4(uTransformation, rotation);
9791

98-
int uView = _shader.GetUniformLocation("u_View");
99-
_shader.SetUniformMat4(uView, camera.GetViewMatrix());
100-
101-
int uProjection = _shader.GetUniformLocation("u_Projection");
102-
_shader.SetUniformMat4(uProjection, camera.GetViewMatrix());
103-
10492
int uRadius = _shader.GetUniformLocation("u_Radius");
10593
_shader.SetUniformFloat(uRadius, shape.CornerRadius);
10694

FreeFrame/Selector.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void Select(Shape shape)
8383
_vaos.Add((new Renderer(hitbox.ToFloatArray(), new uint[] { 0, 1, 2, 0, 2, 3 }, PrimitiveType.Triangles), hitbox, SelectorType.Resize));
8484
}
8585

86-
public void Draw(Vector2i clientSize, Camera camera)
86+
public void Draw(Vector2i clientSize)
8787
{
8888
GL.Enable(EnableCap.LineSmooth);
8989
GL.LineWidth(3.0f);
@@ -95,9 +95,9 @@ public void Draw(Vector2i clientSize, Camera camera)
9595
foreach ((Renderer vao, Area _, SelectorType type) part in _vaos)
9696
{
9797
if (part.type == SelectorType.Edge)
98-
part.vao.Draw(clientSize, camera, new Color4(0, 125, 200, 255), transformation);
98+
part.vao.Draw(clientSize, new Color4(0, 125, 200, 255), transformation);
9999
else
100-
part.vao.Draw(clientSize, camera, new Color4(0, 125, 255, 255), transformation);
100+
part.vao.Draw(clientSize, new Color4(0, 125, 255, 255), transformation);
101101
}
102102

103103
GL.Disable(EnableCap.LineSmooth);

FreeFrame/Shaders/shader.vert

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ layout(location = 0) in vec2 position;
44

55
uniform mat4 u_Model_To_NDC;
66
uniform mat4 u_Transformation;
7-
uniform mat4 u_View;
8-
uniform mat4 u_Projection;
97

108
uniform vec2 u_Resolution;
119
uniform vec2 u_Position;

0 commit comments

Comments
 (0)