Original Post
Hi everyone,
I''ve been lurking around this forum for a while and have found it very informative. I am now in need of help on a topic that is rather new and I can''t seem to find info on it anywhere!
I''m prototyping with Managed (C#) DirectX 9.0, and for batching purposes I want to use Device.ProcessVertices(). Whenever I call this function, however, I get a NullReferenceException from Direct3D.dll. Here is the code:
device.VertexFormat = CustomVertex.PositionTextured.Format;
device.SetStreamSource(0, vertices, 0);
device.SetTransform(
TransformType.World,
Matrix.Translation(10, 20, 0));
/*** copied from MSDN documentation on VertexDeclaration: ***/
// Create the vertex element array.
VertexElement[] elements = new VertexElement[]
{
new VertexElement(0, 0, DeclarationType.Float3,
DeclarationMethod.Default,
DeclarationUsage.Position, 0),
VertexElement.VertexDeclarationEnd
};
// Use the vertex element array to create a vertex declaration.
VertexDeclaration decl = new VertexDeclaration((device, elements);
/*** End copy ***/
device.ProcessVertices(
0, 0, 4,
Scene.transformedVB,
decl); // null reference exception here
device.VertexFormat = CustomVertex.TransformedTextured.Format;
device.SetStreamSource(0, transformedVB, 0);
device.DrawPrimitives(
PrimitiveType.TriangleStrip,
0,
2);
I hope someone else has found a way to call ProcessVertices() from managed code. Any help appreciated.
Thanks in advance.