Example #1
0
        internal static void BloomEnd()
        {
            if (!(ConfigManager.sBloomSoftening || ExtraPass))
            {
                return;
            }
            renderTarget.Unbind();

#if !DEBUG
            try
            {
#endif
            // If we rendered everything to a frame buffer object, then we first need to blit it to the backbuffer.
            if (OsuGlControl.CanUseFBO)
            {
                OsuGlControl.SetBlend(BlendingFactorSrc.One, BlendingFactorDest.Zero);
                renderTarget.Texture.Draw(Vector2.Zero, Vector2.Zero, Color.White, new Vector2(1, -1), 0, null);
            }

            OsuGlControl.SetBlend(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            bloomShader.Begin();
            if (ConfigManager.sBloomSoftening)
            {
                bloomShader.Properties[@"mag"]     = 0.004f;
                bloomShader.Properties[@"alpha"]   = 0.15f;
                bloomShader.Properties[@"hirange"] = false;
                bloomShader.Properties[@"redtint"] = 0f;
                renderTarget.Texture.Draw(Vector2.Zero, Vector2.Zero, Color.White, new Vector2(1, -1), 0, null);
            }

            if (ExtraPass)
            {
                bloomShader.Properties[@"mag"]     = Magnitude;
                bloomShader.Properties[@"alpha"]   = Alpha;
                bloomShader.Properties[@"hirange"] = HiRange;
                bloomShader.Properties[@"redtint"] = RedTint;

                if (Additive)
                {
                    OsuGlControl.SetBlend(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);
                }

                renderTarget.Texture.Draw(Vector2.Zero, Vector2.Zero, Color.White, new Vector2(1, -1), 0, null);

                if (Additive)
                {
                    OsuGlControl.SetBlend(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
                }
            }
            bloomShader.End();
#if !DEBUG
        }

        catch
        {
            //Todo:
        }
#endif
        }
Example #2
0
        private void startBatch(bool allowRecycle = false)
        {
            if (hasBegun && !allowRecycle)
            {
                return;
            }

            endBatch();

            int amountQuads = OsuMathHelper.Clamp(SpriteList.Count, 1, 100);

            if (SpriteBatch == null || SpriteBatch.Size < amountQuads)
            {
                for (int i = 0; i < SpriteBatches.Length; i++)
                {
                    SpriteBatches[i] = new QuadBatch <TexturedVertex2d>(amountQuads * 2, 500);
                }
            }

            if (currentBlend == SpriteBlendMode.Additive)
            {
                OsuGlControl.SetBlend(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);
            }
            else
            {
                OsuGlControl.SetBlend(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            }

            hasBegun = true;
            Current  = this;
            NativeText.ScaleModifier = Scale;
        }
Example #3
0
        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);
        }
Example #4
0
        public void Draw()
        {
            if (ConfigManager.dDisableSpriteDraw)
            {
                return;
            }

            pTexture trail = SkinManager.t_cursortrail;

            if (amountVisibleRanges == 0 || trail == null || trail.IsDisposed)
            {
                return;
            }

            if (trail.TextureGl.Bind())
            {
                cursorTrailShader.Properties[@"g_FadeClock"] = fadeClock;
                cursorTrailShader.Begin();

                OsuGlControl.SetBlend(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);

                for (int i = 0; i < amountNewRanges; i += 2)
                {
                    for (int j = newIndexRanges[i]; j < newIndexRanges[i + 1]; ++j)
                    {
                        needsUpload[j] = false;
                    }

                    vertexBuffer.UpdateRange(newIndexRanges[i] * 4, newIndexRanges[i + 1] * 4);
                }

                for (int i = 0; i < amountVisibleRanges; i += 2)
                {
                    vertexBuffer.DrawRange(visibleIndexRanges[i] * 4, visibleIndexRanges[i + 1] * 4);
                }

                cursorTrailShader.End();
            }
        }