setMaterialFlag(ETC_FOO) causes undefined behavior

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

setMaterialFlag(ETC_FOO) causes undefined behavior

Post by hendu »

Bool is only guaranteed to be one bit long. So passing any of the texture clamping values through that turns them all to 0 or 1 on some platforms. Not what was intended, with CLAMP clamping to border color.

This bug should be fixed by changing the parameter to an u32 from bool, in SMaterial.setFlag and all its wrappers.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: setMaterialFlag(ETC_FOO) causes undefined behavior

Post by hybrid »

The set function should work properly in all cases - as the function always maps false to the "OFF" enum and all other values to one distinct value chosen from all possible values. We should probably add an overloaded function which works for all enum values as expected, though. However, this would break backward compatibility. So we will probably have to invent a new name :-(
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: setMaterialFlag(ETC_FOO) causes undefined behavior

Post by hendu »

The ETC texture clamp flags are cast, it's not an ON/OFF case. So if you do setMaterialFlag(ETC_CLAMP_TO_EDGE), it actually gets set to ETC_CLAMP.
Post Reply