Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In XNA, I have created a new VertexType, called it VertexPositionTextureLight which inherts the IVertexType Interface, but apparently I need to implement the member of VertexDeclartion which I cleary have:

struct VertexPositionTextureLight : IVertexType  {
    Vector3 position;
    Vector2 textureCoordinates;
    float light;

    public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration(new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement(sizeof(float) * 3, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0), new VertexElement(sizeof(float) * 5, VertexElementFormat.Single, VertexElementUsage.TextureCoordinate, 1));

    public VertexPositionTextureLight(Vector3 position, Vector3 normal, Vector2 textureCoordinate, float light)  {
        // TODO: Use normal data
        this.position = position;
        this.textureCoordinates = textureCoordinate;
        this.light = light;

I used to use this struct without inheriting the interface but since I need to call the device.DrawUserIndexedPrimitives that function wants the struct to inherit IVertexType.

share|improve this question
up vote 2 down vote accepted

You should have this line also:

   VertexDeclaration IVertexType.VertexDeclaration
       get { return VertexPositionTextureLight.VertexDeclaration; }

It should work fine after that.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.