SetAlphaFunc() private static méthode

private static SetAlphaFunc ( AlphaFunction Comparison, float Value ) : void
Comparison AlphaFunction
Value float
Résultat void
Exemple #1
0
            internal override void RenderBackground(float Scale)
            {
                if (this.CurrentBackgroundIndex != this.PreviousBackgroundIndex)
                {
                    switch (this.Backgrounds[CurrentBackgroundIndex].Mode)
                    {
                    case BackgroundTransitionMode.FadeIn:
                        Renderer.RenderBackground(this.Backgrounds[PreviousBackgroundIndex], 1.0f, Scale);
                        Renderer.SetAlphaFunc(AlphaFunction.Greater, 0.0f);
                        Renderer.RenderBackground(this.Backgrounds[CurrentBackgroundIndex], this.CurrentAlpha, Scale);
                        break;

                    case BackgroundTransitionMode.FadeOut:
                        Renderer.RenderBackground(this.Backgrounds[CurrentBackgroundIndex], 1.0f, Scale);
                        Renderer.SetAlphaFunc(AlphaFunction.Greater, 0.0f);
                        Renderer.RenderBackground(this.Backgrounds[PreviousBackgroundIndex], this.CurrentAlpha, Scale);
                        break;
                    }
                }
                else
                {
                    Renderer.RenderBackground(this.Backgrounds[CurrentBackgroundIndex], 1.0f, Scale);
                }
            }
Exemple #2
0
        /// <summary>Updates the currently displayed background</summary>
        /// <param name="TimeElapsed">The time elapsed since the previous call to this function</param>
        private static void UpdateBackground(double TimeElapsed)
        {
            if (Game.CurrentInterface != Game.InterfaceType.Normal)
            {
                //Don't update the transition whilst paused
                TimeElapsed = 0.0;
            }
            const float scale = 0.5f;
            // fog
            const float fogdistance = 600.0f;

            if (Game.CurrentFog.Start < Game.CurrentFog.End & Game.CurrentFog.Start < fogdistance)
            {
                float cr = inv255 * (float)Game.CurrentFog.Color.R;
                float cg = inv255 * (float)Game.CurrentFog.Color.G;
                float cb = inv255 * (float)Game.CurrentFog.Color.B;
                if (!FogEnabled)
                {
                    GL.Fog(FogParameter.FogMode, (int)FogMode.Linear);
                }
                float ratio = (float)World.BackgroundImageDistance / fogdistance;
                GL.Fog(FogParameter.FogStart, Game.CurrentFog.Start * ratio * scale);
                GL.Fog(FogParameter.FogEnd, Game.CurrentFog.End * ratio * scale);
                GL.Fog(FogParameter.FogColor, new float[] { cr, cg, cb, 1.0f });
                if (!FogEnabled)
                {
                    GL.Enable(EnableCap.Fog); FogEnabled = true;
                }
            }
            else if (FogEnabled)
            {
                GL.Disable(EnableCap.Fog); FogEnabled = false;
            }
            //Update the currently displayed background
            BackgroundManager.CurrentBackground.UpdateBackground(TimeElapsed, false);
            if (BackgroundManager.TargetBackground == null || BackgroundManager.TargetBackground == BackgroundManager.CurrentBackground)
            {
                //No target background, so call the render function
                BackgroundManager.CurrentBackground.RenderBackground(scale);
                return;
            }
            //Update the target background
            if (BackgroundManager.TargetBackground is BackgroundManager.StaticBackground)
            {
                BackgroundManager.TargetBackground.Countdown += TimeElapsed;
            }
            BackgroundManager.TargetBackground.UpdateBackground(TimeElapsed, true);
            switch (BackgroundManager.TargetBackground.Mode)
            {
            //Render, switching on the transition mode
            case BackgroundManager.BackgroundTransitionMode.FadeIn:
                BackgroundManager.CurrentBackground.RenderBackground(1.0f, scale);
                Renderer.SetAlphaFunc(AlphaFunction.Greater, 0.0f);
                BackgroundManager.TargetBackground.RenderBackground(BackgroundManager.TargetBackground.CurrentAlpha, scale);
                break;

            case BackgroundManager.BackgroundTransitionMode.FadeOut:
                BackgroundManager.TargetBackground.RenderBackground(1.0f, scale);
                Renderer.SetAlphaFunc(AlphaFunction.Greater, 0.0f);
                BackgroundManager.CurrentBackground.RenderBackground(BackgroundManager.TargetBackground.CurrentAlpha, scale);
                break;
            }
            //If our target alpha is greater than or equal to 1.0f, the background is fully displayed
            if (BackgroundManager.TargetBackground.CurrentAlpha >= 1.0f)
            {
                //Set the current background to the target & reset target to null
                BackgroundManager.CurrentBackground = BackgroundManager.TargetBackground;
                BackgroundManager.TargetBackground  = null;
            }
        }