/* * Created by SharpDevelop. * User: username * Date: 03/07/2012 * Time: 21:31 * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using OpenTK; using OpenTK.Graphics.OpenGL; namespace Graphic_Demo_0 { /// /// Description of MainForm. /// public partial class MainForm : Form { bool GL_Loaded = false; double fov, fovTan, aspect; public MainForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // } void GlControl1Load(object sender, EventArgs e) { GL_Loaded = true; SetupViewport(); GL.ClearColor(Color.FromArgb(0,0,0)); } private void SetupViewport() { int w = glControl1.Width; int h = glControl1.Height; aspect = w / h; fov = Math.PI * 0.25; fovTan = Math.Tan(fov * 0.5); Matrix4 perspective = Matrix4.CreatePerspectiveFieldOfView(Convert.ToSingle(fov), Convert.ToSingle(aspect), 10.0f, 5000.0f); GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); GL.LoadMatrix(ref perspective); GL.Viewport(0, 0, w, h); } } }