summaryrefslogtreecommitdiffstats
path: root/src/math/func.h
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-08-03 23:23:13 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-08-03 23:23:13 +0200
commit61bfb22f27f5216f989c023a5e39fad7e356d2d6 (patch)
tree9d7a8a760ace272739f651a2f4208326731a6fe7 /src/math/func.h
parent5e637ca0288ddd631ec33e1d620cd4a73bcdc2be (diff)
downloadcolobot-61bfb22f27f5216f989c023a5e39fad7e356d2d6.tar.gz
colobot-61bfb22f27f5216f989c023a5e39fad7e356d2d6.tar.bz2
colobot-61bfb22f27f5216f989c023a5e39fad7e356d2d6.zip
Basic font rendering
- added basic font rendering - minor refactoring & fixes
Diffstat (limited to 'src/math/func.h')
-rw-r--r--src/math/func.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/math/func.h b/src/math/func.h
index 2127d1a..e97d990 100644
--- a/src/math/func.h
+++ b/src/math/func.h
@@ -127,6 +127,14 @@ inline float Rand()
return static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
}
+//! Returns the next nearest power of two to \a x
+inline int NextPowerOfTwo(int x)
+{
+ double logbase2 = log(static_cast<float>(x)) / Math::LOG_2;
+ return static_cast<int>(pow(2, ceil(logbase2)) + 0.5);
+}
+
+
//! Returns a normalized angle, that is in other words between 0 and 2 * PI
inline float NormAngle(float angle)
{