2 ******************************************************************************
4 GGIMesa debugging macros
6 Copyright (C) 1998-1999 Marcus Sundberg [marcus@ggi-project.org]
7 Copyright (C) 1999-2000 Jon Taylor [taylorj@ggi-project.org]
9 Permission is hereby granted, free of charge, to any person obtaining a
10 copy of this software and associated documentation files (the "Software"),
11 to deal in the Software without restriction, including without limitation
12 the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so, subject to the following conditions:
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 ******************************************************************************
29 #ifndef _GGI_GLUT_INTERNAL_DEBUG_H
30 #define _GGI_GLUT_INTERNAL_DEBUG_H
36 #include <ggi/types.h>
42 /* Exported variables */
43 #ifdef BUILDING_GGIGLUT
44 extern uint32 _ggiglutDebugState
;
45 extern int _ggiglutDebugSync
;
47 IMPORTVAR uint32 _ggiglutDebugState
;
48 IMPORTVAR
int _ggiglutDebugSync
;
55 * bit 0 is reserved! */
57 #define GGIGLUTDEBUG_CORE (1<<1) /* 2 */
58 #define GGIGLUTDEBUG_MODE (1<<2) /* 4 */
59 #define GGIGLUTDEBUG_COLOR (1<<3) /* 8 */
60 #define GGIGLUTDEBUG_DRAW (1<<4) /* 16 */
61 #define GGIGLUTDEBUG_MISC (1<<5) /* 32 */
62 #define GGIGLUTDEBUG_LIBS (1<<6) /* 64 */
63 #define GGIGLUTDEBUG_EVENTS (1<<7) /* 128 */
65 #define GGIGLUTDEBUG_ALL 0xffffffff
70 #define GGIGLUTDPRINT(form,args...) if (_ggiglutDebugState) { ggDPrintf(_ggiglutDebugSync, "GGIGLUT",form, ##args); }
71 #define GGIGLUTDPRINT_CORE(form,args...) if (_ggiglutDebugState & GGIGLUTDEBUG_CORE) { ggDPrintf(_ggiglutDebugSync,"GGIGLUT",form, ##args); }
72 #define GGIGLUTDPRINT_MODE(form,args...) if (_ggiglutDebugState & GGIGLUTDEBUG_MODE) { ggDPrintf(_ggiglutDebugSync,"GGIGLUT",form, ##args); }
73 #define GGIGLUTDPRINT_COLOR(form,args...) if (_ggiglutDebugState & GGIGLUTDEBUG_COLOR) { ggDPrintf(_ggiglutDebugSync,"GGIGLUT",form, ##args); }
74 #define GGIGLUTDPRINT_DRAW(form,args...) if (_ggiglutDebugState & GGIGLUTDEBUG_DRAW) { ggDPrintf(_ggiglutDebugSync,"GGIGLUT",form, ##args); }
75 #define GGIGLUTDPRINT_MISC(form,args...) if (_ggiglutDebugState & GGIGLUTDEBUG_MISC) { ggDPrintf(_ggiglutDebugSync,"GGIGLUT",form, ##args); }
76 #define GGIGLUTDPRINT_LIBS(form,args...) if (_ggiglutDebugState & GGIGLUTDEBUG_LIBS) { ggDPrintf(_ggiglutDebugSync,"GGIGLUT",form, ##args); }
77 #define GGIGLUTDPRINT_EVENTS(form,args...) if (_ggiglutDebugState & GGIGLUTDEBUG_EVENTS) { ggDPrintf(_ggiglutDebugSync,"GGIGLUT",form, ##args); }
79 #define GGIGLUTDPRINT(form,args...) do{}while(0)
80 #define GGIGLUTDPRINT_CORE(form,args...) do{}while(0)
81 #define GGIGLUTDPRINT_MODE(form,args...) do{}while(0)
82 #define GGIGLUTDPRINT_COLOR(form,args...) do{}while(0)
83 #define GGIGLUTDPRINT_DRAW(form,args...) do{}while(0)
84 #define GGIGLUTDPRINT_MISC(form,args...) do{}while(0)
85 #define GGIGLUTDPRINT_LIBS(form,args...) do{}while(0)
86 #define GGIGLUTDPRINT_EVENTS(form,args...) do{}while(0)
93 static inline void GGIGLUTDPRINT(const char *form
,...)
99 fprintf(stderr
, "GGIGLUT: ");
100 va_start(args
, form
);
101 vfprintf(stderr
, form
, args
);
103 if (_ggiglutDebugSync
) fflush(stderr
);
108 static inline void GGIGLUTDPRINT_CORE(const char *form
,...)
111 if (_ggiDebugState
& GGIDEBUG_CORE
) {
114 fprintf(stderr
, "GGIGLUT: ");
115 va_start(args
, form
);
116 vfprintf(stderr
, form
, args
);
118 if (_ggiglutDebugSync
) fflush(stderr
);
123 static inline void GGIGLUTDPRINT_MODE(const char *form
,...)
126 if (_ggiDebugState
& GGIDEBUG_MODE
) {
129 fprintf(stderr
, "GGIGLUT: ");
130 va_start(args
, form
);
131 vfprintf(stderr
, form
, args
);
133 if (_ggiglutDebugSync
) fflush(stderr
);
138 static inline void GGIGLUTDPRINT_COLOR(const char *form
,...)
141 if (_ggiDebugState
& GGIDEBUG_COLOR
) {
144 fprintf(stderr
, "GGIGLUT: ");
145 va_start(args
, form
);
146 vfprintf(stderr
, form
, args
);
148 if (_ggiglutDebugSync
) fflush(stderr
);
153 static inline void GGIGLUTDPRINT_DRAW(const char *form
,...)
156 if (_ggiDebugState
& GGIDEBUG_DRAW
) {
159 fprintf(stderr
, "GGIGLUT: ");
160 va_start(args
, form
);
161 vfprintf(stderr
, form
, args
);
163 if (_ggiglutDebugSync
) fflush(stderr
);
168 static inline void GGIGLUTDPRINT_MISC(const char *form
,...)
171 if (_ggiDebugState
& GGIDEBUG_MISC
) {
174 fprintf(stderr
, "GGIGLUT: ");
175 va_start(args
, form
);
176 vfprintf(stderr
, form
, args
);
178 if (_ggiglutDebugSync
) fflush(stderr
);
183 static inline void GGIGLUTDPRINT_LIBS(const char *form
,...)
186 if (_ggiDebugState
& GGIDEBUG_LIBS
) {
189 fprintf(stderr
, "GGIGLUT: ");
190 va_start(args
, form
);
191 vfprintf(stderr
, form
, args
);
193 if (_ggiglutDebugSync
) fflush(stderr
);
198 static inline void GGIGLUTDPRINT_EVENTS(const char *form
,...)
201 if (_ggiDebugState
& GGIDEBUG_EVENTS
) {
204 fprintf(stderr
, "GGIGLUT: ");
205 va_start(args
, form
);
206 vfprintf(stderr
, form
, args
);
208 if (_ggiglutDebugSync
) fflush(stderr
);
215 #endif /* __GNUC__ */
218 #define GGIGLUT_ASSERT(x,str) \
220 fprintf(stderr,"GGIGLUT:%s:%d: INTERNAL ERROR: %s\n",__FILE__,__LINE__,str); \
223 #define GGIGLUT_APPASSERT(x,str) \
225 fprintf(stderr,"GGIGLUT:%s:%d: APPLICATION ERROR: %s\n",__FILE__,__LINE__,str); \
229 #define GGIGLUT_ASSERT(x,str) do{}while(0)
230 #define GGIGLUT_APPASSERT(x,str) do{}while(0)
234 # define GGIGLUTD0(x) x
236 # define GGIGLUTD0(x) /* empty */
240 # if GGIGLUTDLEV == 1
241 # define GGIGLUTD1(x) x
242 # define GGIGLUTD2(x) /* empty */
243 # define GGIGLUTD3(x) /* empty */
244 # elif GGIGLUTDLEV == 2
245 # define GGIGLUTD1(x) x
246 # define GGIGLUTD2(x) x
247 # define GGIGLUTD3(x) /* empty */
248 # elif GGIGLUTDLEV > 2
249 # define GGIGLUTD1(x) x
250 # define GGIGLUTD2(x) x
251 # define GGIGLUTD3(x) x
254 # define GGIGLUTD1(x) /* empty */
255 # define GGIGLUTD2(x) /* empty */
256 # define GGIGLUTD3(x) /* empty */
259 #endif /* _GGI_MESA_INTERNAL_DEBUG_H */