Jump to content

  • Log In with Google      Sign In   
  • Create Account


why SetFVF is called in every render?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 17 April 2013 - 11:33 PM

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

 

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



Sponsor:

#2 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 18 April 2013 - 02:00 AM

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.



#3 mhagain   Crossbones+   -  Reputation: 7466

Like
2Likes
Like

Posted 18 April 2013 - 02:16 AM

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.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS