tangled
alpha
login
or
join now
keii.dev
/
osu-framework
A game framework written with osu! in mind.
0
fork
atom
overview
issues
pulls
pipelines
Fix triangle not supporting TextureRectangle
smoogipoo
5 years ago
e1ed23fc
e83c1726
+42
-27
2 changed files
expand all
collapse all
unified
split
osu.Framework
Graphics
Shapes
Triangle.cs
osu.Framework.Tests
Visual
Sprites
TestSceneWrapModes.cs
+41
-26
osu.Framework.Tests/Visual/Sprites/TestSceneWrapModes.cs
···
1
1
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2
2
// See the LICENCE file in the repository root for full licence text.
3
3
4
4
+
using System;
5
5
+
using NUnit.Framework;
4
6
using osu.Framework.Allocation;
5
7
using osu.Framework.Graphics;
6
8
using osu.Framework.Graphics.Containers;
···
25
27
{
26
28
}
27
29
28
28
-
protected override void LoadComplete()
30
30
+
private readonly Texture[] textures = new Texture[4 * 4];
31
31
+
32
32
+
[BackgroundDependencyLoader]
33
33
+
private void load(TextureStore store)
29
34
{
30
30
-
base.LoadComplete();
35
35
+
for (int i = 0; i < 4; ++i)
36
36
+
{
37
37
+
for (int j = 0; j < 4; ++j)
38
38
+
textures[i * 4 + j] = store.Get(@"sample-texture", wrapModes[i], wrapModes[j]);
39
39
+
}
40
40
+
}
31
41
42
42
+
[Test]
43
43
+
public void TestSprites() => createTest(tex => new Sprite
44
44
+
{
45
45
+
Texture = tex,
46
46
+
TextureRectangle = new RectangleF(0.25f, 0.25f, 0.5f, 0.5f),
47
47
+
});
48
48
+
49
49
+
[Test]
50
50
+
public void TestTriangles() => createTest(tex => new EquilateralTriangle
51
51
+
{
52
52
+
Texture = tex,
53
53
+
TextureRectangle = new RectangleF(0.25f, 0.25f, 0.5f, 0.5f),
54
54
+
});
55
55
+
56
56
+
[Test, Ignore("not implemented yet")]
57
57
+
public void TestVideos() => createTest(_ => new TestVideo());
58
58
+
59
59
+
private void createTest(Func<Texture, Drawable> creatorFunc) => AddStep("create test", () =>
60
60
+
{
32
61
for (int i = 0; i < Rows; ++i)
33
62
{
34
63
for (int j = 0; j < Cols; ++j)
35
64
{
36
36
-
Cell(i, j).AddRange(new Drawable[]
65
65
+
Cell(i, j).Children = new Drawable[]
37
66
{
38
67
new SpriteText
39
68
{
···
46
75
Size = new Vector2(0.5f),
47
76
Anchor = Anchor.Centre,
48
77
Origin = Anchor.Centre,
49
49
-
Children = new Drawable[]
78
78
+
Children = new[]
50
79
{
51
51
-
new Sprite
80
80
+
creatorFunc(textures[i * 4 + j]).With(d =>
52
81
{
53
53
-
RelativeSizeAxes = Axes.Both,
54
54
-
Size = Vector2.One,
55
55
-
Texture = textures[i * 4 + j],
56
56
-
Anchor = Anchor.Centre,
57
57
-
Origin = Anchor.Centre,
58
58
-
TextureRectangle = new RectangleF(0.25f, 0.25f, 0.5f, 0.5f),
59
59
-
},
82
82
+
d.RelativeSizeAxes = Axes.Both;
83
83
+
d.Size = Vector2.One;
84
84
+
d.Anchor = Anchor.Centre;
85
85
+
d.Origin = Anchor.Centre;
86
86
+
}),
60
87
new Container
61
88
{
62
89
RelativeSizeAxes = Axes.Both,
···
74
101
}
75
102
}
76
103
}
77
77
-
});
104
104
+
};
78
105
}
79
106
}
80
80
-
}
81
81
-
82
82
-
private readonly Texture[] textures = new Texture[4 * 4];
83
83
-
84
84
-
[BackgroundDependencyLoader]
85
85
-
private void load(TextureStore store)
86
86
-
{
87
87
-
for (int i = 0; i < 4; ++i)
88
88
-
{
89
89
-
for (int j = 0; j < 4; ++j)
90
90
-
textures[i * 4 + j] = store.Get(@"sample-texture", wrapModes[i], wrapModes[j]);
91
91
-
}
92
92
-
}
107
107
+
});
93
108
}
94
109
}
+1
-1
osu.Framework/Graphics/Shapes/Triangle.cs
···
44
44
protected override void Blit(Action<TexturedVertex2D> vertexAction)
45
45
{
46
46
DrawTriangle(Texture, toTriangle(ScreenSpaceDrawQuad), DrawColourInfo.Colour, null, null,
47
47
-
new Vector2(InflationAmount.X / DrawRectangle.Width, InflationAmount.Y / DrawRectangle.Height));
47
47
+
new Vector2(InflationAmount.X / DrawRectangle.Width, InflationAmount.Y / DrawRectangle.Height), TextureCoords);
48
48
}
49
49
}
50
50
}