Mercurial > fife-parpg
comparison engine/core/util/math/fife_math.h @ 620:853d25234671
* Moved the GLEnable and GLDisable structures from opengl_gui_graphics.cpp to fife_opengl.h as they may prove to be useful elsewhere.
* Fixed the color mask definitions in fife_stdint.h
* Added the nextPow2() function to calculate the nearest (greater) power of 2
* Removed a bunch of re-definitions of RGB masks
* Modified GLImage to only generate one "texture chunk". I hope this makes better use of memory and speeds things up a hair
* Made use of the GLEnable structure when clearing the screen
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 30 Sep 2010 21:24:55 +0000 |
parents | 90005975cdbb |
children | 356634098bd9 |
comparison
equal
deleted
inserted
replaced
619:f648bfbae5fe | 620:853d25234671 |
---|---|
23 #define FIFE_UTIL_FIFE_MATH_H | 23 #define FIFE_UTIL_FIFE_MATH_H |
24 | 24 |
25 // Standard C++ library includes | 25 // Standard C++ library includes |
26 #include <cmath> | 26 #include <cmath> |
27 | 27 |
28 // Platform specific includes | 28 // Platform specific includes |
29 | 29 |
30 // 3rd party library includes | 30 // 3rd party library includes |
31 | 31 |
32 // FIFE includes | 32 // FIFE includes |
33 // These includes are split up in two parts, separated by one empty line | 33 // These includes are split up in two parts, separated by one empty line |
36 | 36 |
37 | 37 |
38 // Sort out the missing round function in MSVC: | 38 // Sort out the missing round function in MSVC: |
39 #if defined( WIN32 ) && defined( _MSC_VER ) | 39 #if defined( WIN32 ) && defined( _MSC_VER ) |
40 inline double round(const double x) { | 40 inline double round(const double x) { |
41 return x < 0.0 ? ceil(x - 0.5) : floor(x + 0.5); | 41 return x < 0.0 ? ceil(x - 0.5) : floor(x + 0.5); |
42 } | 42 } |
43 #endif | 43 #endif |
44 | 44 |
45 #ifndef ABS | 45 #ifndef ABS |
46 #define ABS(x) ((x)<0?-(x):(x)) | 46 #define ABS(x) ((x)<0?-(x):(x)) |
50 #ifndef M_PI | 50 #ifndef M_PI |
51 #define M_PI 3.14159265358979323846 | 51 #define M_PI 3.14159265358979323846 |
52 | 52 |
53 #endif | 53 #endif |
54 | 54 |
55 inline unsigned nextPow2(unsigned x) | |
56 { | |
57 --x; | |
58 x |= x >> 1; | |
59 x |= x >> 2; | |
60 x |= x >> 4; | |
61 x |= x >> 8; | |
62 x |= x >> 16; | |
63 return ++x; | |
64 } | |
65 | |
66 | |
55 #endif // FIFE_UTIL_FIFE_MATH_H | 67 #endif // FIFE_UTIL_FIFE_MATH_H |