66// / @defgroup core_func_common Common functions
77// / @ingroup core
88// /
9- // / Include <glm/ common.hpp> to use these core features.
9+ // / Provides GLSL common functions
1010// /
1111// / These all operate component-wise. The description is per component.
12+ // /
13+ // / Include <glm/common.hpp> to use these core features.
1214
1315#pragma once
1416
15- #include " detail/setup.hpp"
1617#include " detail/qualifier.hpp"
17- #include " detail/type_int.hpp"
1818#include " detail/_fixes.hpp"
1919
2020namespace glm
@@ -28,9 +28,8 @@ namespace glm
2828 // /
2929 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/abs.xml">GLSL abs man page</a>
3030 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
31- // / @see qualifier
3231 template <typename genType>
33- GLM_FUNC_DECL genType abs (genType x);
32+ GLM_FUNC_DECL GLM_CONSTEXPR genType abs (genType x);
3433
3534 // / Returns x if x >= 0; otherwise, it returns -x.
3635 // /
@@ -41,7 +40,7 @@ namespace glm
4140 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/abs.xml">GLSL abs man page</a>
4241 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
4342 template <length_t L, typename T, qualifier Q>
44- GLM_FUNC_DECL vec<L, T, Q> abs (vec<L, T, Q> const & x);
43+ GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> abs (vec<L, T, Q> const & x);
4544
4645 // / Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0.
4746 // /
@@ -52,7 +51,7 @@ namespace glm
5251 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sign.xml">GLSL sign man page</a>
5352 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
5453 template <length_t L, typename T, qualifier Q>
55- GLM_FUNC_DECL vec<L, T, Q> sign (vec<L, T, Q> const & x);
54+ GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> sign (vec<L, T, Q> const & x);
5655
5756 // / Returns a value equal to the nearest integer that is less then or equal to x.
5857 // /
@@ -175,7 +174,7 @@ namespace glm
175174 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/min.xml">GLSL min man page</a>
176175 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
177176 template <typename genType>
178- GLM_FUNC_DECL genType min (genType x, genType y);
177+ GLM_FUNC_DECL GLM_CONSTEXPR genType min (genType x, genType y);
179178
180179 // / Returns y if y < x; otherwise, it returns x.
181180 // /
@@ -186,7 +185,7 @@ namespace glm
186185 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/min.xml">GLSL min man page</a>
187186 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
188187 template <length_t L, typename T, qualifier Q>
189- GLM_FUNC_DECL vec<L, T, Q> min (vec<L, T, Q> const & x, T y);
188+ GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> min (vec<L, T, Q> const & x, T y);
190189
191190 // / Returns y if y < x; otherwise, it returns x.
192191 // /
@@ -197,7 +196,7 @@ namespace glm
197196 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/min.xml">GLSL min man page</a>
198197 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
199198 template <length_t L, typename T, qualifier Q>
200- GLM_FUNC_DECL vec<L, T, Q> min (vec<L, T, Q> const & x, vec<L, T, Q> const & y);
199+ GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> min (vec<L, T, Q> const & x, vec<L, T, Q> const & y);
201200
202201 // / Returns y if x < y; otherwise, it returns x.
203202 // /
@@ -206,7 +205,7 @@ namespace glm
206205 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/max.xml">GLSL max man page</a>
207206 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
208207 template <typename genType>
209- GLM_FUNC_DECL genType max (genType x, genType y);
208+ GLM_FUNC_DECL GLM_CONSTEXPR genType max (genType x, genType y);
210209
211210 // / Returns y if x < y; otherwise, it returns x.
212211 // /
@@ -217,7 +216,7 @@ namespace glm
217216 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/max.xml">GLSL max man page</a>
218217 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
219218 template <length_t L, typename T, qualifier Q>
220- GLM_FUNC_DECL vec<L, T, Q> max (vec<L, T, Q> const & x, T y);
219+ GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> max (vec<L, T, Q> const & x, T y);
221220
222221 // / Returns y if x < y; otherwise, it returns x.
223222 // /
@@ -228,7 +227,7 @@ namespace glm
228227 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/max.xml">GLSL max man page</a>
229228 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
230229 template <length_t L, typename T, qualifier Q>
231- GLM_FUNC_DECL vec<L, T, Q> max (vec<L, T, Q> const & x, vec<L, T, Q> const & y);
230+ GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> max (vec<L, T, Q> const & x, vec<L, T, Q> const & y);
232231
233232 // / Returns min(max(x, minVal), maxVal) for each component in x
234233 // / using the floating-point values minVal and maxVal.
@@ -238,7 +237,7 @@ namespace glm
238237 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/clamp.xml">GLSL clamp man page</a>
239238 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
240239 template <typename genType>
241- GLM_FUNC_DECL genType clamp (genType x, genType minVal, genType maxVal);
240+ GLM_FUNC_DECL GLM_CONSTEXPR genType clamp (genType x, genType minVal, genType maxVal);
242241
243242 // / Returns min(max(x, minVal), maxVal) for each component in x
244243 // / using the floating-point values minVal and maxVal.
@@ -250,7 +249,7 @@ namespace glm
250249 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/clamp.xml">GLSL clamp man page</a>
251250 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
252251 template <length_t L, typename T, qualifier Q>
253- GLM_FUNC_DECL vec<L, T, Q> clamp (vec<L, T, Q> const & x, T minVal, T maxVal);
252+ GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> clamp (vec<L, T, Q> const & x, T minVal, T maxVal);
254253
255254 // / Returns min(max(x, minVal), maxVal) for each component in x
256255 // / using the floating-point values minVal and maxVal.
@@ -262,7 +261,7 @@ namespace glm
262261 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/clamp.xml">GLSL clamp man page</a>
263262 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
264263 template <length_t L, typename T, qualifier Q>
265- GLM_FUNC_DECL vec<L, T, Q> clamp (vec<L, T, Q> const & x, vec<L, T, Q> const & minVal, vec<L, T, Q> const & maxVal);
264+ GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> clamp (vec<L, T, Q> const & x, vec<L, T, Q> const & minVal, vec<L, T, Q> const & maxVal);
266265
267266 // / If genTypeU is a floating scalar or vector:
268267 // / Returns x * (1.0 - a) + y * a, i.e., the linear blend of
@@ -307,13 +306,13 @@ namespace glm
307306 // / glm::vec4 u = glm::mix(g, h, r); // Interpolations can be perform per component with a vector for the last parameter.
308307 // / @endcode
309308 template <typename genTypeT, typename genTypeU>
310- GLM_FUNC_DECL genTypeT mix (genTypeT x, genTypeT y, genTypeU a);
309+ GLM_FUNC_DECL GLM_CONSTEXPR genTypeT mix (genTypeT x, genTypeT y, genTypeU a);
311310
312311 template <length_t L, typename T, typename U, qualifier Q>
313- GLM_FUNC_DECL vec<L, T, Q> mix (vec<L, T, Q> const & x, vec<L, T, Q> const & y, vec<L, U, Q> const & a);
312+ GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> mix (vec<L, T, Q> const & x, vec<L, T, Q> const & y, vec<L, U, Q> const & a);
314313
315314 template <length_t L, typename T, typename U, qualifier Q>
316- GLM_FUNC_DECL vec<L, T, Q> mix (vec<L, T, Q> const & x, vec<L, T, Q> const & y, U a);
315+ GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> mix (vec<L, T, Q> const & x, vec<L, T, Q> const & y, U a);
317316
318317 // / Returns 0.0 if x < edge, otherwise it returns 1.0 for each component of a genType.
319318 // /
@@ -405,7 +404,7 @@ namespace glm
405404 // /
406405 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToInt.xml">GLSL floatBitsToInt man page</a>
407406 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
408- GLM_FUNC_DECL int floatBitsToInt (float const & v);
407+ GLM_FUNC_DECL int floatBitsToInt (float v);
409408
410409 // / Returns a signed integer value representing
411410 // / the encoding of a floating-point value. The floatingpoint
@@ -425,7 +424,7 @@ namespace glm
425424 // /
426425 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToUint.xml">GLSL floatBitsToUint man page</a>
427426 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
428- GLM_FUNC_DECL uint floatBitsToUint (float const & v);
427+ GLM_FUNC_DECL uint floatBitsToUint (float v);
429428
430429 // / Returns a unsigned integer value representing
431430 // / the encoding of a floating-point value. The floatingpoint
@@ -447,7 +446,7 @@ namespace glm
447446 // /
448447 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/intBitsToFloat.xml">GLSL intBitsToFloat man page</a>
449448 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
450- GLM_FUNC_DECL float intBitsToFloat (int const & v);
449+ GLM_FUNC_DECL float intBitsToFloat (int v);
451450
452451 // / Returns a floating-point value corresponding to a signed
453452 // / integer encoding of a floating-point value.
@@ -471,7 +470,7 @@ namespace glm
471470 // /
472471 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/uintBitsToFloat.xml">GLSL uintBitsToFloat man page</a>
473472 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
474- GLM_FUNC_DECL float uintBitsToFloat (uint const & v);
473+ GLM_FUNC_DECL float uintBitsToFloat (uint v);
475474
476475 // / Returns a floating-point value corresponding to a
477476 // / unsigned integer encoding of a floating-point value.
@@ -510,8 +509,11 @@ namespace glm
510509 // /
511510 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/frexp.xml">GLSL frexp man page</a>
512511 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
513- template <typename genType, typename genIType>
514- GLM_FUNC_DECL genType frexp (genType const & x, genIType& exp);
512+ template <typename genType>
513+ GLM_FUNC_DECL genType frexp (genType x, int & exp);
514+
515+ template <length_t L, typename T, qualifier Q>
516+ GLM_FUNC_DECL vec<L, T, Q> frexp (vec<L, T, Q> const & v, vec<L, int , Q>& exp);
515517
516518 // / Builds a floating-point number from x and the
517519 // / corresponding integral exponent of two in exp, returning:
@@ -524,8 +526,11 @@ namespace glm
524526 // /
525527 // / @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/ldexp.xml">GLSL ldexp man page</a>;
526528 // / @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
527- template <typename genType, typename genIType>
528- GLM_FUNC_DECL genType ldexp (genType const & x, genIType const & exp);
529+ template <typename genType>
530+ GLM_FUNC_DECL genType ldexp (genType const & x, int const & exp);
531+
532+ template <length_t L, typename T, qualifier Q>
533+ GLM_FUNC_DECL vec<L, T, Q> ldexp (vec<L, T, Q> const & v, vec<L, int , Q> const & exp);
529534
530535 // / @}
531536}// namespace glm
0 commit comments