Jump to content
  • Advertisement
Sign in to follow this  
Grizwald

Vertex FVF classes... static members?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, if I create a series of classes for my vertex data, like Simplevertex, VertexTextureColorNormal etc, would I be able to place a static variable in the class with the value for the FVF?
struct SimpleVertex
{
   static long FVF = fvf values;
   float x,y,z;
   float nx,ny,nz;
   float r,g,b,a;
};
or does that screw up the data during buffering? It would be really nice to just use SimpleVertex::FVF where I needed the FVF for the class.

Share this post


Link to post
Share on other sites
Advertisement
You will be OK doing that.
I would stick to the SDK data type for an FVF though, which is DWORD (AFAIK unsigned long).

***edit***
The static FVF is OK but the rest of your vertex structure looks wrong.

float x, y, z is ok for the vertex position.
float nx, ny, nz is ok for the normal.

not sure about the color data though (r,g, b, a) as floats.
I think the color data type should be D3DCOLOR (DWORD)

Also I think the ordering of the (non static) structure members should be different.

Try this:

struct SimpleVertex
{
float x, y, z; // position
D3DCOLOR diffuse; // diffuse color
float nx, ny, nz; // normal
static DWORD FVF;
};

DWORD SimpleVertex::FVF = D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_NORMAL;

Also you can set the r, g, b, a values for the color using the D3DCOLOR_RGBA macro:

v.diffuse = D3DCOLOR_RGBA(r,g,b,a);

r, g, b,a values here should be between 0 and 255.

HTH,
Cambo_frog

[Edited by - Cambo_frog on July 30, 2005 3:07:53 PM]

Share this post


Link to post
Share on other sites
I wasn't so much concerned with the datatypes, because I still have to look those up for every vertex definition. But thanks anyways!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!