Example #1
0
        /// <summary>
        /// This method overrides the base OnRenderFrame method from GameWindow
        ///
        /// It renders each frame
        /// </summary>
        /// <param name="e"></param>
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);

            //OpenGL graphics initialization
            GL.ClearColor(currentColor);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);

            //Setup OpenGL graphics to render the player
            GL.Begin(PrimitiveType.Polygon);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.Color3(0, 0, 0);

            //Get vertices of the player
            Vertices = player.render(Width, Height);

            //Render the player
            foreach (Vector2d vertex in Vertices)
            {
                GL.Vertex2(vertex);
            }

            //End rendering the player
            GL.End();


            //Loop through all of the platforms to render them
            foreach (Platform plat in platforms)
            {
                //Begin GL graphics to render the current platform
                GL.Begin(PrimitiveType.Polygon);
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
                GL.Color3(0.3, 0.3, 0.3);

                //Ger vertices for rendering the current platform
                Vertices = plat.render(Width, Height);

                //Render the platform
                foreach (Vector2d vertex in Vertices)
                {
                    GL.Vertex2(vertex);
                }

                //End rendering the platform
                GL.End();
            }

            //Update the window
            SwapBuffers();
        }