OpenBve.Renderer.RenderOverlaySolid C# (CSharp) Méthode

RenderOverlaySolid() private static méthode

private static RenderOverlaySolid ( double ax, double ay, double bx, double by ) : void
ax double
ay double
bx double
by double
Résultat void
        private static void RenderOverlaySolid(double ax, double ay, double bx, double by)
        {
            double nay = (double)ScreenHeight - ay;
            double nby = (double)ScreenHeight - by;
            if (TexturingEnabled)
            {
                GL.Disable(EnableCap.Texture2D);
                TexturingEnabled = false;
            }
            GL.Begin(PrimitiveType.Quads);
            GL.TexCoord2(0.0, 1.0);
            GL.Vertex2(ax, nby);
            GL.TexCoord2(0.0, 0.0);
            GL.Vertex2(ax, nay);
            GL.TexCoord2(1.0, 0.0);
            GL.Vertex2(bx, nay);
            GL.TexCoord2(1.0, 1.0);
            GL.Vertex2(bx, nby);
            GL.End();
        }

Usage Example

Exemple #1
0
        //
        // DRAW LOADING SCREEN
        //
        /// <summary>Draws on OpenGL canvas the route/train loading screen</summary>
        internal static void DrawLoadingScreen()
        {
            // begin HACK //
            if (!BlendEnabled)
            {
                GL.Enable(EnableCap.Blend);
                GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
                BlendEnabled = true;
            }
            if (LightingEnabled)
            {
                GL.Disable(EnableCap.Lighting);
                LightingEnabled = false;
            }
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.PushMatrix();
            // fill the screen with background colour
            GL.Color4(bkgR, bkgG, bkgB, bkgA);
            Renderer.RenderOverlaySolid(0.0, 0.0, (double)Screen.Width, (double)Screen.Height);
            GL.Color4(1.0f, 1.0f, 1.0f, 1.0f);

            // BACKGROUND IMAGE
            int fontHeight = (int)Fonts.SmallFont.FontSize;
            int logoBottom;
            //			int		versionTop;
            int halfWidth = Screen.Width / 2;

            if (TextureLoadingBkg != null)
            {
                int bkgHeight, bkgWidth;
                // stretch the background image to fit at least one screen dimension
                double ratio = (double)TextureLoadingBkg.Width / (double)TextureLoadingBkg.Height;
                if (Screen.Width / ratio > Screen.Height)     // if screen ratio is shorter than bkg...
                {
                    bkgHeight = Screen.Height;                // set height to screen height
                    bkgWidth  = (int)(Screen.Height * ratio); // and scale width proprtionally
                }
                else                                          // if screen ratio is wider than bkg...
                {
                    bkgWidth  = Screen.Width;                 // set width to screen width
                    bkgHeight = (int)(Screen.Width / ratio);  // and scale height accordingly
                }
                // draw the background image down from the top screen edge
                DrawRectangle(TextureLoadingBkg, new Point((Screen.Width - bkgWidth) / 2, 0), new Size(bkgWidth, bkgHeight), Color128.White);
            }
            // if the route has no custom loading image, add the openBVE logo
            // (the route custom image is loaded in OldParsers/CsvRwRouteParser.cs)
            if (!customLoadScreen)
            {
                if (TextureLogo != null)
                {
                    // place the centre of the logo at from the screen top
                    int logoTop = (int)(Screen.Height * logoCentreYFactor - TextureLogo.Height / 2.0);
                    logoBottom = logoTop + TextureLogo.Height;
                    DrawRectangle(TextureLogo, new Point((Screen.Width - TextureLogo.Width) / 2, logoTop), new Size(TextureLogo.Width, TextureLogo.Height), Color128.White);
                }
            }
            else
            {
                // if custom route image, no logo and leave a conventional black area below the potential logo
            }
            logoBottom = Screen.Height / 2;
            // take the height remaining below the logo and divide in 3 horiz. parts
            int blankHeight = (Screen.Height - logoBottom) / 3;

            // VERSION NUMBER
            // place the version above the first division
            int versionTop = logoBottom + blankHeight - fontHeight;

            DrawString(Fonts.NormalFont, "API Version: " + RAGLINKCommons.RPlatform.SettingsContent.simulatorVersion.ToString(),
                       new Point(65, 5), TextAlignment.TopMiddle, Color128.White);
            // for the moment, do not show any URL; would go right below the first division
            //			DrawString(Fonts.SmallFont, "https://sites.google.com/site/openbvesim/home",
            //				new Point(halfWidth, versionTop + fontHeight+2),
            //				TextAlignment.TopMiddle, Color128.White);

            // PROGRESS MESSAGE AND BAR
            // place progress bar right below the second division
            //int		progressTop		= Screen.Height - blankHeight;
            int progressTop = Screen.Height - 6;
            //int		progressWidth	= Screen.Width - progrMargin * 2;
            int    progressWidth = Screen.Width;
            double routeProgress = Math.Max(0.0, Math.Min(1.0, Loading.RouteProgress));
            double trainProgress = Math.Max(0.0, Math.Min(1.0, Loading.TrainProgress));
            // sum of route progress and train progress arrives up to 2.0:
            // => times 50.0 to convert to %
            double percent = 50.0 * (routeProgress + trainProgress);
            string percStr = percent.ToString("0") + "%";
            // draw progress message right above the second division
            string text = Translations.GetInterfaceString(
                routeProgress < 1.0 ? "loading_loading_route" :
                (trainProgress < 1.0 ? "loading_loading_train" : "message_loading")) + " (" + percStr + ")";

            DrawString(Fonts.NormalFont, text, new Point(halfWidth, progressTop - fontHeight - 8),
                       TextAlignment.TopMiddle, Color128.White);
            // progress frame
            //DrawRectangle(null, new Point(progrMargin-progrBorder, progressTop-progrBorder),
            //	new Size(progressWidth+progrBorder*2, fontHeight+6), Color128.White);
            // progress bar
            DrawRectangle(null, new Point(0, progressTop),
                          new Size(progressWidth * (int)percent / 100, fontHeight + 4), ColourProgressBar);
            // progress percent
            //DrawString(Fonts.SmallFont, percStr, new Point(halfWidth, progressTop),
            //	TextAlignment.TopMiddle, Color128.Black);
            GL.PopMatrix();
        }
All Usage Examples Of OpenBve.Renderer::RenderOverlaySolid