diff options
Diffstat (limited to 'Source/ThirdParty/ANGLE/src/libGLESv2/mathutil.h')
-rw-r--r-- | Source/ThirdParty/ANGLE/src/libGLESv2/mathutil.h | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/mathutil.h b/Source/ThirdParty/ANGLE/src/libGLESv2/mathutil.h index 31fa16f..7ca2d9f 100644 --- a/Source/ThirdParty/ANGLE/src/libGLESv2/mathutil.h +++ b/Source/ThirdParty/ANGLE/src/libGLESv2/mathutil.h @@ -9,7 +9,9 @@ #ifndef LIBGLESV2_MATHUTIL_H_ #define LIBGLESV2_MATHUTIL_H_ +#include <intrin.h> #include <math.h> +#include <windows.h> namespace gl { @@ -38,9 +40,15 @@ inline unsigned int ceilPow2(unsigned int x) return x; } +template<typename T, typename MIN, typename MAX> +inline T clamp(T x, MIN min, MAX max) +{ + return x < min ? min : (x > max ? max : x); +} + inline float clamp01(float x) { - return x < 0 ? 0 : (x > 1 ? 1 : x); + return clamp(x, 0.0f, 1.0f); } template<const int n> @@ -61,6 +69,51 @@ inline unsigned int unorm(float x) return (unsigned int)(max * x + 0.5f); } } + +inline RECT transformPixelRect(GLint x, GLint y, GLint w, GLint h, GLint surfaceHeight) +{ + RECT rect = {x, + surfaceHeight - y - h, + x + w, + surfaceHeight - y}; + return rect; +} + +inline int transformPixelYOffset(GLint yoffset, GLint h, GLint surfaceHeight) +{ + return surfaceHeight - yoffset - h; +} + +inline GLenum adjustWinding(GLenum winding) +{ + ASSERT(winding == GL_CW || winding == GL_CCW); + return winding == GL_CW ? GL_CCW : GL_CW; +} + +inline bool supportsSSE2() +{ + static bool checked = false; + static bool supports = false; + + if (checked) + { + return supports; + } + + int info[4]; + __cpuid(info, 0); + + if (info[0] >= 1) + { + __cpuid(info, 1); + + supports = (info[3] >> 26) & 1; + } + + checked = true; + + return supports; +} } #endif // LIBGLESV2_MATHUTIL_H_ |