2017-01-09 4 views
0

私は緑色の三角形を描こうとしています。私は三角形を描くことができましたが、緑の代わりに白です。誰かがこれを引き起こしている考えを持っていますか?なぜ私の三角形は白ですか?

protected override void LoadContent() 
    { 
     _vertexPositionColors = new[] 
{ 
    new VertexPositionColor(new Vector3(0, 0, 0), Color.Green), 
    new VertexPositionColor(new Vector3(100, 0, 0), Color.Red), 
    new VertexPositionColor(new Vector3(100, 100, 0), Color.Blue) 
}; 
     _basicEffect = new BasicEffect(GraphicsDevice); 
     _basicEffect.World = Matrix.CreateOrthographicOffCenter(
      0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 0, 1); 
     _basicEffect.LightingEnabled = false; 
     _basicEffect.VertexColorEnabled = true; 
    } 

protected override void Draw(GameTime gameTime) 
    { 
     GraphicsDevice.Clear(Color.CornflowerBlue); 

     EffectTechnique effectTechnique = _basicEffect.Techniques[0]; 
     EffectPassCollection effectPassCollection = effectTechnique.Passes; 
     foreach (EffectPass pass in effectPassCollection) 
     { 
      pass.Apply(); 
      GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, _vertexPositionColors, 0, 1); 
     } 
     base.Draw(gameTime); 
    } 

答えて

1

問題は、あなたのドローである:

は、ここに私のコードです。現在のテクニックを適用するだけで、すべてのテクニックを適用します。次のことが私のために働いた:

protected override void Draw(GameTime gameTime) 
{ 
    GraphicsDevice.Clear(Color.CornflowerBlue); 
    _basicEffect.CurrentTechnique.Passes[0].Apply(); 
    GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, _vertexPositionColors, 0, 1); 
    base.Draw(gameTime); 
} 
+0

それを修正しました。ありがとう – Wipie44

関連する問題