#1 Jimi
Máš špatně pozice .. Tady máš kód tak si to podle toho oprav ;)
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace XNA_Triangle
{
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
VertexPositionColor[] vert;
BasicEffect effect;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
Window.Title = "XNA TRIANGLE";
}
protected override void Initialize()
{
vert = new VertexPositionColor[3];
vert[0] = new VertexPositionColor(new Vector3(0,0,0), Color.Red);
vert[1] = new VertexPositionColor(new Vector3(10,20,0), Color.Green);
vert[2] = new VertexPositionColor(new Vector3(20,0,0), Color.Blue);
effect = new BasicEffect(GraphicsDevice);
effect.VertexColorEnabled = true;
effect.View = Matrix.CreateLookAt(new Vector3(20, 0, 20), new Vector3(10,10,0), Vector3.Up);
effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, GraphicsDevice.DisplayMode.AspectRatio, 1, 1000);
base.Initialize();
}
protected override void LoadContent()
{
}
protected override void UnloadContent()
{
}
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)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
effect.CurrentTechnique.Passes[0].Apply();
GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, vert, 0, 1);
base.Draw(gameTime);
}
}
}