I'm stumped. I have been fighting this for about 2 hours now.
Here are the interesting parts of my code:
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
var time = gameTime.TotalGameTime.TotalSeconds;
this.position = new Vector3(
2.0f * (float)Math.Sin(time),
2.0f * (float)Math.Cos(time),
2.0f * (float)Math.Cos(time / 4));
effect.World = Matrix.Identity;
effect.View = Matrix.CreateLookAt(this.position, Vector3.Zero, Up);
effect.Projection = Matrix.CreatePerspectiveFieldOfView(1.5708f, (float)this.Window.ClientBounds.Width / this.Window.ClientBounds.Height, float.Epsilon, 500.0f);
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
var count = this.SetUpVertices() / 3;
this.GraphicsDevice.Clear(ClearOptions.DepthBuffer | ClearOptions.Target, Color.CornflowerBlue, 1.0f, 0);
this.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
this.GraphicsDevice.BlendState = BlendState.Opaque;
this.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
foreach (var pass in this.effect.CurrentTechnique.Passes)
{
pass.Apply();
this.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, count, VertexPositionTexture.VertexDeclaration);
}
base.Draw(gameTime);
}