CUGL
Cornell University Game Library
Main Page
Namespaces
Classes
Files
File List
•
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
util
CUDebug.h
1
//
2
// CUDebug.h
3
// Cornell University Game Library (CUGL)
4
//
5
// The SDL_assert functionality is VERY heavy weight. In addition, it beach
6
// balls on OS X. This module provides debugging functionality that is much
7
// more lightweight. However, you can still access the SDL functionality
8
// by setting the alter level to paranoid (assert level 3).
9
//
10
// CUGL zlib License:
11
// This software is provided 'as-is', without any express or implied
12
// warranty. In no event will the authors be held liable for any damages
13
// arising from the use of this software.
14
//
15
// Permission is granted to anyone to use this software for any purpose,
16
// including commercial applications, and to alter it and redistribute it
17
// freely, subject to the following restrictions:
18
//
19
// 1. The origin of this software must not be misrepresented; you must not
20
// claim that you wrote the original software. If you use this software
21
// in a product, an acknowledgment in the product documentation would be
22
// appreciated but is not required.
23
//
24
// 2. Altered source versions must be plainly marked as such, and must not
25
// be misrepresented as being the original software.
26
//
27
// 3. This notice may not be removed or altered from any source distribution.
28
//
29
// Author: Walker White
30
// Version: 5/31/16
31
32
#ifndef CU_DEBUG_H
33
#define CU_DEBUG_H
34
35
#include <SDL/SDL.h>
36
#include "../math/CUMathBase.h"
37
#include <cassert>
38
51
#if defined(__WINDOWS__)
52
#define CULog(msg,...) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,SDL_LOG_PRIORITY_INFO,msg, ##__VA_ARGS__)
53
#else
54
#define CULog(msg,args...) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,SDL_LOG_PRIORITY_INFO,msg, ##args)
55
#endif
56
69
#if defined(__WINDOWS__)
70
#define CULogError(msg,...) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,SDL_LOG_PRIORITY_ERROR,msg, ##__VA_ARGS__)
71
#else
72
#define CULogError(msg,args...) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,SDL_LOG_PRIORITY_ERROR,msg, ##args)
73
#endif
74
88
#if defined(__WINDOWS__)
89
#define CULogCritial(msg,...) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,SDL_LOG_PRIORITY_CRITICAL,msg, ##__VA_ARGS__)
90
#else
91
#define CULogCritial(msg,args...) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,SDL_LOG_PRIORITY_CRITICAL,msg, ##args)
92
#endif
93
107
#if defined(__WINDOWS__)
108
#define CUWarn(msg,...) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,SDL_LOG_PRIORITY_WARN,msg,##__VA_ARGS__)
109
#else
110
#define CUWarn(msg,args...) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,SDL_LOG_PRIORITY_WARN,msg, ##args)
111
#endif
112
113
/* Internal assert code to combine logging with the assert */
114
#define __cu_assert__(condition,msg,...) do { \
115
if (!(condition)) { \
116
CULogError(msg, ##__VA_ARGS__); \
117
assert(condition); \
118
} \
119
} while (0)
120
121
122
// Let's Doxgen the functions before the variable block.
123
196
#if SDL_ASSERT_LEVEL == 0
/* assertions disabled */
197
# define CUAssert(condition) SDL_disabled_assert(condition)
198
# define CUAssertLog(condition,msg,args...) SDL_disabled_assert(condition)
199
# define CUAssertAlways(condition) SDL_disabled_assert(condition)
200
# define CUAssertAlwaysLog(condition,msg,args...) SDL_disabled_assert(condition)
201
#elif SDL_ASSERT_LEVEL == 1
/* release settings. */
202
# define CUAssert(condition) SDL_disabled_assert(condition)
203
# define CUAssertLog(condition,msg,args...) SDL_disabled_assert(condition)
204
# define CUAssertAlways(condition) SDL_enabled_assert(condition)
205
# define CUAssertAlwaysLog(condition,msg,args...) SDL_enabled_assert(condition)
206
#elif SDL_ASSERT_LEVEL == 2
/* normal settings. */
207
# define CUAssert(condition) assert(condition)
208
# define CUAssertLog(condition,msg,...) __cu_assert__(condition,msg, ##__VA_ARGS__)
209
# define CUAssertAlways(condition) assert(condition)
210
# define CUAssertAlwaysLog(condition,msg,...) __cu_assert__(condition,msg, ##__VA_ARGS__)
211
#elif SDL_ASSERT_LEVEL == 3
/* paranoid settings. */
212
# define CUAssert(condition) SDL_enabled_assert(condition)
213
# define CUAssertLog(condition,msg,args...) SDL_enabled_assert(condition)
214
# define CUAssertAlways(condition) SDL_enabled_assert(condition)
215
# define CUAssertAlwaysLog(condition,msg,args...) SDL_enabled_assert(condition)
216
#else
217
# error Unknown assertion level.
218
#endif
219
228
#define CULogGLError() _check_gl_error(__FILE__,__LINE__)
229
230
void
_check_gl_error(
const
char
*file,
int
line);
231
232
#endif
/* CU_DEBUG_H */
Generated by
1.8.10