Archived

This topic is now archived and is closed to further replies.

directx fvf help

This topic is 5149 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

dunno if this has been asked already, but i did a brief search and couldn''t find anything... i''m not new to 3d programming, but i am sorta new to directx. i''m wondering how flexible the fvf''s are. can i define an fvf with, say, position, normal, and color, and selectively render only the position and normal, or selectively render the position and color. in other words, if i initially build the vertex buffer a certain way, do i have to rebuild the entire thing (so, build another one), if i want to render the same geometry differently. as i''m sure some of u know, with opengl when u specify an array (either position, nromal, texture, etc.) u specify the type of data (float, char, int, etc.) and the stride between consecutive elements. so, u can have your vertices all in one struct (ala directx''s fvf), or u can have seperate buffers for your position, normals, colors, textures, etc. can i get this flexible with directx? thanks for any help

Share this post


Link to post
Share on other sites
You can set up multiple vertex buffers with the info you want in them and then set multiple stream sources based on which vertex buffers you want to use. So, you could have one vertex buffer with position info and another buffer with texture coords. If you want to render with texturing, you would set the first stream source as your position buffer and the second stream source as your texture buffer. To render without textures, you would unset the second stream source.

Check out this topic at MSDN.

edit - The topic is really discussing shaders, but the concepts apply to flexible vertex formats, as well.



[edited by - Dave Hunt on November 13, 2003 1:09:49 PM]

Share this post


Link to post
Share on other sites
You can include data and ignore it, yes.

You can include the normal, but not do lighting.
You can include vertex color, but use material color to render.
You can include texture coordinates but never reference a texture with them.

You cannot choose the data type unless using a vertex shader.
You cannot use multiple streams of data unless using a vertex shader.

When using the fixed pipeline, data must all reside in stream 0. All data must be in the correct order. The data''s stride must match the FVF''s implied stride. Data that is not needed CAN be included and not used.

Share this post


Link to post
Share on other sites
Since you are new to Flexible Vertex Formats (FVF), I will offer you a piece of information that might save hours of debugging. The Vertex Data Structure must be defined in the order outlined in the documentation. The following is a footnote from the SDK Documentation:

quote:

One significant requirement that the system places on how you format your vertices is on the order in which the data appears. The following illustration depicts the required order for all possible vertex components in memory, and their associated data types.




_______________________________________
Understanding is a three edged sword...

Share this post


Link to post
Share on other sites