i find in all books, SetFVF and SetStreamSource is called in render
why not call it before render, then it is called only once
Jump to content
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.
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.