po2 scaling for average luminance

This commit is contained in:
glassmancody.info 2023-02-05 12:30:38 -08:00
parent 72efd3a650
commit e778ffee9b
6 changed files with 40 additions and 28 deletions

View file

@ -22,6 +22,23 @@ namespace Misc
return osg::Vec2f(vec.x() * c + vec.y() * -s, vec.x() * s + vec.y() * c);
}
inline bool isPowerOfTwo(int x)
{
return ((x > 0) && ((x & (x - 1)) == 0));
}
inline int nextPowerOfTwo(int v)
{
if (isPowerOfTwo(v))
return v;
int depth = 0;
while (v)
{
v >>= 1;
depth++;
}
return 1 << depth;
}
}
#endif