~ubuntu-branches/ubuntu/edgy/glui/edgy

« back to all changes in this revision

Viewing changes to stdinc.h

  • Committer: Bazaar Package Importer
  • Author(s): Marcelo E. Magallon
  • Date: 2001-09-23 12:57:28 UTC
  • Revision ID: james.westby@ubuntu.com-20010923125728-qbts7xit2eg1ogo2
Tags: upstream-2.1.0.beta
ImportĀ upstreamĀ versionĀ 2.1.0.beta

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _STDINC_H_
 
2
#define _STDINC_H_
 
3
 
 
4
#include <stdio.h>
 
5
#include <math.h>
 
6
 
 
7
#ifndef AND
 
8
#define AND &&
 
9
#define OR  ||
 
10
#define NOT !
 
11
#endif
 
12
 
 
13
#ifndef true
 
14
#define true 1
 
15
#define false 0
 
16
#endif
 
17
 
 
18
#ifndef Bool
 
19
typedef char Bool;
 
20
#endif
 
21
 
 
22
#ifndef MAX
 
23
#define MAX(a,b)  ((a)>(b) ? (a) : (b))
 
24
#define MIN(a,b)  ((a)<(b) ? (a) : (b))
 
25
#endif
 
26
 
 
27
#ifndef ABS
 
28
#define ABS(a) ((a)>=0 ? (a) : (-(a)))
 
29
#endif
 
30
 
 
31
/********* TOGGLE_BOOL(boolean) : toggles values of 'boolean' ******/
 
32
#ifndef TOGGLE_BOOL
 
33
#define TOGGLE_BOOL(a)  ((a)=1-(a))
 
34
#endif
 
35
 
 
36
 
 
37
/********************  bit comparisons and operations ***************/
 
38
#ifndef TEST_BIT
 
39
#define TEST_BIT( x, b )   (((x) & (1<<(b))) != 0 )
 
40
#define SET_BIT( x, b )    ((x) |= (1 << (b)))
 
41
#define CLEAR_BIT( x, b )  ((x) &= ~(1 << (b)))
 
42
#define TOGGLE_BIT( x, b ) ((TEST_BIT(x,b)) ?(CLEAR_BIT(x,b)):(SET_BIT(x,b)))
 
43
#endif
 
44
 
 
45
#ifndef TEST_AND
 
46
#define TEST_AND( a, b ) ((a&b)==b)
 
47
#endif
 
48
 
 
49
 
 
50
#ifndef M_PI
 
51
#define M_PI 3.141592654
 
52
#endif
 
53
 
 
54
typedef  char String[81];
 
55
 
 
56
 
 
57
/*********** flush the stdout and stderr output streams *************/
 
58
#ifndef flushout
 
59
#define flushout fflush(stdout)
 
60
#define flusherr fflush(stderr)
 
61
#endif
 
62
 
 
63
 
 
64
/********** Debugging functions *************************************/
 
65
#ifndef error_return
 
66
#define error_return( c ); {fprintf(stderr,c);return;}
 
67
#endif
 
68
 
 
69
 
 
70
/************************* floating-point random ********************/
 
71
#ifndef randf
 
72
#define randf()  ((float) rand() / (float)RAND_MAX )
 
73
#endif
 
74
 
 
75
#ifndef SIGN
 
76
#define SIGN(x) ((x)>=0 ?  1  :  -1)
 
77
#endif
 
78
 
 
79
 
 
80
/****************** conversion between degrees and radians **********/
 
81
#ifndef DEG2RAD
 
82
#define DEG2RAD(x) ((x)/180.0*M_PI)
 
83
#define RAD2DEG(x) ((x)/M_PI*180.0)
 
84
#endif
 
85
 
 
86
 
 
87
/***************** clamp a value to some fixed interval *************/
 
88
#ifndef CLAMP
 
89
#define CLAMP(x,lo,hi)  {if ((x) < (lo)) {(x)=(lo);} else if((x) > (hi)) {(x)=(hi);}}
 
90
#endif
 
91
 
 
92
 
 
93
 
 
94
/************ check if a value lies within a closed interval *********/
 
95
#ifndef IN_BOUNDS
 
96
#define IN_BOUNDS( x, lo, hi ) ( (x) >= (lo) AND (x) <= (hi) )
 
97
#endif
 
98
 
 
99
 
 
100
/************ check if a 2D point lies within a 2D box ***************/
 
101
#ifndef PT_IN_BOX
 
102
#define PT_IN_BOX( x, y, lo_x, hi_x, lo_y, hi_y ) \
 
103
( IN_BOUNDS(x,lo_x,hi_x) AND IN_BOUNDS(y,lo_y,hi_y) )
 
104
#endif
 
105
 
 
106
     /****** check if value lies on proper side of another value     *****/
 
107
     /*** if side is positive => proper side is positive, else negative **/
 
108
#ifndef CHECK_PROPER_SIDE
 
109
#define CHECK_PROPER_SIDE(x,val,side) ((side) > 0 ? (x) > (val) : (x) < (val))
 
110
#endif
 
111
 
 
112
 
 
113
     /***** Small value when we want to do a comparison to 'close to zero' *****/
 
114
#ifndef FUDGE
 
115
#define FUDGE .00001
 
116
#endif
 
117
 
 
118
 
 
119
     /******************* swap two values, using a temp variable *********/
 
120
#ifndef SWAP2
 
121
#define SWAP2(a,b,t) {t=a;a=b;b=t;}     
 
122
#endif
 
123
 
 
124
#define VEC3_TO_ARRAY(v,a)  a[0]=v[0], a[1]=v[1], a[2]=v[2]
 
125
 
 
126
#endif /* _STDINC_H_ */
 
127
 
 
128
 
 
129
 
 
130
 
 
131