Cubo Perspectiva

using System;
using System.Drawing;
 
using OpenTK;
using OpenTK.Input;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
 
using Tao.FreeGlut;
using System.Threading;
 
public class OpenTK_cubo:GameWindow
{	
	const float rotation = 180.0f;
	float angle;
 
	public OpenTK_cubo(): base(500, 500)
	{
		Keyboard.KeyDown += teclado;
	}
 
	public void teclado(object lanzador, KeyboardKeyEventArgs e)
	{
		if(e.Key == Key.Escape)
		{
			base.Exit();
		}
		if(e.Key == Key.F)
		{
			if(this.WindowState == OpenTK.WindowState.Normal)
			{
				this.WindowState = OpenTK.WindowState.Fullscreen;
			}
			else
			{
				this.WindowState = OpenTK.WindowState.Normal;
			}
		}
	}
 
	protected override void OnLoad (EventArgs e)
	{
		base.OnLoad (e);
		GL.ClearColor(Color.CornflowerBlue);
		GL.Enable(EnableCap.DepthTest);
	}
 
	protected override void OnRenderFrame (FrameEventArgs e)
	{
		base.OnRenderFrame (e);
		GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
		Matrix4 lookAt =  Matrix4.LookAt(0,5,5,0,0,0,0,1,0);
		GL.MatrixMode(MatrixMode.Modelview);
		GL.LoadMatrix(ref lookAt);
 
		angle += rotation * (float)e.Time;
		GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
 
		DrawCube();
 
		base.SwapBuffers();
		Thread.Sleep(1);
	}
	protected override void OnResize (EventArgs e)
	{
		base.OnResize (e);
		double aspec_ratio = Width / (double)Height;
		GL.Viewport(0, 0, Width, Height);
		OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float) aspec_ratio, 1, 64);
		GL.MatrixMode(MatrixMode.Projection);
		GL.LoadMatrix(ref perspective);
	}
 
	private void DrawCube()
        {
            GL.Begin(BeginMode.Quads);
 
            GL.Color3(Color.Blue);
            GL.Vertex3(-1.0f, -1.0f, -1.0f);
            GL.Vertex3(-1.0f, 1.0f, -1.0f);
            GL.Vertex3(1.0f, 1.0f, -1.0f);
            GL.Vertex3(1.0f, -1.0f, -1.0f);
 
            GL.Color3(Color.Green);
            GL.Vertex3(-1.0f, -1.0f, -1.0f);
            GL.Vertex3(1.0f, -1.0f, -1.0f);
            GL.Vertex3(1.0f, -1.0f, 1.0f);
            GL.Vertex3(-1.0f, -1.0f, 1.0f);
 
            GL.Color3(Color.Red);
 
            GL.Vertex3(-1.0f, -1.0f, -1.0f);
            GL.Vertex3(-1.0f, -1.0f, 1.0f);
            GL.Vertex3(-1.0f, 1.0f, 1.0f);
            GL.Vertex3(-1.0f, 1.0f, -1.0f);
 
            GL.Color3(Color.Purple);
            GL.Vertex3(-1.0f, -1.0f, 1.0f);
            GL.Vertex3(1.0f, -1.0f, 1.0f);
            GL.Vertex3(1.0f, 1.0f, 1.0f);
            GL.Vertex3(-1.0f, 1.0f, 1.0f);
 
            GL.Color3(Color.Violet);
            GL.Vertex3(-1.0f, 1.0f, -1.0f);
            GL.Vertex3(-1.0f, 1.0f, 1.0f);
            GL.Vertex3(1.0f, 1.0f, 1.0f);
            GL.Vertex3(1.0f, 1.0f, -1.0f);
 
            GL.Color3(Color.ForestGreen);
            GL.Vertex3(1.0f, -1.0f, -1.0f);
            GL.Vertex3(1.0f, 1.0f, -1.0f);
            GL.Vertex3(1.0f, 1.0f, 1.0f);
            GL.Vertex3(1.0f, -1.0f, 1.0f);
 
            GL.End();
        }
}
 
class MainClass
{
	public static void Main (string[] args)
	{
		OpenTK_cubo ventana = new OpenTK_cubo();
		ventana.Title = String.Format("OpenTK Cubo");
		ventana.Run();
	}
}