public Statistics(Game game)
        {
            // By default, this class only sets the frames per second statistic
            m_statistics = new Dictionary<string, string>();
            m_statistics["FPS"] = "0";

            // Load the font to be used for drawing text
            m_textFont = new Font(FontFamily.GenericSansSerif, 10);
            m_textBrush = new SolidBrush(Color.White);

            // Create a bitmap to store the text
            m_textBitmap = new Bitmap(game.Width, game.Height);

            // Create and bind a texture object
            m_textTexture = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, m_textTexture);

            // Set linear filtering for stretching and shrinking textures
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear);

            // Allocate memory, so we can update efficiently using TexSubImage2D
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba,
                m_textBitmap.Width, m_textBitmap.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
        }
Пример #2
0
 public static void Main(string[] args)
 {
     using (Game game = new Game())
     {
         game.Run(60.0);
     }
 }
Пример #3
0
        /// <summary>
        /// Creates the instance of the camera at the given location.
        /// </summary>
        /// <param name="position">Position of the camera.</param>
        /// <param name="target">The target towards which the camera is pointing.</param>
        public Camera(Game game, Vector3 position, Vector3 target)
            : this(game)
        {
            m_position = position;
            m_direction = target - m_position;
            m_direction.Normalize();

            View = CreateLookAt();
        }
Пример #4
0
        /// <summary>
        /// Creates the instance of the camera.
        /// </summary>
        public Camera(Game game)
        {
            // Create the direction vector and normalize it since it will be used for movement
            m_direction = Vector3.Zero - m_position;
            m_direction.Normalize();

            // Create default camera matrices
            Projection = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, game.Width / (float)game.Height, 0.01f, 1000);
            View = CreateLookAt();
        }