00001
00002
00003
00004
00005
00006
00008
00010
00011
00012
00013
00014
00016
00017 #pragma once
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #ifndef PI
00049
00050 #define PI 3.14159265358979323846
00051 #endif
00052
00053
00054 #ifndef DEBUG
00055
00056 #define verbose 1
00057 #define DEBUG if (verbose) printf
00058 #endif
00059
00064 #define GLERROR \
00065 { \
00066 GLenum code = glGetError(); \
00067 while (code!=GL_NO_ERROR) \
00068 { \
00069 printf("Gl error: %s\n",(char *) gluErrorString(code));\
00070 code = glGetError(); \
00071 } \
00072 }
00073
00074
00075
00076 #ifndef AND
00077 #define AND &&
00078 #define OR ||
00079 #define NOT !
00080 #endif
00081
00082
00083 #ifndef MAX
00084
00085 #define MAX(a,b) ((a)>(b) ? (a) : (b))
00086
00087 #define MIN(a,b) ((a)<(b) ? (a) : (b))
00088 #endif
00089
00090
00091 #ifndef IMAX
00092
00093 #define IMAX(a,b) ((a)>(b) ? (0) : (1))
00094
00095 #define IMIN(a,b) ((a)<(b) ? (0) : (1))
00096 #endif
00097
00098 #ifndef ABS
00099
00100 #define ABS(a) ((a)>=0 ? (a) : (-(a)))
00101 #endif
00102
00103
00104 #ifndef TEST_BIT
00105 #define TEST_BIT( x, b ) (((x) & (1<<(b))) != 0 )
00106 #define SET_BIT( x, b ) ((x) |= (1 << (b)))
00107 #define CLEAR_BIT( x, b ) ((x) &= ~(1 << (b)))
00108 #define TOGGLE_BIT( x, b ) ((TEST_BIT(x,b))?(CLEAR_BIT(x,b)):(SET_BIT(x,b)))
00109 #endif
00110
00111
00112 #ifndef flushout
00113
00114 #define flushout fflush(stdout)
00115
00116 #define flusherr fflush(stderr)
00117 #endif
00118
00119
00120 #ifndef randf
00121
00124 #define randf() ((float) rand() / (float)RAND_MAX )
00125 #endif
00126
00127
00128 #ifndef SIGN
00129
00130 #define SIGN(x) ((x)>=0 ? 1 : -1)
00131 #endif
00132
00133
00134 #ifndef DEG2RAD
00135
00136 #define DEG2RAD(x) ((x)/180.0*pi)
00137
00138 #define RAD2DEG(x) ((x)/pi*180.0)
00139 #endif
00140
00141
00142 #ifndef CLAMP
00143
00144 #define CLAMP(x,lo,hi) {if ((x) < (lo)) {(x)=(lo);} else if((x) > (hi)){(x)=(hi);}}
00145 #endif
00146
00147