제 2D XNA 게임에서 삼각형을 그려 보려고했습니다. 튜토리얼 here을 따라 왔습니다.()는 GraphicsDevice.DrawUserPrimitives에서)합니다 (spriteBatch.Draw로 되돌아 갈 때GraphicsDevice.DrawUserPrimitives()를 사용한 후 SpriteBatch.Draw()로 돌아 가기
// Game1.FX is a static instance of Effect
Game1.FX.CurrentTechnique = Game1.FX.Techniques["Pretransformed"];
foreach (EffectPass pass in Game1.FX.CurrentTechnique.Passes)
{
pass.Apply();
Game1.GameInstance.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 1, VertexPositionColor.VertexDeclaration);
}
// Exception is thrown when we go back to spriteBatch.Draw()
spriteBatch.Draw(Textures.Get("Projectiles\\laser01"), new Rectangle((int)compartment.Position.X, (int)compartment.Position.Y,
compartment.CompartmentWeapon.MaxRange, 2), null, laserColour, gunRotation - compartment.CompartmentWeapon.ArcLOS, Vector2.Zero, SpriteEffects.None, 1);
은 내가 System.InvalidOperationException를받을 수 있습니다.
"유효한 정점 버퍼 (및 인덱스 된 프리미티브를 사용하는 경우 유효한 인덱스 버퍼)는 그리기 작업을 수행하기 전에 장치에 설정해야합니다."
왜 이런 일이 일어나고 있는지 지적 해 주시면 감사하겠습니다.