[IronPython] XNA and how to specify the type arguments explicitly

Curt Hagenlocher curt at hagenlocher.org
Tue Feb 2 17:18:49 CET 2010


You should template on VertexPositionColor, not on VertexPositionColor[].

The reason for the error message is that you're saying T is
VertexPositionColor[]. An array is a reference type, while the template
constraint specifies a value type.
On Tue, Feb 2, 2010 at 7:51 AM, Richard Steventon <steventon at gmail.com>wrote:

> Okay, so problem #2.... calling the correct version of the interface
> (I think this is the problem?), since I am getting a "violates the
> constraint of type 'T'" error.
>
> I set up a XNA VertexBuffer using:
>        l = Array.CreateInstance(VertexPositionColor,6)
>        .....
>        self.vertices = l
>
> Then:
>        self.VertexBuffer = VertexBuffer(self.graphics.GraphicsDevice, \
>            len(self.vertices) * VertexPositionColor.SizeInBytes, \
>            BufferUsage.WriteOnly)
>        self.VertexBuffer.SetData[Array[VertexPositionColor]](self.vertices)
>
> And I get:
> ValueError: GenericArguments[0],
> 'Microsoft.Xna.Framework.Graphics.VertexPositionColor[]', on 'Void
> SetData[T](Int32, T[], Int32, Int32, Int32)' violates the constraint
> of type 'T'.
>
> The documentation for the VertexBuffer.SetData method can be found here:
>
> http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.vertexbuffer.setdata.aspx
>
> The methods are:
>  VertexBuffer.SetData (Int32, T[], Int32, Int32, Int32)
>  VertexBuffer.SetData (T[])
>  VertexBuffer.SetData (T[], Int32, Int32)
>
> This works fine in C# with a List of VertexPositionColor objects, so I
> assume that Array in IronPython is the equivalent ?  So why does it
> not work ?
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100202/3783a16a/attachment.html>


More information about the Ironpython-users mailing list