Sign in to follow this  
m4gnus

How to know which fvf codes are in a DWORD

Recommended Posts

m4gnus    240
Hi I've got a very simple problem: I'm trying to write a vertex class that holds vertices of all fvfs so i have a detection routine that checks which fvf codes are containend in the DWORD i pass to the function( that should be something direct3D does all the time) atm i do this with if((fvf & <FVF-CODE-TO-CHECK-FOR>)==<FVF-CODE-TO-CHECK-FOR>) and it works well except that this way the check for D3DFVF_TEX0 always returns true :(. D3DFVF_TEX0 has the value 00000000 and i don't know how to check if that fvf-code is contained in a DWORD!? i mean how can i decide if 0001 is (0000 | 0001) or just 0001 ? how does direct3d check for this fvf-code? regards, m4gnus

Share this post


Link to post
Share on other sites
guyaton    130
D3DFVF_TEX0 just means that there is no Texture. If you look at D3DFVF_TEX1 or D3DFVF_TEX2, you will see that they are 0x100 and 0x200 respectively. All you should need to do is this:


DWORD fvf = (D3DFVF_DIFFUSE|D3DFVF_NORMALS|D3DFVF_TEX0);

if( fvf &D3DFVF_TEX0 )
{
//you have no textures
}



This should work no problems.

~guyaton

Share this post


Link to post
Share on other sites
Muhammad Haggag    1358
TEX0 means the vertex contains no texture coordinates. The way to check for that is simple: If you can't find TEX1-8, then it's TEX0.

There are 2 very useful resources to use here:
1) D3DXDeclaratorFromFVF will save you the headache and give you a declaration from an FVF.
2) CrackFVF.cpp by InFramez demonstrates just what you want.

Share this post


Link to post
Share on other sites
guyaton    130
yeah...I forgot bout that [grin] ur idea should work, altho it is a pain to have to check for all the conditions just to find out that there aren't any textures.
~guyaton

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