protected override void OnRenderFrame(FrameEventArgs e) { // called once per frame; render app.Tick(); if (terminated) { Exit(); return; } // convert MyApplication.screen to OpenGL texture GL.BindTexture(TextureTarget.Texture2D, screenID); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, app.screen.width, app.screen.height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, app.screen.pixels ); // 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(); app.RenderGL(); // tell OpenTK we're done rendering SwapBuffers(); }
protected override void OnRenderFrame(FrameEventArgs e) { // called once per frame; render app.Tick(); if (terminated) { Exit(); return; } // set the state for rendering the quad GL.ClearColor(Color.Black); GL.Enable(EnableCap.Texture2D); GL.Disable(EnableCap.DepthTest); GL.Color3(1.0f, 1.0f, 1.0f); // convert MyApplication.Screen to OpenGL texture GL.BindTexture(TextureTarget.Texture2D, screenID); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, app.screen.width, app.screen.height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, app.screen.pixels ); // draw screen filling quad 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.Clear(ClearBufferMask.DepthBufferBit); GL.Disable(EnableCap.Texture2D); // do OpenGL rendering app.RenderGL(); // swap buffers SwapBuffers(); }