2017-01-09 3 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

관련 문제