Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- namespace Game1
- {
- /// <summary>
- /// This is the main type for your game.
- /// </summary>
- public class Game1 : Game
- {
- GraphicsDeviceManager graphics;
- SpriteBatch spriteBatch;
- public Game1()
- {
- graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- }
- /// <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>
- Quad quad;
- Quad quad2;
- VertexDeclaration vertexDeclaration;
- Matrix View, Projection;
- protected override void Initialize()
- {
- quad = new Quad(Vector3.Zero, Vector3.Backward, Vector3.Up, 1, 1);
- quad2 = new Quad(new Vector3(0.5f,0,1), Vector3.Backward, Vector3.Up, 1, 1);
- View = Matrix.CreateLookAt(new Vector3(0, 0, 2), Vector3.Zero,
- Vector3.Up);
- Projection = Matrix.CreatePerspectiveFieldOfView(
- MathHelper.PiOver4, 4.0f / 3.0f, 1, 500);
- base.Initialize();
- }
- /// <summary>
- /// LoadContent will be called once per game and is the place to load
- /// all of your content.
- /// </summary>
- Texture2D texture;
- BasicEffect quadEffect;
- BasicEffect quadEffect2;
- protected override void LoadContent()
- {
- // Create a new SpriteBatch, which can be used to draw textures.
- spriteBatch = new SpriteBatch(GraphicsDevice);
- texture = Content.Load<Texture2D>("Placeholder");
- quadEffect = new BasicEffect(graphics.GraphicsDevice);
- quadEffect2 = new BasicEffect(graphics.GraphicsDevice);
- //quadEffect.EnableDefaultLighting();
- quadEffect.World = Matrix.Identity;
- quadEffect.View = View;
- quadEffect.Projection = Projection;
- quadEffect.TextureEnabled = true;
- quadEffect.Texture = texture;
- quadEffect2.World = Matrix.Identity;
- quadEffect2.View = View;
- quadEffect2.Projection = Projection;
- quadEffect2.TextureEnabled = true;
- quadEffect2.Texture = texture;
- vertexDeclaration = new VertexDeclaration(new VertexElement[]
- {
- new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
- new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
- new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
- });
- }
- /// <summary>
- /// UnloadContent will be called once per game and is the place to unload
- /// game-specific content.
- /// </summary>
- protected override void UnloadContent()
- {
- // TODO: Unload any non ContentManager content here
- }
- /// <summary>
- /// Allows the game to run logic such as updating the world,
- /// checking for collisions, gathering input, and playing audio.
- /// </summary>
- /// <param name="gameTime">Provides a snapshot of timing values.</param>
- protected override void Update(GameTime gameTime)
- {
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
- Exit();
- // TODO: Add your update logic here
- base.Update(gameTime);
- }
- /// <summary>
- /// This is called when the game should draw itself.
- /// </summary>
- /// <param name="gameTime">Provides a snapshot of timing values.</param>
- protected override void Draw(GameTime gameTime)
- {
- GraphicsDevice.Clear(Color.CornflowerBlue);
- foreach (EffectPass pass in quadEffect.CurrentTechnique.Passes)
- {
- pass.Apply();
- GraphicsDevice.DrawUserIndexedPrimitives
- <VertexPositionNormalTexture>(
- PrimitiveType.TriangleList,
- quad2.Vertices, 0, 4,
- quad2.Indexes, 0, 2);
- GraphicsDevice.DrawUserIndexedPrimitives
- <VertexPositionNormalTexture>(
- PrimitiveType.TriangleList,
- quad.Vertices, 0, 4,
- quad.Indexes, 0, 2);
- }
- base.Draw(gameTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement