protected override void OnRenderFrame(FrameEventArgs e)
 {
     // called once per frame; render
     game.Tick();
     GL.BindTexture(TextureTarget.Texture2D, screenID);
     GL.TexImage2D(TextureTarget.Texture2D,
                   0,
                   PixelInternalFormat.Rgba,
                   game.screen.width,
                   game.screen.height,
                   0,
                   OpenTK.Graphics.OpenGL.PixelFormat.Bgra,
                   PixelType.UnsignedByte,
                   game.screen.pixels
                   );
     GL.Clear(ClearBufferMask.ColorBufferBit);
     GL.MatrixMode(MatrixMode.Modelview);
     GL.LoadIdentity();
     GL.BindTexture(TextureTarget.Texture2D, screenID);
     GL.Begin(PrimitiveType.Quads);
     GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-1.0f, -1.0f);
     GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(1.0f, -1.0f);
     GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(1.0f, 1.0f);
     GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-1.0f, 1.0f);
     GL.End();
     game.Render();
     SwapBuffers();
 }
Example #2
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            // called once per frame; render

            game.Tick();
            if (terminated)
            {
                Exit();
                return;
            }
            // convert Game.screen to OpenGL texture
            GL.BindTexture(TextureTarget.Texture2D, screenID);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba,
                          game.screen.width, game.screen.height, 0,
                          OpenTK.Graphics.OpenGL.PixelFormat.Bgra,
                          PixelType.UnsignedByte, game.screen.pixels
                          );
            // clear window contents
            GL.Clear(ClearBufferMask.ColorBufferBit);
            // setup camera
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            // draw screen filling quad
            GL.Begin(PrimitiveType.Quads);
            GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-1.0f, -1.0f);
            GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(1.0f, -1.0f);
            GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(1.0f, 1.0f);
            GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-1.0f, 1.0f);
            GL.End();
            // tell OpenTK we're done rendering
            SwapBuffers();
        }
Example #3
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            GL.UniformMatrix4(modelviewMatrixLocation, false, ref modelviewMatrix);

            // called once per frame; app logic
            var keyboard = OpenTK.Input.Keyboard.GetState();

            HandleInput(keyboard);
            game.Tick(e);
        }
Example #4
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            // called once per frame; render
            GL.ClearColor(Color.Black);
            GL.Enable(EnableCap.Texture2D);
            GL.Disable(EnableCap.DepthTest);
            GL.Color3(1.0f, 1.0f, 1.0f);

            sw.Stop();
            if (sw.ElapsedMilliseconds != 0)
            {
                Console.WriteLine(1 / (sw.ElapsedMilliseconds / 1000f));
            }
            sw.Reset();
            game.Tick();
            sw.Start();

            if (terminated)
            {
                Exit();
                return;
            }
            // convert Game.screen to OpenGL texture
            GL.BindTexture(TextureTarget.Texture2D, screenID);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba,
                          game.screen.width, game.screen.height, 0,
                          OpenTK.Graphics.OpenGL.PixelFormat.Bgra,
                          PixelType.UnsignedByte, game.screen.pixels
                          );
            // clear window contents
            GL.Clear(ClearBufferMask.ColorBufferBit);
            // setup camera
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            // draw screen filling quad
            GL.Begin(PrimitiveType.Quads);
            GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-1.0f, -1.0f);
            GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(1.0f, -1.0f);
            GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(1.0f, 1.0f);
            GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-1.0f, 1.0f);
            GL.End();
            // prepare for generic OpenGL rendering
            GL.Enable(EnableCap.DepthTest);
            GL.Disable(EnableCap.Texture2D);
            GL.Clear(ClearBufferMask.DepthBufferBit);
            game.RenderGL();
            // tell OpenTK we're done rendering
            SwapBuffers();
        }
Example #5
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            // prepare for generic OpenGL rendering
            GL.ClearColor(Color.Black);
            GL.Enable(EnableCap.DepthTest);
            GL.Disable(EnableCap.Texture2D);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.LoadIdentity();
            GL.Color3(1.0f, 1.0f, 1.0f);
            // called once per frame; render
            game.Tick();
            if (terminated)
            {
                Exit();
                return;
            }
            // convert Game.screen to OpenGL texture
            //GL.BindTexture( TextureTarget.Texture2D, screenID );
            //GL.TexImage2D( TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba,
            //game.screen.width, game.screen.height, 0,
            //OpenTK.Graphics.OpenGL.PixelFormat.Bgra,
            // PixelType.UnsignedByte, game.screen.pixels
            // );
            // clear window contents
            GL.Clear(ClearBufferMask.ColorBufferBit);
            // setup camera
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            // draw screen filling quad

            /*
             * GL.Color3(0f, 0f, 0f);
             *          GL.Begin( PrimitiveType.Quads );
             *          GL.Vertex2( -1.0f, -1.0f );
             *          GL.Vertex2(  1.0f, -1.0f );
             *          GL.Vertex2(  1.0f,  1.0f );
             *          GL.Vertex2( -1.0f,  1.0f );
             *          GL.End();
             */

            //Run the game GL
            game.RenderGL();
            // tell OpenTK we're done rendering
            SwapBuffers();
        }