WineD3D: better pixelformat selection code
hverbeet at gmail.com
Thu Aug 9 02:23:34 CDT 2007
On 09/08/07, Roderick Colenbrander <thunderbird2k at gmx.net> wrote:
> This code lets WineD3D use the pixelformat of the D3D device. The code helps
> on Windows where OpenGL offers multiple pixelformats.
The stencil column is probably useful for determining if we need an
stencil attachment for FBOs as well.
>+int count_bits(int mask)
>+ int i, count=0;
>+ for(i=0; i<32; i++)
>+ if(mask & (1<<i))
>+ return count;
The "classical" way to do that would be something like this:
unsigned int count_bits(unsigned int mask)
unsigned int count;
for (count = 0; mask; ++count)
mask &= mask - 1;
Ie, simply mask out the set bits one by one until none are set, rather
than looping over all of them.
More information about the wine-devel