[SDL] IMG_Load and SDL_Surface flags

Alberto Luaces aluaces at udc.es
Fri Dec 21 04:32:58 PST 2007


El Friday 21 December 2007 13:15:59 Torsten Giebl escribió:
> > Why? Those SDL_ flags always have only one bit set. Isn't it the usual
> > way of implementing it? Otherwise it could exist clashes between flags.
>
> In which case ?

If you had three features:

1001 A
0010 B
0001 C

and the bitfield where "1001", the following test would be incorrect:

if( bitfield & C) /* (bitfield & C) == C would also fail */
	printf( "we have C!"); /*No, we had A instead*/

because there are common bits between A and C.

All the code I've seen until today relies on the flags not having any bit in 
common, that is, being powers of 2. However it seems that SDL doesn't work 
this way, because those flag definitions are written in terms of 0x1, 0x2, 
0x4 and 0xA, the last instead of 0x8. I'm a bit confused why it has been done 
so.

Any thoughts?


More information about the SDL mailing list