59 #define _ATL_VER 0x0400 // set this to 0x0300 if getting an error with Visual Studio 6 61 #elif defined _TMS320C6X 76 return *((
float *) &nResult);
81 unsigned long result = 0;
82 result |= (x & 0x000000ff) << 24;
83 result |= (x & 0x0000ff00) << 8;
84 result |= (x & 0x00ff0000) >> 8;
85 result |= (x & 0xff000000) >> 24;
91 unsigned int result = 0;
92 result |= (x & 0x000000ff) << 24;
93 result |= (x & 0x0000ff00) << 8;
94 result |= (x & 0x00ff0000) >> 8;
95 result |= (x & 0xff000000) >> 24;
101 unsigned short result = 0;
102 result |= (x & 0x00ff) << 8;
103 result |= (x & 0xff00) >> 8;
110 result |= (x & 0x000000ff) << 24;
111 result |= (x & 0x0000ff00) << 8;
112 result |= (x & 0x00ff0000) >> 8;
113 result |= (x & 0xff000000) >> 24;
120 result |= (x & 0x000000ff) << 24;
121 result |= (x & 0x0000ff00) << 8;
122 result |= (x & 0x00ff0000) >> 8;
123 result |= (x & 0xff000000) >> 24;
130 result |= (x & 0x00ff) << 8;
131 result |= (x & 0xff00) >> 8;
139 #if _ATL_VER > 0x0300 140 DWORD_PTR oldmask = SetThreadAffinityMask(GetCurrentThread(), 0);
143 static bool bInit =
true;
144 static LARGE_INTEGER startTime;
145 static LARGE_INTEGER freq;
149 QueryPerformanceFrequency(&freq);
150 QueryPerformanceCounter(&startTime);
154 LARGE_INTEGER tempTime;
155 QueryPerformanceCounter(&tempTime);
156 tempTime.QuadPart = tempTime.QuadPart - startTime.QuadPart;
157 sec = (
unsigned int) (tempTime.QuadPart / freq.QuadPart);
158 __int64 remainder = (__int64) tempTime.QuadPart % (__int64) freq.QuadPart;
159 usec = (
unsigned int) (remainder * (1000000.0 / freq.QuadPart));
161 #if _ATL_VER > 0x0300 162 SetThreadAffinityMask(GetCurrentThread(), oldmask);
165 #elif defined(_TMS320C6X) 166 sec = (
unsigned int) getlvar(SEC);
167 usec = ((
unsigned int) getvar(MSEC))*1000;
182 static int nStaticSec = 0;
183 static int nStaticUSec = 0;
186 #if _ATL_VER > 0x0300 187 DWORD_PTR oldmask = SetThreadAffinityMask(GetCurrentThread(), 0);
190 static bool bInit =
true;
191 static LARGE_INTEGER startTime;
192 static LARGE_INTEGER freq;
196 QueryPerformanceFrequency(&freq);
197 QueryPerformanceCounter(&startTime);
201 LARGE_INTEGER tempTime;
202 QueryPerformanceCounter(&tempTime);
203 tempTime.QuadPart = tempTime.QuadPart - startTime.QuadPart;
204 unsigned int sec = (
unsigned int) (tempTime.QuadPart / freq.QuadPart);
205 __int64 remainder = (__int64) tempTime.QuadPart % (__int64) freq.QuadPart;
206 unsigned int usec = (
unsigned int) (remainder * (1000000.0 / freq.QuadPart));
215 #if _ATL_VER > 0x0300 216 SetThreadAffinityMask(GetCurrentThread(), oldmask);
219 return (sec - nStaticSec) * 1000000 + ((int) usec - nStaticUSec);
221 #elif defined(_TMS320C6X) 222 int tv_sec = getlvar(SEC);
223 int tv_usec = getvar(MSEC)*1000;
229 nStaticUSec = tv_usec;
232 return (tv_sec - nStaticSec) * 1000000 + ((int) tv_usec - nStaticUSec);
243 nStaticSec = t.tv_sec;
244 nStaticUSec = t.tv_usec;
247 return (t.tv_sec - nStaticSec) * 1000000 + ((int) t.tv_usec - nStaticUSec);
253 return rand() / double(RAND_MAX);
258 return rand() / float(RAND_MAX);
265 static int next_gaussian = 0;
266 static double saved_gaussian_value;
268 double fac, rsq,
v1,
v2;
270 if (next_gaussian == 0)
276 rsq = v1 * v1 + v2 *
v2;
278 while (rsq >= 1.0 || rsq == 0.0);
280 fac = sqrt(-2.0 * log(rsq) / rsq);
281 saved_gaussian_value = v1 * fac;
289 return saved_gaussian_value;
296 static int next_gaussian = 0;
297 static float saved_gaussian_value;
299 float fac, rsq,
v1,
v2;
301 if (next_gaussian == 0)
307 rsq = v1 * v1 + v2 *
v2;
309 while (rsq >= 1.0f || rsq == 0.0f);
311 fac = sqrtf(-2.0f * logf(rsq) / rsq);
312 saved_gaussian_value = v1 * fac;
320 return saved_gaussian_value;
327 return (x > 0) ? int(x + 0.5) : int(x - 0.5);
332 return (x > 0) ? int(x + 0.5f) : int(x - 0.5f);
340 #elif defined(_TMS320C6X) 343 usleep((useconds_t) (1000 * ms));
351 float S = s / 255.0f, V = v / 255.0f;
355 R = (120 - h) / 60.0f;
362 G = (240 - h) / 60.0f;
363 B = (h - 120) / 60.0f;
367 R = (h - 240) / 60.0f;
369 B = (360 - h) / 60.0f;
376 r = int(255.0f * (1.0f + S * (R - 1.0f)) * V + 0.5f);
377 g = int(255.0f * (1.0f + S * (G - 1.0f)) * V + 0.5f);
378 b = int(255.0f * (1.0f + S * (B - 1.0f)) * V + 0.5f);
385 const int delta = v - min;
397 h = 60 * (g -
b) / delta;
399 h = 120 + (60 * (b -
r) / delta);
401 h = 240 + (60 * (r -
g) / delta);
404 while (h < 0) h += 360;
405 while (h > 360) h -= 360;
411 const int align_mask = align_size - 1;
413 char *ptr = (
char *) malloc(size + align_size +
sizeof(
int));
417 char *ptr2 = ptr +
sizeof(int);
418 char *aligned_ptr = ptr2 + (align_size - ((size_t)ptr2 & align_mask));
420 ptr2 = aligned_ptr -
sizeof(int);
421 *((
int *) ptr2) = (int) (aligned_ptr - ptr);
428 int *ptr2 = (
int *) ptr - 1;
429 char *ptr3 = (
char *) ptr;
GLfloat GLfloat GLfloat v2
float gaussian_random_float()
float invert_byte_order_float(float x)
unsigned long invert_byte_order_long(unsigned long x)
float uniform_random_float()
void hsv2rgb(int h, int s, int v, int &r, int &g, int &b)
const char * GetVersionIVT()
void rgb2hsv(int r, int g, int b, int &h, int &s, int &v)
unsigned int invert_byte_order_int(unsigned int x)
void aligned_free(void *ptr)
void * aligned_malloc(unsigned int size, unsigned int align_size)
void get_timer_value(unsigned int &sec, unsigned int &usec)
void sleep_ms(unsigned int ms)
GLdouble GLdouble GLdouble r
unsigned short invert_byte_order_short(unsigned short x)