我遵循教程,但我注意到了这个问题:
GraphicsDevice.RenderState.CullMode = CullMode.None;
GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionColor.VertexElements);
monogame中缺少此代码,我该怎么办? 这是教程的完整代码:
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
GraphicsDevice.RenderState.CullMode = CullMode.None;
GraphicsDevice.VertexDeclaration = new VertexDeclaration(GraphicsDevice, VertexPositionColor.VertexElements);
BasicEffect effect = new BasicEffect(GraphicsDevice, null);
effect.World = Matrix.Identity;
effect.View = camera.viewMatrix;
effect.Projection = camera.projectionMatrix;
effect.VertexColorEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, verts, 0, 2);
pass.End();
}
effect.End();
base.Draw(gameTime);
}
谢谢。
答案 0 :(得分:0)
我想你可能想要使用RasterizerState。我认为RenderState在XNA 4.0中已停止使用。
GraphicsDevice.RasterizerState = RasterizerState.CullNone;
查看此博文:https://blogs.msdn.microsoft.com/shawnhar/2010/04/19/vertex-data-in-xna-game-studio-4-0/
它涵盖了对XNA 4.0中顶点声明的更改