SetVertexShader...

Started by
1 comment, last by mrmrcoleman 19 years, 3 months ago
Has the meaning of set vertex shader changed between DirectX8 and DirectX9? I have some sample code which uses DirectX8 that seems to supply to SetVertexShader an FVF declaration. I thought that SetFVF would have been used? Here is the code:

g_pd3dDevice->SetVertexShader(Vertex::FVF_Flags);

// Vertex definition
struct Vertex
{
     FLOAT x, y, z;
     FLOAT tu, tv;

     enum FVF
     {
          FVF_Flags = D3DFVF_XYZ | D3DFVF_TEX1
     }
};

Thanks for any help guys. Mark Coleman
Advertisement
Yes, it has changed.

In DX8 vertex shaders were referred to by a HANDLE value, which is what you passed to SetVertexShader(). As it was simply numerical D3D obviously had some way of figuring out if you passed it a shader handle or just an FVF code, which was also legal.

As of DX9 verex shaders are interface classes of their own, so SetVertexShader() takes a class pointer as it's parameter, thus no longer accepting FVF codes. To set an FVF code you have to now do this:

device->SetVertexShader(NULL);
device->SetFVF(fvfCode);

Which will then use the fixed function pipeline.

EDIT: as for you wondering why SetFVF() wouldn't have been used - well, it wasn't around in the days of DX8, it was introduced with DX9.

-Mezz
Thanks Mezz, everything seems much clearer now!!

Regards.

Mark Coleman

This topic is closed to new replies.

Advertisement