示例#1
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);
            Time.AddTime((float)e.Time);
            DateTime frameStart = DateTime.Now;

            PostProcessing.GetInstance().PreRender();
            Render();
            PostProcessing.GetInstance().Prepare2D();
            Render2D();
            PostProcessing.GetInstance().PostRender();

            this.SwapBuffers();

            if (GlobalSettings.Default.improvedLatency)
            {
                GL.Finish();
            }

            #region "Framerate logic"
            DateTime frameEnd = DateTime.Now;
            if (GlobalSettings.Default.frameCap > 0 && (frameEnd - frameStart).TotalMilliseconds < 1000.0f / GlobalSettings.Default.frameCap)
            {
                Thread.Sleep((int)((1000.0f / GlobalSettings.Default.frameCap) - (frameEnd - frameStart).TotalMilliseconds));
            }
            ++framesLastSecond;

            Time.lastFrameTime = (frameEnd - frameStart).TotalSeconds;

            if ((DateTime.Now - lastFrameCollection).TotalMilliseconds >= 1000)
            {
                OneSecondPassed();
                //Logging.Write(1000.0f/(frameEnd-frameStart).TotalMilliseconds + "FPS");
                for (int i = 0; i < 99; ++i)
                {
                    frameRateGraph[i + 1] = frameRateGraph[i];
                }
                frameRateGraph[99]  = (int)(1000.0f / (frameEnd - frameStart).TotalMilliseconds);
                framesLastSecond    = 0;
                lastFrameCollection = DateTime.Now;
            }
            #endregion
            if (firstFrameRendered)
            {
                return;
            }
            firstFrameRendered = true;
        }
示例#2
0
        public override void Init()
        {
            Icon = System.Drawing.Icon.ExtractAssociatedIcon(AppDomain.CurrentDomain.FriendlyName);

            Title = "race test";

            PostProcessing.GetInstance().frameBufferMaterial = new MaterialBuilder()
                                                               .Build()
                                                               .SetName("Standard Object Material")
                                                               .Attach(new Shader("Shaders\\2D\\vert.glsl", ShaderType.VertexShader))
                                                               .Attach(new Shader("Shaders\\Framebuffer\\frag.glsl", ShaderType.FragmentShader))
                                                               .Link()
                                                               .GetMaterial();


            currentScreen = new Splash();
            currentScreen.Init();

            label = new BitmapLabel(new BitmapFont(TextureLoader.LoadAsset("Content\\Fonts\\5x10mono.png"), new Vector2(5, 10), new Vector2(0, 0), new char[] { '!', '\"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '¦' }), new Vector2(16, 16), "");

            mainGame = new GameScreen();
            mainGame.Init();
        }