Sign in to follow this  
Eddie Zehoo

Vertex Declaration and SetFVF

Recommended Posts

Hi, I'm having problems with FVF. It seems that if I have RHW enabled, the following works, and there's no problem : lp_3DDevice->SetVertexShader(NULL); lp_3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); But once I turn RHW off, I get this message in VisualC++'s debug window : "Direct3D9: (ERROR) :Current vertex shader declaration doesn't match VB's FVF" I am very sure my Vertex structs and flags have all been defined appropriately.Any idea, anyone? Thx! Regards, Ed Zehoo

Share this post


Link to post
Share on other sites
Hi Daedalus,
Thanks for posting! .. but I fixed it already. It was due to SetFVF not being in the Render loop.. I called it only once during Initialization. Geez, MSDN never said anything about SetFVF having to be in the Render loop.... another day wasted.

but thanks anyway!
Regards,
Ed Zehoo

Share this post


Link to post
Share on other sites
SetFVF does not have to be in the render loop. You can set it at the beginning of the application and never set it again. But you have to make sure you're not setting anything else that can clobber you FVF declaration. if you are using SetVertesxShader after that, then that effectively invalidates your SetFVF call. Or if you lose the device your FVF call is invalidated as well.

Share this post


Link to post
Share on other sites
Hi IFoobar,
I've checked through my Render function again, but I can't see anything which would clobber the SetFVF call. Here's my Render function below :
(Could it be the D3DXFont object - lp_FontObj) ?

Thx!

void ML_GAMEAPP::Render()
{
lp_Direct3DDevice->BeginScene ();
//Print out the FPS Text
if (lp_FontObj!=NULL) lp_FontObj->Begin();
if (lp_FontObj!=NULL) lp_FontObj->DrawTextA((LPCSTR)strTextBuffer,-1,&rctFontRect,DT_LEFT,0xFFBBBBBB);
if (lp_FontObj!=NULL) lp_FontObj->End();
//Draw the quad
lp_3DDevice->SetTexture (0,lp_TextureToLoad);
lp_3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2);
lp_Direct3DDevice->EndScene ();
lp_Direct3DDevice->Present(NULL,NULL,NULL,NULL);
UpdateFPS();
}


void ML_GAMEAPP::UpdateFPS()
{
lngFramesElapsed++;
float fltCurrentUpdate = GetGameTime();
if( fltCurrentUpdate - fltLastUpdate > fltUpdateInterval )
{
fltFPS = lngFramesElapsed / (fltCurrentUpdate - fltLastUpdate);
fltLastUpdate = fltCurrentUpdate;
lngFramesElapsed = 0;
}
sprintf(strTextBuffer,"FPS : %.2f",fltFPS);
}

Share this post


Link to post
Share on other sites
Might be the font, try doing the font stuff after you render and if it works then it was definetly the font. Though the font uses state blocks if im not mistaken and restores the previous state block on the End() call. But I dunno, give it a try...

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