where can i find the D3DFVF format

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

Recommended Posts

there's only float on msdn, but no variable name and what float means, where can i find the detail of all kinds of D3DFVF format

yes, directx books have the info, but how do they get it, did sb reverse the detail format?

Share on other sites

http://msdn.microsoft.com/en-us/library/windows/desktop/bb172559%28v=vs.85%29.aspx

You bitwise or these flags together and feed it to the device when you are rendering that particular vertex buffer. Your are better of learning how to use the programmable pipeline however as most GPU's out there support this now.

Share on other sites

http://msdn.microsoft.com/en-us/library/windows/desktop/bb172559%28v=vs.85%29.aspx

You bitwise or these flags together and feed it to the device when you are rendering that particular vertex buffer. Your are better of learning how to use the programmable pipeline however as most GPU's out there support this now.

i want to know the float variable name and what every float means

Share on other sites

What float variable name, I am not sure I understand your question actually.

Generally you do something like this

struct CustomVertex
{
float x, y, z; //position
float nx, ny, nz; //normal
float u, v; //texture coordinates
};

DWORD CustomVertexFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX0 |
D3DFVF_TEXCOORDSIZE2(0);

Edited by NightCreature83

Share on other sites

What float variable name, I am not sure I understand your question actually.

Generally you do something like this

struct CustomVertex
{
float x, y, z; //position
float nx, ny, nz; //normal
float u, v; //texture coordinates
}

DWORD CustomVertexFVF |= D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX0 |
D3DFVF_TEXCOORDSIZE2(0);


the float variable name is x, y, z in this structure

where does this structure come from, i can not find it on msdn

you know, when i program, i only go msdn

Share on other sites

You have to define this structure yourself, the DX SDK will not define this for you as it wouldn't know what needs you have for your vertex structure. Mesh data is very specific to the project it is being used in and some projects use position, normal, tangent and a couple of texture coordinate sets and others leave out the tangent data and calculate that in the shader.

What goes into the vertex buffer in the end is up to you. I could also have used this as the CustomVertex structure

struct CustomVertexColor
{
float x, y, z; //position
float nx, ny, nz; //normal
DWORD diffuse; //Diffuse color
float u, v; //texture coordinates
};

DWORD CustomVertexFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX0 |
D3DFVF_TEXCOORDSIZE2(0);


The thing is I remember that you need to be careful with the order in the struct and FVF, I haven't used the Fixed Function pipeline in years so this information is a bit hazy.

Using VERTEXELEMENT9 and the D3D11 equivalents of this are far easier to manage as you are literally telling the vertex buffer how it has been laid out and you could potentially put the normal in front of the position if you wanted to.

Edited by NightCreature83

Share on other sites

You create that structure. And you choose what you put there because you (should) know what data you need for each verticle.

For example in tcige's code, his structure says that he wants position of each vertex (x, y, z), normal vector of each vertex (nx, ny, nz) and one set of texture coordinates of each vertex (u, v).

The FVF value must correspond to this, so it this case it is D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX0.

On the msdn page that NightCreature83 linked to, you can see what number and data types of variables does each of the FVF types need, for example "float,float,float" for  D3DFVF_XYZ. So, your structure must contain three float values (names are up to you, something like x, y, z is common).

Of course this is just the definition of the structure of your vertices. Next step is to fill them with actual data. But that's another story.

Edited by Tom KQT

Share on other sites

where can i find the detail of all kinds of D3DFVF format

directx 8 docs.

i've got a copy of the chart you need, but gamedev.net's editor can't paste it into this post, i'll try uploading it to my gallery or journal.

Edited by Norman Barrows

Share on other sites

You have to define this structure yourself, the DX SDK will not define this for you as it wouldn't know what needs you have for your vertex structure. Mesh data is very specific to the project it is being used in and some projects use position, normal, tangent and a couple of texture coordinate sets and others leave out the tangent data and calculate that in the shader.

What goes into the vertex buffer in the end is up to you. I could also have used this as the CustomVertex structure

struct CustomVertexColor
{
float x, y, z; //position
float nx, ny, nz; //normal
DWORD diffuse; //Diffuse color
float u, v; //texture coordinates
};

DWORD CustomVertexFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX0 |
D3DFVF_TEXCOORDSIZE2(0);


The thing is I remember that you need to be careful with the order in the struct and FVF, I haven't used the Fixed Function pipeline in years so this information is a bit hazy.

Using VERTEXELEMENT9 and the D3D11 equivalents of this are far easier to manage as you are literally telling the vertex buffer how it has been laid out and you could potentially put the normal in front of the position if you wanted to.

thanks a lot

i do not mean that, for example, the texture

how can i known what addictional info needs in the structure except xyz

Share on other sites

You create that structure. And you choose what you put there because you (should) know what data you need for each verticle.

For example in tcige's code, his structure says that he wants position of each vertex (x, y, z), normal vector of each vertex (nx, ny, nz) and one set of texture coordinates of each vertex (u, v).

The FVF value must correspond to this, so it this case it is D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX0.

On the msdn page that NightCreature83 linked to, you can see what number and data types of variables does each of the FVF types need, for example "float,float,float" for  D3DFVF_XYZ. So, your structure must contain three float values (names are up to you, something like x, y, z is common).

Of course this is just the definition of the structure of your vertices. Next step is to fill them with actual data. But that's another story.

yeah, why needs u,v for texture, that's what i want to know

Share on other sites

where can i find the detail of all kinds of D3DFVF format

directx 8 docs.

i've got a copy of the chart you need, but gamedev.net's editor can't paste it into this post, i'll try uploading it to my gallery or journal.

thanks for the info

Share on other sites

i posted the chart from the directx8 docs in my gallery:

http://www.gamedev.net/gallery/image/3560-fvfcodes/

lemme check my code, and i'll see if i can explain what's up in my next post. i use fvf too.

Share on other sites

its still out there on a few sites, but that image is all you need out of it. the june 2010 sdk docs cover everything else RE:  fixed function and FVF codes.

if you're just starting out, you might just want to learn the newer way. its forward compatible, FVF is not.

i'll check my code and see if i can explain what's up with fvf's.

Share on other sites

You have to define this structure yourself, the DX SDK will not define this for you as it wouldn't know what needs you have for your vertex structure. Mesh data is very specific to the project it is being used in and some projects use position, normal, tangent and a couple of texture coordinate sets and others leave out the tangent data and calculate that in the shader.

What goes into the vertex buffer in the end is up to you. I could also have used this as the CustomVertex structure

struct CustomVertexColor
{
float x, y, z; //position
float nx, ny, nz; //normal
DWORD diffuse; //Diffuse color
float u, v; //texture coordinates
};

DWORD CustomVertexFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX0 |
D3DFVF_TEXCOORDSIZE2(0);


The thing is I remember that you need to be careful with the order in the struct and FVF, I haven't used the Fixed Function pipeline in years so this information is a bit hazy.

Using VERTEXELEMENT9 and the D3D11 equivalents of this are far easier to manage as you are literally telling the vertex buffer how it has been laid out and you could potentially put the normal in front of the position if you wanted to.

thanks a lot

i do not mean that, for example, the texture

how can i known what addictional info needs in the structure except xyz

That's completely up to you to be honest, but there are a few things that are needed to do certain things, like:

• Wanna do lighting you need to provide a normal
• Wanna do texture mapping you need to provide at least one set of texture coordinates.

This link should give you more information on when to use what in a vertex buffer, it also relates this information to certain features you can turn on in the Fixed Function pipeline in D3D9.

ok I found a link to the order of the structure related to the FVF again: http://p.blog.csdn.net/images/p_blog_csdn_net/yanonsoftware/fvf_order.gif

Again I advice you to start looking at the programmable pipeline instead as the Fixed Function pipeline isn't used anymore in anything but legacy code.

Share on other sites

i posted the chart from the directx8 docs in my gallery:

http://www.gamedev.net/gallery/image/3560-fvfcodes/

lemme check my code, and i'll see if i can explain what's up in my next post. i use fvf too.

the chart is great

maybe the directx 8 header file contains the detail info of every structure

thanks for the info and advise

Share on other sites

You have to define this structure yourself, the DX SDK will not define this for you as it wouldn't know what needs you have for your vertex structure. Mesh data is very specific to the project it is being used in and some projects use position, normal, tangent and a couple of texture coordinate sets and others leave out the tangent data and calculate that in the shader.

What goes into the vertex buffer in the end is up to you. I could also have used this as the CustomVertex structure

struct CustomVertexColor
{
float x, y, z; //position
float nx, ny, nz; //normal
DWORD diffuse; //Diffuse color
float u, v; //texture coordinates
};

DWORD CustomVertexFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX0 |
D3DFVF_TEXCOORDSIZE2(0);


The thing is I remember that you need to be careful with the order in the struct and FVF, I haven't used the Fixed Function pipeline in years so this information is a bit hazy.

Using VERTEXELEMENT9 and the D3D11 equivalents of this are far easier to manage as you are literally telling the vertex buffer how it has been laid out and you could potentially put the normal in front of the position if you wanted to.

thanks a lot

i do not mean that, for example, the texture

how can i known what addictional info needs in the structure except xyz

That's completely up to you to be honest, but there are a few things that are needed to do certain things, like:

• Wanna do lighting you need to provide a normal
• Wanna do texture mapping you need to provide at least one set of texture coordinates.

This link should give you more information on when to use what in a vertex buffer, it also relates this information to certain features you can turn on in the Fixed Function pipeline in D3D9.

ok I found a link to the order of the structure related to the FVF again: http://p.blog.csdn.net/images/p_blog_csdn_net/yanonsoftware/fvf_order.gif

Again I advice you to start looking at the programmable pipeline instead as the Fixed Function pipeline isn't used anymore in anything but legacy code.

thanks for the info and advise

Share on other sites

ok, i'm only using fvf's for a test of drawing dynamically height mapped ground quads, and for drawing meshes.

for the ground quad test, i'm using this vertex format:

const DWORD ZFVF=(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0)  );

struct Zvertexrec
{
float x,y,z;
float nx,ny,nz;
float tu,tv;
DWORD diffuse,specular;
};

so these have position for drawing, normals for lighting, texture coords for texturing, and diffuse and specular lighting components.

but that was just a test.

in my actual code, i just call mesh.getfvf, and then call set_fvf. then i set my vertex and index buffers and call drawprimitive.

the meshes are made in truespace, and use its built-in .x export capability to save them as .x files. the .x files are loaded at program start, and are a convenient way for me to store vertex and index buffers for drawing.

as i recall, their vertex format is x,y,z,normal,u,v.

as i recall, diffuse and specular are only used when you're not texture mapping.

so here's the process:

1. figure out what you need.   xyz, normal, u,v   etc...     xyz normal and uv might be enough for basic texturermapping and lighting.

3. declare your fvf code dword (like my ZFVF above)

4. call set_fvf(myfvf_dword)

Share on other sites

> maybe the directx 8 header file contains the detail info of every structure

dude, you don't get it, there ARE no structures.

you make them yourself, then use fvf codes to tell directx what you put in them.

all the possible combos would be a nightmare to deal with, so microsoft left it up to the user to declare the struct in a certain order, then uses fvf codes to tell directx how to read it.

so there isn't a "xyz,normal,uv" struct in directx at all. or any of the other possible struct declarations you could get from all possible fvf code combos.

you make the struct.  the order in the chart and the fvf codes allow directx to read it correctly.

the fvf codes  define what fields you can include. the docs about the fvf flags tell what they do, but they don't explain about the order of appearance in the struct very well or at all.

i've never checked to see if the flags are listed in the docs in the order that the fields must appear or not.

Edited by Norman Barrows

Share on other sites

That depends on your render states that are setup on the device and on the material settings. If D3DRS_VERTEXCOLOR is set and lighting is also enabled it will use the per vertex color values in this calculation. By default it's set to true.

Share on other sites

That depends on your render states that are setup on the device and on the material settings.

yes, i suspected that material was involved.   when you export just a mesh by itself from truespace with uv and normals only, it does not include lighting in the vertices, so directx just uses the material (i'm pretty sure). i use global materials to control specular and diffuse when drawing scenes.

Share on other sites
The helper function D3DXDeclaratorFromFVF will give you an array of vertex elements (which you can use to create a matching vertex declaration) from any FVF you can think of. These elements tell you the exactly how your struct has to look. For C++ there's also the offsetof macro to check if your offsets really match with your declaration/FVF.

You can also look at the SDK samples (or any other working sample) that still uses FVF to learn how a such a struct looks and works.

As an aside: Without the fixed function pipeline (shaders) you rather go the other way round: You first define your struct and then define a matching vertex declaration (since FVF isn't really, well, flexible).

Share on other sites

The helper function D3DXDeclaratorFromFVF will give you an array of vertex elements (which you can use to create a matching vertex declaration) from any FVF you can think of. These elements tell you the exactly how your struct has to look. For C++ there's also the offsetof macro to check if your offsets really match with your declaration/FVF.

You can also look at the SDK samples (or any other working sample) that still uses FVF to learn how a such a struct looks and works.

As an aside: Without the fixed function pipeline (shaders) you rather go the other way round: You first define your struct and then define a matching vertex declaration (since FVF isn't really, well, flexible).

this function is awesome and really what i want

thanks a lot