using Microsoft.Xna.Framework.Graphics; // ... GraphicsDevice graphicsDevice = new GraphicsDevice( GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, new PresentationParameters() );
Texture2D texture = Content.Load("example_sprite"); spriteBatch.Begin(); spriteBatch.Draw(texture, new Vector2(100, 100), Color.White); spriteBatch.End();
Model model = Content.LoadThis code loads a 3D model from a content file and draws it on the screen using a series of transformation matrices and BasicEffect objects. The GraphicsDevice class is part of the Microsoft.Xna.Framework.Graphics namespace, which is included in the XNA Framework library.("example_model"); Matrix worldMatrix = Matrix.CreateTranslation(new Vector3(0, 0, 0)); Matrix viewMatrix = Matrix.CreateLookAt(Vector3.Zero, Vector3.Forward, Vector3.Up); Matrix projectionMatrix = Matrix.CreatePerspectiveFieldOfView( MathHelper.PiOver4, graphicsDevice.Viewport.AspectRatio, 0.1f, 1000f ); foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.World = worldMatrix; effect.View = viewMatrix; effect.Projection = projectionMatrix; effect.EnableDefaultLighting(); } mesh.Draw(); }