public override bool Draw() { if (!base.Draw()) { return(false); } Progress = (float)Math.Min(1.0, Progress); float scaledOuterRingRadius = Radius * Scale * GameBase.WindowManager.RatioInverse; float scaledGlowWidth = GlowWidth * Scale * GameBase.WindowManager.RatioInverse; float scaledInnerRingRadius = (float)Math.Min(scaledOuterRingRadius, Math.Max(0.0, (Radius - LineWidth) * Scale * GameBase.WindowManager.RatioInverse)); Vector2 scaledPosition = Position * GameBase.WindowManager.Ratio; vertexBuffer.Vertices[0].Position = scaledPosition + new Vector2(-scaledOuterRingRadius - scaledGlowWidth, -scaledOuterRingRadius - scaledGlowWidth); vertexBuffer.Vertices[1].Position = scaledPosition + new Vector2(-scaledOuterRingRadius - scaledGlowWidth, scaledOuterRingRadius + scaledGlowWidth); vertexBuffer.Vertices[2].Position = scaledPosition + new Vector2(scaledOuterRingRadius + scaledGlowWidth, scaledOuterRingRadius + scaledGlowWidth); vertexBuffer.Vertices[3].Position = scaledPosition + new Vector2(scaledOuterRingRadius + scaledGlowWidth, -scaledOuterRingRadius - scaledGlowWidth); vertexBuffer.Update(); circularProgressBarShader.Properties[@"m_CenterPos"] = new OpenTK.Vector2(scaledPosition.X, scaledPosition.Y); circularProgressBarShader.Properties[@"m_OuterRadius"] = scaledOuterRingRadius; circularProgressBarShader.Properties[@"m_InnerRadius"] = scaledInnerRingRadius; circularProgressBarShader.Properties[@"m_OuterGlowRadius"] = scaledOuterRingRadius + scaledGlowWidth; circularProgressBarShader.Properties[@"m_InnerGlowRadius"] = scaledInnerRingRadius - scaledGlowWidth; circularProgressBarShader.Properties[@"m_Alpha"] = Alpha; circularProgressBarShader.Properties[@"m_GlowColour"] = _glowColour; circularProgressBarShader.Properties[@"m_RingBackgroundColour"] = _ringBackgroundColour; circularProgressBarShader.Properties[@"m_RingForegroundColour"] = _ringForegroundColour; circularProgressBarShader.Properties[@"m_Progress"] = Progress; OsuGlControl.SetBlend(BlendingFactorSrc.One, BlendingFactorDest.One); circularProgressBarShader.Begin(); vertexBuffer.Draw(); circularProgressBarShader.End(); return(true); }
public override bool Draw() { if (bypass) { return(false); } SpriteManager.Current.SetBlending(Additive); pTexture texture = Texture; if (texture == null || texture.IsDisposed) { return(true); } Vector2 d = new Vector2(drawRectangle.X + drawOriginScaled.X, drawRectangle.Y + drawOriginScaled.Y); if (vertexBuffer == null) { vertexBuffer = new QuadVertexBuffer <ParticleVertex2d>(amountParticles, BufferUsageHint.StaticDraw); RectangleF texCoordsRect = new RectangleF(0, 0, (float)texture.Width / TextureGl.GetPotDimension(texture.Width), (float)texture.Height / TextureGl.GetPotDimension(texture.Height)); for (int i = 0; i < amountParticles; ++i) { int vertexIndex = i * 4; int time = RNG.Next(500, 1200); double angle = RNG.NextDouble(Math.PI * 2.0); Vector2 direction = drawScaleVector * new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * (float)RNG.NextDouble(radius); if (time > maxTime) { maxTime = time; } vertexBuffer.Vertices[vertexIndex + 0].Position = d + new Vector2(-drawRectangle.Width / 2, -drawRectangle.Height / 2); vertexBuffer.Vertices[vertexIndex + 0].TexturePosition = new Vector2(0, 0); vertexBuffer.Vertices[vertexIndex + 0].Colour = Color.White; vertexBuffer.Vertices[vertexIndex + 0].Time = time; vertexBuffer.Vertices[vertexIndex + 0].Direction = direction; vertexBuffer.Vertices[vertexIndex + 1].Position = d + new Vector2(-drawRectangle.Width / 2, drawRectangle.Height / 2); vertexBuffer.Vertices[vertexIndex + 1].TexturePosition = new Vector2(0, texCoordsRect.Height); vertexBuffer.Vertices[vertexIndex + 1].Colour = Color.White; vertexBuffer.Vertices[vertexIndex + 1].Time = time; vertexBuffer.Vertices[vertexIndex + 1].Direction = direction; vertexBuffer.Vertices[vertexIndex + 2].Position = d + new Vector2(drawRectangle.Width / 2, drawRectangle.Height / 2); vertexBuffer.Vertices[vertexIndex + 2].TexturePosition = new Vector2(texCoordsRect.Width, texCoordsRect.Height); vertexBuffer.Vertices[vertexIndex + 2].Colour = Color.White; vertexBuffer.Vertices[vertexIndex + 2].Time = time; vertexBuffer.Vertices[vertexIndex + 2].Direction = direction; vertexBuffer.Vertices[vertexIndex + 3].Position = d + new Vector2(drawRectangle.Width / 2, -drawRectangle.Height / 2); vertexBuffer.Vertices[vertexIndex + 3].TexturePosition = new Vector2(texCoordsRect.Width, 0); vertexBuffer.Vertices[vertexIndex + 3].Colour = Color.White; vertexBuffer.Vertices[vertexIndex + 3].Time = time; vertexBuffer.Vertices[vertexIndex + 3].Direction = direction; } vertexBuffer.Update(); } if (texture.TextureGl != null && texture.TextureGl.Bind()) { OsuGlControl.ParticleShader.Properties[@"g_Gravity"] = gravity; OsuGlControl.ParticleShader.Properties[@"g_FadeClock"] = (float)(getClockTime() - startTime); OsuGlControl.ParticleShader.Begin(); vertexBuffer.Draw(); OsuGlControl.ParticleShader.End(); } return(true); }