/// <summary> /// Main entry point static method for the program. /// </summary> /// <param name="args">The input arguments from the command line, if any.</param> static void Main(string[] args) { // Create a new game instance. GameInternal game = new GameInternal(); // Run the game! game.Run(); }
/// <summary> /// Apply the projection matrix from the camera POV. /// </summary> /// <param name="file">The file name.</param> /// <returns>The GL object.</returns> public static void CameraView() { Quaternion Q = GameInternal.GetRotation(); Vector3 forward = Vector3.Transform(-Vector3.UnitZ, Q); Matrix4 View = Matrix4.LookAt(GameInternal.Center, GameInternal.Center + forward, Vector3.UnitY); Matrix4 Perspective = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI * 0.5f, GameInternal.Window.Width / (float)GameInternal.Window.Height, 0.1f, 1000f); Matrix4 Projection = View * Perspective; GL.UniformMatrix4(1, false, ref Projection); GL.ClearBuffer(ClearBuffer.Color, 0, new float[] { 0, 0, 0, 1 }); GL.ClearBuffer(ClearBuffer.Depth, 0, new float[] { 1 }); }
/// <summary> /// Tick operation for control inputs. /// </summary> public static void ControlTick() { MouseState ms = Mouse.GetState(); if (ms.IsButtonDown(MouseButton.Left)) { GameInternal.Angle -= (ms.X - MouseCoords.X) * 0.005f; //GameInternal.Angle = (GameInternal.Angle < 0f) ? 360f : (GameInternal.Angle > 360f) ? 0f : GameInternal.Angle; GameInternal.Pitch -= (ms.Y - MouseCoords.Y) * 0.005f; GameInternal.Pitch = (GameInternal.Pitch < -GameInternal.Degrees89) ? -GameInternal.Degrees89 : (GameInternal.Pitch > GameInternal.Degrees89) ? GameInternal.Degrees89 : GameInternal.Pitch; } MouseCoords = new Vector2(ms.X, ms.Y); Quaternion Q = GameInternal.GetRotation(); if (InputHelpers.CurrentVector != Vector3.Zero) { GameInternal.Center += Vector3.Transform(InputHelpers.CurrentVector, Q); } }