make po2 stuff better

This commit is contained in:
Bill Meltsner
2011-05-15 16:33:38 -04:00
parent af809ab210
commit 2e9e5a1502
3 changed files with 14 additions and 21 deletions
+10
View File
@@ -21,6 +21,8 @@
#ifndef LOVE_MATH_H
#define LOVE_MATH_H
#include <climits> // for CHAR_BIT
/* Definitions of useful mathematical constants
* M_E - e
* M_LOG2E - log2(e)
@@ -64,6 +66,14 @@ struct vertex
float x, y;
float s, t;
};
inline int next_p2(int x)
{
x += (x == 0);
x--;
for (unsigned int i = 1; i < sizeof(int)*CHAR_BIT; i <<= 1) x |= x >> i;
return ++x;
}
} // love