Simple question about custom FVF's

Started by
3 comments, last by Drakex 18 years, 8 months ago
Hullo hullo, So I've been pouring through all the DirectX tutorials I can find, and one thing that still boggles me about the basics is the way DirectX takes custom FVF's for custom-defined vertices. What seems to happen is that there is a definition of a struct somewhere which includes position, normals, colors, texture coordinates, etc. Then there is an FVF flag #defined to be all of the D3D flags which represent that data OR'd together. So what I'm wondering is this: how does DirectX know in what order the different vertex data is going to come? There's no difference between A | B | C and C | B | A, so how does it work? Are you required to always specifiy the data in a particular order if you're going to use it? I've been scratching my head over this for a while. Thanks much for any help clearing this up. Mike
Advertisement
I think the standard is the following order for the vertex data:

VERTICES
NORMALS
TEXTURE COORDINATES

This is assuming each of these is included in the FVF Definition.
You can get the info by doing this

unsigned short fvf = mesh->GetFVF();int fvfSize = D3DXGetFVFVertexSize(fvf) / sizeof(float);if(fvf & D3DFVF_NORMAL)   // do somethingif(fvf & D3DFVF_TEX1)  // do something




Author Freeworld3Dhttp://www.freeworld3d.org
The DX8 docs had a wonderful diagram showing the layout, but they seem to have removed it in DX9 (guess they want us to use decls instead. bah..). Let me see..

Here it is.



Note that most of the elements are optional; you just have to follow this order.

[smile]

edit: are there image tags for this forum? [img] doesn't work, and I can't find anything in the FAQ about it.

[Edited by - Coder on August 10, 2005 8:29:12 AM]
_______________________________________________________________________Hoo-rah.
Use HTML img tags.

I see. I've never used a forum that allowed HTML before. Thanks!
_______________________________________________________________________Hoo-rah.

This topic is closed to new replies.

Advertisement