non-FVF VertexBuffer

How to create Mesh with non-FVF VertexBuffer (Managed DirectX)
I tried to specify declaration but Mesh has FVF VertexBuffer after creation:

Microsoft.DirectX.Direct3D.VertexElement[] elements = new Microsoft.DirectX.Direct3D.VertexElement[] {
new Microsoft.DirectX.Direct3D.VertexElement(0, 0, Microsoft.DirectX.Direct3D.DeclarationType.Float3, Microsoft.DirectX.Direct3D.DeclarationMethod.Default, Microsoft.DirectX.Direct3D.DeclarationUsage.Position, 0),
new Microsoft.DirectX.Direct3D.VertexElement(0, 12, Microsoft.DirectX.Direct3D.DeclarationType.Float3, Microsoft.DirectX.Direct3D.DeclarationMethod.Default, Microsoft.DirectX.Direct3D.DeclarationUsage.Normal, 0),
new Microsoft.DirectX.Direct3D.VertexElement(0, 24, Microsoft.DirectX.Direct3D.DeclarationType.Float2, Microsoft.DirectX.Direct3D.DeclarationMethod.Default, Microsoft.DirectX.Direct3D.DeclarationUsage.TextureCoordinate, 0),
Microsoft.DirectX.Direct3D.VertexElement.VertexDeclarationEnd };

dxDevice.VertexDeclaration = new Microsoft.DirectX.Direct3D.VertexDeclaration(dxDevice, elements);
dxDevice.VertexFormat = Microsoft.DirectX.Direct3D.VertexFormats.None;

dxMesh = new Microsoft.DirectX.Direct3D.Mesh(dxDevice, d3dfile.TotalFaces, d3dfile.Vertices.Count,Microsoft.DirectX.Direct3D.MeshFlags.Managed, elements);



Answer this question

non-FVF VertexBuffer

  • Sorean

    The vertex declaration you are specifying just so happens to be identical to the FVF that you showed. Vertex declarations and FVF's are just two different ways to specify vertex layout, and if they are compatible you will see the FVF set to the equivalent to your decl. Think of it as two different API's setting (and getting) the same state.

    As Ralf mentioned, there is no need to set the layout to the device when you create the mesh. In fact, when you render with the mesh, it sets the vertex layout that is associated with the mesh.

    So, to answer your question, how do you create a mesh with a non-FVF vertex buffer, well, specify a vertex declaratoin that doesn't map to an FVF. But there's no point in doing so just for the sake of trying to make it incompatible.



  • santanu

    Anyway i'll get FVF vertexbuffer, i'm using DirectX analyze tools and it shows:

    FVF = D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1

    but must be:


    FVF = NULL


  • Wagepeace007

    The mesh class does not care about the format that is set to device during creation. Because of this you don’t need to set a vertex declaration or vertex format before you create a mesh. As I side not you should never set both because a vertex format will override your vertex declaration and this happens the other way, too.

    Your code looks right for me but as you use Managed DX 2 it is possible that you have find a bug. Which version of the SDK you are using



  • djenerate

    April 2006
  • Jon500

    Iirc, you don't need to set the vertex formats, simply setting the declaration will do the job just fine.

  • non-FVF VertexBuffer