effect and model vertex declaration compatibility

Posted by Vodácek on Game Development See other posts from Game Development or by Vodácek
Published on 2012-06-03T09:24:57Z Indexed on 2012/06/03 10:48 UTC
Read the original article Hit count: 303

Filed under:
|
|
|

I have normal model drawing code. When I try to draw model without UV coordinates I got this exception:

System.InvalidOperationException: The current vertex declaration does not include all
   the elements required by the current vertex shader. TextureCoordinate0 is missing.
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.VerifyCanDraw(
   Boolean bUserPrimitives, Boolean bIndexedPrimitives)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawIndexedPrimitives(
  PrimitiveType primitiveType, Int32 baseVertex, Int32 minVertexIndex,
  Int32 numVertices, Int32 startIndex, Int32 primitiveCount)
at Microsoft.Xna.Framework.Graphics.ModelMeshPart.Draw()
at Microsoft.Xna.Framework.Graphics.ModelMesh.Draw()
...

I know what cause the exception, but is possible to avoid it? Is possible to check model before drawing it with current shader for vertex declaration compatibility?

© Game Development or respective owner

Related posts about XNA

Related posts about c#