summaryrefslogtreecommitdiffstats
path: root/src/math
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2013-05-11 21:40:09 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2013-05-11 21:40:09 +0200
commitf7f6e10c704585c4652fda359dc225fbb95b6075 (patch)
tree90fb42ed8c766ca37ee383d74afc7167d852ec4f /src/math
parentcc8ed2979b14449f2dcf2b85daa7f13612d1dd00 (diff)
downloadcolobot-f7f6e10c704585c4652fda359dc225fbb95b6075.tar.gz
colobot-f7f6e10c704585c4652fda359dc225fbb95b6075.tar.bz2
colobot-f7f6e10c704585c4652fda359dc225fbb95b6075.zip
Added check and warning about non-power-of-2 textures
Diffstat (limited to 'src/math')
-rw-r--r--src/math/func.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/math/func.h b/src/math/func.h
index 413b5d9..83e8ca4 100644
--- a/src/math/func.h
+++ b/src/math/func.h
@@ -128,6 +128,12 @@ inline float Rand()
return static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
}
+//! Returns whether \a x is an even power of 2
+inline bool IsPowerOfTwo(unsigned int x)
+{
+ return x && !(x & (x - 1));
+}
+
//! Returns the next nearest power of two to \a x
inline int NextPowerOfTwo(int x)
{