Example #1
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            int startTime = Environment.TickCount & Int32.MaxValue;

            base.OnRenderFrame(e);

            GL.LightModel(LightModelParameter.LightModelAmbient, globLight);

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.MatrixMode(MatrixMode.Modelview);

            camera.SetView();

            SkyBoxSphere.Render(camera);

            ReferencePlane.setDimensions(50, 50);
            ReferencePlane.render();

            map.Render();

            //shadowTest();

            int totalTime = (Environment.TickCount & Int32.MaxValue) - startTime;

            int fps = 0;

            if (totalTime > 0)
            {
                fps = 1000 / totalTime;
            }

            Title = this.baseTitle + " FPS: " + fps;

            if (useFonts)
            {
                QFont.Begin();

                GL.PushMatrix();
                GL.Translate(0.0, 0.0, 0.0);
                font.Print(Title, QFontAlignment.Left);
                GL.PopMatrix();

                if (cameraHelp)
                {
                    GL.PushMatrix();
                    GL.Translate(config.ScreenWidth * 0.75, 0.0, 0.0);
                    monoFont.Print(cameraHelpText, QFontAlignment.Left);
                    GL.PopMatrix();
                }

                if (gameStats)
                {
                    GL.PushMatrix();
                    GL.Translate(0.0, config.ScreenHeight * 0.10f, 0.0);
                    gameStatsText = String.Format(gameStatsFormat,
                                                  map.GetRobots().Count, activeRobot.GetALife());
                    monoFont.Print(gameStatsText, QFontAlignment.Left);
                    GL.PopMatrix();
                }

                if (gameOver)
                {
                    GL.PushMatrix();
                    GL.Translate(config.ScreenWidth * 0.50, 0.0, 0.0);
                    monoFont.Print(gameOverText, QFontAlignment.Centre);
                    GL.PopMatrix();
                }

                QFont.End();
                GL.Disable(EnableCap.Texture2D);
            }

            GL.Flush();

            SwapBuffers();
        }