using System; using System.Collections.Generic; using System.Text; using OpenTK.OpenGL; using OpenTK; using OpenTK.OpenGL.Enums; using System.Drawing; using OpenTK.Math; namespace Dogfight2008.Common { /// /// This class assumes a right handed coordinate system, /// with z axis going upwards. In other words, moving on /// in the ground plane means changing x/y position, not /// z! /// /// _ /// z / \ sky /// | /// | /// | _ y /// | /| /// |/ ground /// +---------> x /// /// public static class GLControlUtil { public static void Init(GLControl glControl, double viewdistance) { GLUtil.Init(); HandleResize(glControl, viewdistance); } public static void HandleResize(GLControl glCtrl, double viewdistance) { GL.Viewport(0, 0, glCtrl.ClientSize.Width, glCtrl.ClientSize.Height); GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); Glu.Perspective(45, (double)glCtrl.Width / glCtrl.Height, 0.5, viewdistance); glCtrl.Invalidate(); GL.MatrixMode(MatrixMode.Modelview); } public static void SwapBuffers(GLControl glControl) { glControl.SwapBuffers(); } } }