On 29/10/09 10:55 PM, Paul Martz wrote:
Hi Robert -- The code submission by Wojciech and I for MSFBO has opened
a small can of worms on declaring bits and bitmasks. I hope you can
weigh in and put an end to the debate.

Originally, my submission followed the Optimizer's OptimizationOptions
pattern of declaring bit values in an enum, but declaring the bitmask
variable as an unsigned int.

In Wojciech's modified submission, he changed the bitmask variable to a
signed int, with the reasoning that enum values are also signed ints,
and this eliminates the need for a typecast to get rid of compiler
warnings.

This caused me to weigh in with the workaround of declaring the bit
values as static const unsigned int, and keeping the bitmask unsigned.
But this goes against the OSG precedent set with the Optimizer.

Just to add more confusion (and yet-another-solution):

StateAttribute defines 'enum Values { OFF, ON, PROTECT, OVERRIDE }' but also defines 'typedef unsigned int GLModeValues'.

StateSet::setAttributeAndModes accepts an argument of GLModeValues which is supposed to contain bitwise-ored StateAttribute::Values.

As I remember there was never any controversy about doing it this way, although this isn't necessarily what you would like it to be (but C++ enums are broken in that respect).

Cheers,
/ulrich

PS: AFAIK StateSet/StateAttribute predate Optimizer ;-)
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to