On 09/08/07, Roderick Colenbrander <[EMAIL PROTECTED]> wrote: > Hi, > > 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)) >+ count++; >+ } >+ 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; } return count; } Ie, simply mask out the set bits one by one until none are set, rather than looping over all of them.