Sign in to follow this  
kiss my grits

Problem creating the FVF macros for the vertex structures

Recommended Posts

kiss my grits    122
Hi, I am trying to create a vertex structure, but I get an error saying, "'|': unexpected in macro formal parameter list" for this code: #define VERTEX_FVF( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 ) After that error, I also get errors for the 'D', then the next '|' and it continues through all of them. The only thing I can think of, is that the program doesn't know where the parameters came from. I thought they were included when linking some of the directx libs, so I found the d3d9types.h file, where they are defined, and I included that file at the top of the page, but it still had the same errors. I'm using VS.NET '03, and I'm still new to it, and how you link files to it. If anyone has experienced this before, or has any idea of what I am doing wrong, please reply. Thanks, Kevin

Share this post


Link to post
Share on other sites
blaze02    100
You need a space between VERTEX_FVF and the paren.

It thinks you are creating a macro that takes parameters:
#define macro(x) (x + 1)

Share this post


Link to post
Share on other sites
3ddreams    142
You can use FVF like follow. Choose which is useful for you. In your example you forget space after VERTEX_FVF. ;)

#define VertexFVF (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1)
//or
const DWORD VertexFVF =(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1);

lpDevice->CreateVertexBuffer( dwNumPolygonIndex*3*sizeof(CUSTOMVERTEX),
0, VertexFVF,D3DPOOL_SYSTEMMEM, &lpVertexBuffer, NULL );

Share this post


Link to post
Share on other sites
ET3D    810
Quote:
Original post by 3ddreams
const DWORD VertexFVF =(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1);

And then you don't need the parenthesis around the FVF terms.

Share this post


Link to post
Share on other sites
Flimflam    665
Quote:
Original post by ET3D
Quote:
Original post by 3ddreams
const DWORD VertexFVF =(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1);

And then you don't need the parenthesis around the FVF terms.


You dont need the Patenthesis, but it makes the code look better in my opinion.

Share this post


Link to post
Share on other sites
Demus79    362

Perhaps it is clearer to place the FVF inside the vertex class/struct

class Vertex
{
public:
vector pos;
vector normal;

enum{
FVF = D3DFVF_XYZ | D3DFVF_NORMAL
};
};

lpDevice->CreateVertexBuffer( dwNumPolygonIndex*3*sizeof(Vertex),
0, Vertex::FVF,D3DPOOL_SYSTEMMEM, &lpVertexBuffer, NULL );


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this