From 61bfb22f27f5216f989c023a5e39fad7e356d2d6 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Fri, 3 Aug 2012 23:23:13 +0200 Subject: Basic font rendering - added basic font rendering - minor refactoring & fixes --- src/math/func.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/math/func.h') 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(rand()) / static_cast(RAND_MAX); } +//! Returns the next nearest power of two to \a x +inline int NextPowerOfTwo(int x) +{ + double logbase2 = log(static_cast(x)) / Math::LOG_2; + return static_cast(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) { -- cgit v1.2.3-1-g7c22