A game framework written with osu! in mind.
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge remote-tracking branch 'origin/master' into glwrapper-depthinfo

# Conflicts:
# osu.Framework/Graphics/OpenGL/GLWrapper.cs

+101 -28
+19 -3
osu.Framework/Graphics/Colour/ColourInfo.cs
··· 190 190 get 191 191 { 192 192 float max = TopLeft.Linear.A; 193 - if (TopRight.Linear.A < max) max = TopRight.Linear.A; 194 - if (BottomLeft.Linear.A < max) max = BottomLeft.Linear.A; 195 - if (BottomRight.Linear.A < max) max = BottomRight.Linear.A; 193 + if (TopRight.Linear.A > max) max = TopRight.Linear.A; 194 + if (BottomLeft.Linear.A > max) max = BottomLeft.Linear.A; 195 + if (BottomRight.Linear.A > max) max = BottomRight.Linear.A; 196 196 197 197 return max; 198 + } 199 + } 200 + 201 + /// <summary> 202 + /// The minimum alpha value of all four corners. 203 + /// </summary> 204 + public float MinAlpha 205 + { 206 + get 207 + { 208 + float min = TopLeft.Linear.A; 209 + if (TopRight.Linear.A < min) min = TopRight.Linear.A; 210 + if (BottomLeft.Linear.A < min) min = BottomLeft.Linear.A; 211 + if (BottomRight.Linear.A < min) min = BottomRight.Linear.A; 212 + 213 + return min; 198 214 } 199 215 } 200 216
+1 -1
osu.Framework/Graphics/Containers/BufferedContainerDrawNode.cs
··· 153 153 // We can do this by adding a translation component to our (orthogonal) projection matrix. 154 154 GLWrapper.PushOrtho(ScreenSpaceDrawRectangle); 155 155 156 - GLWrapper.ClearColour(BackgroundColour); 156 + GLWrapper.Clear(new ClearInfo(BackgroundColour)); 157 157 base.Draw(vertexAction); 158 158 159 159 GLWrapper.PopOrtho();
+40
osu.Framework/Graphics/OpenGL/ClearInfo.cs
··· 1 + // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2 + // See the LICENCE file in the repository root for full licence text. 3 + 4 + using osuTK.Graphics; 5 + 6 + namespace osu.Framework.Graphics.OpenGL 7 + { 8 + /// <summary> 9 + /// Information for how the current frame buffer should be cleared. 10 + /// </summary> 11 + public readonly struct ClearInfo 12 + { 13 + /// <summary> 14 + /// The default clear properties, as defined by OpenGL. 15 + /// </summary> 16 + public static ClearInfo Default => new ClearInfo(default); 17 + 18 + /// <summary> 19 + /// The colour to write to the frame buffer. 20 + /// </summary> 21 + public readonly Color4 Colour; 22 + 23 + /// <summary> 24 + /// The depth to write to the frame buffer. 25 + /// </summary> 26 + public readonly double Depth; 27 + 28 + /// <summary> 29 + /// The stencil value to write to the frame buffer. 30 + /// </summary> 31 + public readonly int Stencil; 32 + 33 + public ClearInfo(Color4 colour = default, double depth = 1f, int stencil = 0) 34 + { 35 + Colour = colour; 36 + Depth = depth; 37 + Stencil = stencil; 38 + } 39 + } 40 + }
+14 -6
osu.Framework/Graphics/OpenGL/GLWrapper.cs
··· 136 136 }, true); 137 137 138 138 PushDepthInfo(new DepthInfo(false)); 139 + Clear(ClearInfo.Default); 139 140 } 140 141 141 - // We initialize to an invalid value such that we are not missing an initial GL.ClearColor call. 142 - private static Color4 clearColour = new Color4(-1, -1, -1, -1); 142 + private static ClearInfo currentClearInfo; 143 143 144 - public static void ClearColour(Color4 c) 144 + public static void Clear(ClearInfo clearInfo) 145 145 { 146 - if (clearColour != c) 146 + if (clearInfo.Colour != currentClearInfo.Colour) 147 + GL.ClearColor(clearInfo.Colour); 148 + 149 + if (clearInfo.Depth != currentClearInfo.Depth) 147 150 { 148 - clearColour = c; 149 - GL.ClearColor(clearColour); 151 + // Todo: Wtf. osuTK's bindings are broken for glClearDepthf(). Using glClearDepth() for now 152 + osuTK.Graphics.OpenGL.GL.ClearDepth(clearInfo.Depth); 150 153 } 151 154 155 + if (clearInfo.Stencil != currentClearInfo.Stencil) 156 + GL.ClearStencil(clearInfo.Stencil); 157 + 152 158 GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); 159 + 160 + currentClearInfo = clearInfo; 153 161 } 154 162 155 163 /// <summary>
+2 -2
osu.Framework/Platform/GameHost.cs
··· 305 305 setVSyncMode(); 306 306 307 307 GLWrapper.Reset(new Vector2(Window.ClientSize.Width, Window.ClientSize.Height)); 308 - GLWrapper.ClearColour(Color4.Black); 308 + GLWrapper.Clear(ClearInfo.Default); 309 309 } 310 310 311 311 private long lastDrawFrameId; ··· 329 329 using (drawMonitor.BeginCollecting(PerformanceCollectionType.GLReset)) 330 330 { 331 331 GLWrapper.Reset(new Vector2(Window.ClientSize.Width, Window.ClientSize.Height)); 332 - GLWrapper.ClearColour(Color4.Black); 332 + GLWrapper.Clear(ClearInfo.Default); 333 333 } 334 334 335 335 buffer.Object.Draw(null);
+1 -1
osu.Framework/Testing/Drawables/TestCaseButton.cs
··· 80 80 : this() 81 81 { 82 82 TestType = test; 83 - text.AddText(test.Name.Replace("TestCase", "")); 83 + text.AddText(TestCase.RemovePrefix(test.Name)); 84 84 85 85 var description = test.GetCustomAttribute<DescriptionAttribute>()?.Description; 86 86 if (description != null)
+6 -2
osu.Framework/Testing/Drawables/TestCaseButtonGroup.cs
··· 63 63 bool hasHeader = tests.Length > 1; 64 64 65 65 if (hasHeader) 66 - buttonFlow.Add(headerButton = new TestCaseHeaderButton(group.Name.Replace("TestCase", "")) 66 + buttonFlow.Add(headerButton = new TestCaseHeaderButton(group.Name) 67 67 { 68 68 Action = ToggleVisibility 69 69 }); ··· 81 81 82 82 protected override void PopIn() => buttonFlow.ForEach(b => b.Collapsed = false); 83 83 84 - protected override void PopOut() => buttonFlow.ForEach(b => b.Collapsed = true); 84 + protected override void PopOut() 85 + { 86 + if (headerButton != null) 87 + buttonFlow.ForEach(b => b.Collapsed = true); 88 + } 85 89 } 86 90 }
+1 -1
osu.Framework/Testing/DynamicClassCompiler.cs
··· 97 97 // add ourselves as a required type. 98 98 reqTypes.Add(checkpointName); 99 99 // if we are a TestCase, add the class we are testing automatically. 100 - reqTypes.Add(checkpointName.Replace("TestCase", "")); 100 + reqTypes.Add(TestCase.RemovePrefix(checkpointName)); 101 101 102 102 if (!reqTypes.Contains(Path.GetFileNameWithoutExtension(e.Name))) 103 103 return;
+9 -3
osu.Framework/Testing/TestBrowser.cs
··· 79 79 private void updateList(ValueChangedEvent<Assembly> args) 80 80 { 81 81 leftFlowContainer.Clear(); 82 + 82 83 //Add buttons for each TestCase. 83 84 string namespacePrefix = TestTypes.Select(t => t.Namespace).GetCommonPrefix(); 84 85 ··· 87 88 t => 88 89 { 89 90 string group = t.Namespace?.Substring(namespacePrefix.Length).TrimStart('.'); 90 - return string.IsNullOrWhiteSpace(group) ? t.Name : group; 91 + return string.IsNullOrWhiteSpace(group) ? TestCase.RemovePrefix(t.Name) : group; 91 92 }, 92 93 t => t, 93 94 (group, types) => new TestGroup { Name = group, TestTypes = types.ToArray() } 94 - ).Select(t => new TestCaseButtonGroup(type => LoadTest(type), t))); 95 + ).OrderBy(g => g.Name) 96 + .Select(t => new TestCaseButtonGroup(type => LoadTest(type), t))); 95 97 } 96 98 97 99 internal readonly BindableDouble PlaybackRate = new BindableDouble(1) { MinValue = 0, MaxValue = 2 }; ··· 493 495 if (!interactive || RunAllSteps.Value) 494 496 return false; 495 497 498 + if (actualStepCount > 0) 499 + // stop once one actual step has been run. 500 + return true; 501 + 496 502 if (!(s is SetUpStep) && !(s is LabelStep)) 497 503 actualStepCount++; 498 504 499 - return actualStepCount > 1; 505 + return false; 500 506 }); 501 507 } 502 508
+8 -9
osu.Framework/Testing/TestCase.cs
··· 130 130 } 131 131 132 132 /// <summary> 133 - /// Most derived usages of this start with TestCase. This will be removed for display purposes. 134 - /// </summary> 135 - private const string prefix = "TestCase"; 136 - 137 - /// <summary> 138 133 /// Tests any steps and assertions in the constructor of this <see cref="TestCase"/>. 139 134 /// This test must run before any other tests, as it relies on <see cref="StepsContainer"/> not being cleared and not having any elements. 140 135 /// </summary> ··· 145 140 146 141 protected TestCase() 147 142 { 148 - Name = GetType().ReadableName(); 149 - 150 - // Skip the "TestCase" prefix 151 - if (Name.StartsWith(prefix)) Name = Name.Replace(prefix, string.Empty); 143 + Name = RemovePrefix(GetType().ReadableName()); 152 144 153 145 RelativeSizeAxes = Axes.Both; 154 146 Masking = true; ··· 383 375 foreach (var method in GetType().GetMethods().Where(m => m.GetCustomAttributes(typeof(SetUpStepsAttribute), false).Length > 0)) 384 376 method.Invoke(this, null); 385 377 } 378 + 379 + /// <summary> 380 + /// Remove the "TestCase" prefix from a name. 381 + /// </summary> 382 + /// <param name="name"></param> 383 + /// <returns></returns> 384 + public static string RemovePrefix(string name) => name.Replace(nameof(TestCase), string.Empty); 386 385 } 387 386 }