# order of FVF flags

This topic is 4545 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I was just posting in this forum about my problems with trying to get a texture-diffuse blending to work. Basically, I wanted to draw my static world geometry, with the output color being a result of a MODULATE between TEXTURE and DIFFUSE arguments. This is basically my pre-calculated per-vertex "lighting" method. I set COLORARG1 to TEXTURE, COLORARG2 to DIFFUSE, and COLOROP to MODULATE. It sort of worked, but not really. My vertices were irregularly shaded, even though they all had identical color values. Also, their uv coords were corrupted (all the v coords were zeroed.) This was the vertex definition I used then:
//here is the FVF define
#define VERTEX_WORLD (D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE )

//here is the vertex structure
struct VERTEXWORLD
{
D3DXVECTOR3 pos;
D3DXVECTOR2 uv;
DWORD color;
};


Then I tried switching to the definition below, and the blending worked perfectly, with no problems at all:
//here is the FVF define
#define VERTEX_WORLD (D3DFVF_XYZ |  D3DFVF_DIFFUSE | D3DFVF_TEX1)

//here is the vertex structure
struct VERTEXWORLD
{
D3DXVECTOR3 pos;
DWORD color;
D3DXVECTOR2 uv;
};


You will note that the only difference is that the structure of the vertex and the vertex definition are slightly rearranged, with color coming before uv coords. So I'm wondering: Are "Flexible Vertex Formats" as flexible as I thought they were? Is there an exact order you have to arrange definitions for vertices to render properly? With my previous definition, it almost seemed as if Direct3d was mixing up the data within the vertices, explaining the weird coloring and the messed up uv coords. Most importantly: Can I be sure that I've found the universal "correct" way to define my world vertices? Can I be sure that some other person's DirectX will recognize it incorrectly in the same way my DirectX misread my first vertex definition? Thanks for your help! -synth_cat

##### Share on other sites
The order of the bitflags doesn't matter...as they are bitflags.

It's the order in the structure that makes a difference, with D3D it specifies the order in which certain elements must appear in the structure.

http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dx8_c/directx_cpp/graphics_using_6b78.asp

Paul

##### Share on other sites
The FVF flags are just numbered ORed together.

Lets say XYZ = 1, Normal = 2, and UV = 4.

XYZ | Normal | UV = 7
XYZ | UV | Normal = 7

The order of the *flags* doesn't matter. The flags just indicate the presence of an item in the structure. The items in the structure must appear in the correct order. This order. No idea why they stripped this out the recent SDKs.

##### Share on other sites
Well, thanks! I had never heard that there was an order of members that you had to stick to. That link really explained things for me!

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 26
• 10
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
633717
• Total Posts
3013509
×