First off, does VertexBuffer.SetData<T> "officially" support byte arrays on Windows and XBox 360? For instance, making a call like "vb.SetData<byte>(someByteArray)", where someByteArray is a byte[] object that contains raw vertex data?
I'm running into a situation where this call is not working. On Windows, everything works fine. The byte array is pushed to the graphics card, and rendering is performed properly. On XBox 360, however, something is not working. The model is just not drawing, but there are no thrown exceptions or debug output. (unless there is a way to enable Direct3D debug output from the XBox?). The code is 100% copy-and-paste between the Windows project and the XBox project.
The relevant code is as follows:
System.IO.FileStream modelStream = new System.IO.FileStream("test1.model", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
byte[] mdl = new byte[modelStream.Length];
modelStream.Read(mdl, 0, (int)modelStream.Length);
vb.SetData<byte>(0, mdl, 0, 3*20, 20, SetDataOptions.None);
(I also tried the basic SetData(mdl) call, but this also works on Windows and not XBox.)
test1.model is a binary file that contains 3 vertices of size 20 bytes each (5 floats * 4 bytes/float), with a structure as follows (C++ struct layout):
struct
{
float x, y, z;
float u, v;
}
I'm not seeing any fundamental reason why this should not work. The vertex declaration is set up as follows:
decl = new VertexDeclaration(graphics.GraphicsDevice, new VertexElement[] {
new VertexElement(0, 0, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Position, 0),
new VertexElement(0, 12, VertexElementFormat.Vector2, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 0) });
I know the "proper" way to do things now are to use XNA's mesh formats, but I am porting my C++ engine to XNA and I would really like to be able to keep my model formats without having to write converters to load a byte array into a C# struct vertex format like how the tutorials show SetData<T> being used.
I'm starting to wonder if this is just unsupported usage on XBox, especially since I have not had a problem with this on Windows.