Preprocessor Macros: Difference between revisions

From David's Wiki
Created page with "Some common preprocessor macros ==GLSL== <syntaxhighlight lang="c"> #define PI 3.14159265359 #define PI_2 1.57079632679 </syntaxhighlight>"
 
Line 3: Line 3:
==GLSL==
==GLSL==
<syntaxhighlight lang="c">
<syntaxhighlight lang="c">
#define PI 3.14159265359
#define PI 3.141592653589793
#define PI_2 1.57079632679
#define PI_2 1.5707963267948966
#define DEG2RAD 0.017453292519943295
#define RAD2DEG 57.29577951308232
 
#define sign(x) (int((x) > 0) - int((x) < 0))
#define imin(x, y) (int(x) * int(int(x) < int(y)) + int(y) * int(int(x) >= int(y)))
#define imax(x, y) (int(x) * int(int(x) > int(y)) + int(y) * int(int(x) <= int(y)))
#define iabs(x) ((x) * int((x) >= 0) - (x) * int((x) < 0))
</syntaxhighlight>
</syntaxhighlight>

Revision as of 17:17, 30 October 2019

Some common preprocessor macros

GLSL

#define PI 3.141592653589793
#define PI_2 1.5707963267948966
#define DEG2RAD 0.017453292519943295
#define RAD2DEG 57.29577951308232

#define sign(x) (int((x) > 0) - int((x) < 0))
#define imin(x, y) (int(x) * int(int(x) < int(y)) + int(y) * int(int(x) >= int(y)))
#define imax(x, y) (int(x) * int(int(x) > int(y)) + int(y) * int(int(x) <= int(y)))
#define iabs(x) ((x) * int((x) >= 0) - (x) * int((x) < 0))