Sign in to follow this  

why SetFVF is called in every render?

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

i find in all books, SetFVF and SetStreamSource is called in render

 

why not call it before render, then it is called only once

Share this post


Link to post
Share on other sites

It depends, SetStreamSource() is used to set the vertex data that you want to draw, SetFVF() is used to set the vertex stream declaration.

 

For example: If you are drawing from 10 different vertex buffers and the same vertex declaration you could use SetFVF() once and SetStreamSource() 10 times.

Share this post


Link to post
Share on other sites

In sample code you'll generally see this because the purpose of sample code is to show what needs to be done, not necessarily in the most efficient manner.  Think about it: if you were working from a sample that had omitted a SetFVF call wouldn't you be inclined to omit it too?  What if that call was actually needed?  Would you consider that to be good or bad sample code?

 

In the real world you don't always have the same FVF for everything you're drawing.  A mesh might have a fatter vertex with position, normal, 2 sets of texcoords, maybe some blend weights, etc.  Your 2D GUI may just have position and one set of texcoords.

 

One approach that people do is to wrap the SetFVF call so that if the newly requested FVF is the same as the old one, the SetFVF call can be skipped.  That kind of thing is normally omitted from sample code for the purposes of brevity and clarity but it should be self-evident to anyone reading it.

Share this post


Link to post
Share on other sites

This topic is 1734 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.

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