예제 #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            m_camera = new Camera(this);
            Components.Add(m_camera);

            m_stats = new Statistics(this, Content);
            Components.Add(m_stats);

            m_map = new Map(this, Content);
            Components.Add(m_map);

            base.Initialize();
        }
예제 #2
0
        /// <summary>
        /// Display the terrain using the given shader.
        /// </summary>
        /// <param name="gameTime">Snapshot of the game timing state.</param>
        /// <param name="camera">Reference to the instance of the camera class.</param>
        public void Draw(GameTime gameTime, Camera camera)
        {
            m_effect.CurrentTechnique = m_effect.Techniques["Textured"];
            m_effect.Parameters["World"].SetValue(Matrix.Identity);
            m_effect.Parameters["View"].SetValue(camera.View);
            m_effect.Parameters["Projection"].SetValue(camera.Projection);

            m_effect.Parameters["xTexture"].SetValue(m_texture);

            foreach (EffectPass pass in m_effect.CurrentTechnique.Passes)
            {
                pass.Apply();

                GraphicsDevice.Indices = m_indexBuffer;
                GraphicsDevice.SetVertexBuffer(m_vertexBuffer);
                GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, m_vertexBuffer.VertexCount, 0, m_indexBuffer.IndexCount / 3);
            }
        }