• FEATURED
• FEATURED
• FEATURED
• FEATURED
• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# where can i find the D3DFVF format

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

21 replies to this topic

### #1tcige  Members

Posted 10 April 2013 - 06:00 AM

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?

### #2NightCreature83  Members

Posted 10 April 2013 - 06:35 AM

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.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max

### #3tcige  Members

Posted 10 April 2013 - 07:14 AM

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

### #4NightCreature83  Members

Posted 10 April 2013 - 08:00 AM

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, 10 April 2013 - 08:46 AM.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max

### #5tcige  Members

Posted 10 April 2013 - 08:28 AM

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

### #6NightCreature83  Members

Posted 10 April 2013 - 08:34 AM

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, 10 April 2013 - 08:51 AM.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max

### #7Tom KQT  Members

Posted 10 April 2013 - 08:39 AM

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, 10 April 2013 - 08:40 AM.

### #8Norman Barrows  Members

Posted 10 April 2013 - 09:17 AM

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, 10 April 2013 - 09:21 AM.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

### #9tcige  Members

Posted 10 April 2013 - 09:33 AM

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

### #10tcige  Members

Posted 10 April 2013 - 09:34 AM

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

### #11tcige  Members

Posted 10 April 2013 - 09:38 AM

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

### #12Norman Barrows  Members

Posted 10 April 2013 - 09:40 AM

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.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

### #13Norman Barrows  Members

Posted 10 April 2013 - 09:45 AM

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.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

### #14NightCreature83  Members

Posted 10 April 2013 - 09:47 AM

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.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max

### #15tcige  Members

Posted 10 April 2013 - 09:53 AM

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

### #16tcige  Members

Posted 10 April 2013 - 09:54 AM

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

### #17Norman Barrows  Members

Posted 10 April 2013 - 10:03 AM

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)

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

### #18Norman Barrows  Members

Posted 10 April 2013 - 10:13 AM

> 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, 10 April 2013 - 10:13 AM.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

### #19NightCreature83  Members

Posted 10 April 2013 - 10:13 AM

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.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max

### #20Norman Barrows  Members

Posted 10 April 2013 - 10:41 AM

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.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.