A game framework written with osu! in mind.
0
fork

Configure Feed

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

Add ability to clear Depth and Stencil

+58 -9
+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 + }
+15 -6
osu.Framework/Graphics/OpenGL/GLWrapper.cs
··· 134 134 BlendRange = 1, 135 135 AlphaExponent = 1, 136 136 }, true); 137 + 138 + Clear(ClearInfo.Default); 137 139 } 138 140 139 - // We initialize to an invalid value such that we are not missing an initial GL.ClearColor call. 140 - private static Color4 clearColour = new Color4(-1, -1, -1, -1); 141 + private static ClearInfo currentClearInfo; 141 142 142 - public static void ClearColour(Color4 c) 143 + public static void Clear(ClearInfo clearInfo) 143 144 { 144 - if (clearColour != c) 145 + if (clearInfo.Colour != currentClearInfo.Colour) 146 + GL.ClearColor(clearInfo.Colour); 147 + 148 + if (clearInfo.Depth != currentClearInfo.Depth) 145 149 { 146 - clearColour = c; 147 - GL.ClearColor(clearColour); 150 + // Todo: Wtf. osuTK's bindings are broken for glClearDepthf(). Using glClearDepth() for now 151 + osuTK.Graphics.OpenGL.GL.ClearDepth(clearInfo.Depth); 148 152 } 149 153 154 + if (clearInfo.Stencil != currentClearInfo.Stencil) 155 + GL.ClearStencil(clearInfo.Stencil); 156 + 150 157 GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); 158 + 159 + currentClearInfo = clearInfo; 151 160 } 152 161 153 162 /// <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);