2011-10-31 05:36:24 +00:00
|
|
|
#region Using Statements
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using ANX.Framework;
|
|
|
|
using ANX.Framework.Graphics;
|
|
|
|
using ANX.Framework.Input;
|
2011-12-12 08:38:31 +00:00
|
|
|
using ANX.Framework.NonXNA;
|
2011-10-31 05:36:24 +00:00
|
|
|
|
|
|
|
#endregion // Using Statements
|
|
|
|
|
2012-08-09 09:45:04 +00:00
|
|
|
// This file is part of the ANX.Framework created by the
|
|
|
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
|
|
|
// For details see: http://anxframework.codeplex.com/license
|
2011-10-31 05:36:24 +00:00
|
|
|
|
|
|
|
namespace VertexIndexBuffer
|
|
|
|
{
|
|
|
|
public class Game1 : ANX.Framework.Game
|
|
|
|
{
|
|
|
|
GraphicsDeviceManager graphics;
|
|
|
|
SpriteBatch spriteBatch;
|
|
|
|
|
|
|
|
Effect miniTriEffect;
|
|
|
|
VertexBuffer vb;
|
|
|
|
VertexBuffer vb2;
|
|
|
|
IndexBuffer ib;
|
|
|
|
|
|
|
|
public Game1()
|
|
|
|
{
|
|
|
|
graphics = new GraphicsDeviceManager(this);
|
|
|
|
Content.RootDirectory = "SampleContent";
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Initialize()
|
|
|
|
{
|
|
|
|
base.Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadContent()
|
|
|
|
{
|
|
|
|
spriteBatch = new SpriteBatch(GraphicsDevice);
|
|
|
|
|
|
|
|
miniTriEffect = Content.Load<Effect>(@"Effects/MiniTri");
|
|
|
|
|
|
|
|
vb = new VertexBuffer(GraphicsDevice, VertexPositionColor.VertexDeclaration, 6, BufferUsage.None);
|
|
|
|
VertexPositionColor[] vertices = new[] { new VertexPositionColor( new Vector3(-0.75f, 0.25f, 0.5f), new Color(1.0f, 0.0f, 0.0f, 1.0f)),
|
|
|
|
new VertexPositionColor( new Vector3(-0.25f, 0.25f, 0.5f), new Color(0.0f, 1.0f, 0.0f, 1.0f)),
|
|
|
|
new VertexPositionColor( new Vector3(-0.75f, -0.25f, 0.5f), new Color(0.0f, 0.0f, 1.0f, 1.0f)),
|
|
|
|
|
|
|
|
new VertexPositionColor( new Vector3(-0.25f, 0.25f, 0.5f), new Color(0.0f, 1.0f, 0.0f, 1.0f)),
|
|
|
|
new VertexPositionColor( new Vector3(-0.25f, -0.25f, 0.5f), new Color(1.0f, 0.0f, 0.0f, 1.0f)),
|
|
|
|
new VertexPositionColor( new Vector3(-0.75f, -0.25f, 0.5f), new Color(0.0f, 0.0f, 1.0f, 1.0f)),
|
|
|
|
};
|
|
|
|
vb.SetData<VertexPositionColor>(vertices);
|
|
|
|
|
|
|
|
vb2 = new VertexBuffer(GraphicsDevice, VertexPositionColor.VertexDeclaration, 4, BufferUsage.None);
|
|
|
|
VertexPositionColor[] vertices2 = new[] { new VertexPositionColor( new Vector3(0.25f, 0.25f, 0.5f), new Color(1.0f, 0.0f, 0.0f, 1.0f)),
|
|
|
|
new VertexPositionColor( new Vector3(0.75f, 0.25f, 0.5f), new Color(0.0f, 1.0f, 0.0f, 1.0f)),
|
|
|
|
new VertexPositionColor( new Vector3(0.25f, -0.25f, 0.5f), new Color(0.0f, 0.0f, 1.0f, 1.0f)),
|
|
|
|
new VertexPositionColor( new Vector3(0.75f, -0.25f, 0.5f), new Color(1.0f, 0.0f, 0.0f, 1.0f)),
|
|
|
|
};
|
|
|
|
vb2.SetData<VertexPositionColor>(vertices2);
|
|
|
|
|
|
|
|
ib = new IndexBuffer(GraphicsDevice, IndexElementSize.ThirtyTwoBits, 6, BufferUsage.None);
|
|
|
|
int[] indices = new[] { 0, 1, 2, 1, 3, 2 };
|
|
|
|
ib.SetData<int>(indices);
|
2011-12-09 08:46:25 +00:00
|
|
|
|
|
|
|
graphics.PreferredBackBufferWidth = 810;
|
|
|
|
graphics.PreferredBackBufferHeight = 486;
|
|
|
|
graphics.PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8;
|
|
|
|
graphics.ApplyChanges();
|
2011-10-31 05:36:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update(GameTime gameTime)
|
|
|
|
{
|
|
|
|
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
|
|
|
|
this.Exit();
|
|
|
|
|
|
|
|
base.Update(gameTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Draw(GameTime gameTime)
|
|
|
|
{
|
2011-12-04 08:10:48 +00:00
|
|
|
GraphicsDevice.Clear(Color.CornflowerBlue);
|
2011-10-31 05:36:24 +00:00
|
|
|
|
2011-11-22 14:51:30 +00:00
|
|
|
miniTriEffect.CurrentTechnique.Passes[0].Apply();
|
|
|
|
|
2011-10-31 05:36:24 +00:00
|
|
|
GraphicsDevice.SetVertexBuffer(vb);
|
|
|
|
GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 6);
|
|
|
|
|
|
|
|
GraphicsDevice.SetVertexBuffer(vb2);
|
|
|
|
GraphicsDevice.Indices = ib;
|
|
|
|
GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2);
|
|
|
|
|
|
|
|
base.Draw(gameTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|