|
From: Elias N. <eli...@us...> - 2003-12-20 14:01:33
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1:/tmp/cvs-serv21938/src/native/common Modified Files: checkALerror.h checkGLerror.h common_tools.cpp common_tools.h extal.cpp extgl.cpp org_lwjgl_Sys.h Log Message: Implemented proper debug levels Index: checkALerror.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/checkALerror.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/checkALerror.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- checkALerror.h 15 Dec 2003 11:49:16 -0000 1.7 +++ checkALerror.h 20 Dec 2003 14:01:30 -0000 1.8 @@ -16,7 +16,7 @@ #define CHECK_AL_ERROR \ { \ - if (ATDEBUGLEVEL()) { \ + if (ATDEBUGLEVEL(org_lwjgl_Sys_DEBUG)) { \ int err = alGetError(); \ if (err != AL_NO_ERROR) { \ jclass cls = env->FindClass("org/lwjgl/openal/OpenALException"); \ @@ -28,7 +28,7 @@ /* only available if deviceaddress is specified in method */ #define CHECK_ALC_ERROR \ { \ - if (ATDEBUGLEVEL()) { \ + if (ATDEBUGLEVEL(org_lwjgl_Sys_DEBUG)) { \ int err = alcGetError((ALCdevice*) deviceaddress); \ if (err != AL_NO_ERROR) { \ jclass cls = env->FindClass("org/lwjgl/openal/OpenALException"); \ Index: checkGLerror.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/checkGLerror.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/checkGLerror.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- checkGLerror.h 15 Dec 2003 11:49:16 -0000 1.8 +++ checkGLerror.h 20 Dec 2003 14:01:30 -0000 1.9 @@ -16,7 +16,7 @@ #define CHECK_GL_ERROR \ { \ - if (ATDEBUGLEVEL()) { \ + if (ATDEBUGLEVEL(org_lwjgl_Sys_DEBUG)) { \ int err = glGetError(); \ if (err != GL_NO_ERROR) { \ jclass cls = env->FindClass("org/lwjgl/opengl/OpenGLException"); \ Index: common_tools.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/common_tools.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/common_tools.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- common_tools.cpp 15 Dec 2003 11:49:16 -0000 1.5 +++ common_tools.cpp 20 Dec 2003 14:01:30 -0000 1.6 @@ -39,18 +39,18 @@ #include "common_tools.h" -int debug_level = org_lwjgl_Sys_DEBUG_DISABLED; +int debug_level = org_lwjgl_Sys_NONE; void setDebugLevel(int level) { debug_level = level; } -int printfDebug(const char *format, ...) { +void printfDebug(int level, const char *format, ...) { va_list ap; va_start(ap, format); - int result = vprintf(format, ap); + if (debug_level >= level) + vprintf(format, ap); va_end(ap); - return result; } static void incListStart(event_queue_t *queue) { @@ -65,7 +65,7 @@ void putEventElement(event_queue_t *queue, unsigned char byte) { int next_index = (queue->list_end + 1)%EVENT_BUFFER_SIZE; if (next_index == queue->list_start) { - printfDebug("Event buffer overflow!\n"); + printfDebug(org_lwjgl_Sys_DEBUG, "Event buffer overflow!\n"); return; } queue->input_event_buffer[queue->list_end] = byte; Index: common_tools.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/common_tools.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/common_tools.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- common_tools.h 15 Dec 2003 11:49:16 -0000 1.4 +++ common_tools.h 20 Dec 2003 14:01:30 -0000 1.5 @@ -47,7 +47,7 @@ // Must be x * max_event_size + 1 #define EVENT_BUFFER_SIZE (25 * 4 + 1) -#define ATDEBUGLEVEL() (debug_level >= org_lwjgl_Sys_DEBUG_ENABLED) +#define ATDEBUGLEVEL(level) (debug_level >= level) typedef struct { unsigned char input_event_buffer[EVENT_BUFFER_SIZE]; @@ -65,6 +65,6 @@ extern void throwException(JNIEnv *env, const char *msg); extern void throwOpenALException(JNIEnv * env, const char * err); extern void setDebugLevel(int level); -extern int printfDebug(const char *format, ...); +extern void printfDebug(int level, const char *format, ...); #endif Index: extal.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/extal.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/extal.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- extal.cpp 15 Dec 2003 11:49:16 -0000 1.13 +++ extal.cpp 20 Dec 2003 14:01:30 -0000 1.14 @@ -182,7 +182,7 @@ static void* GetFunctionPointer(const char* function) { void *p = NativeGetFunctionPointer(function); if (p == NULL) { - printfDebug("Could not locate symbol %s\n", function); + printfDebug(org_lwjgl_Sys_DEBUG, "Could not locate symbol %s\n", function); } return p; } @@ -193,11 +193,11 @@ static bool LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) { jsize pathcount = env->GetArrayLength(oalPaths); - printfDebug("Found %d OpenAL paths\n", (int)pathcount); + printfDebug(org_lwjgl_Sys_DEBUG, "Found %d OpenAL paths\n", (int)pathcount); for(int i=0;i<pathcount;i++) { jstring path = (jstring) env->GetObjectArrayElement(oalPaths, i); const char *path_str = env->GetStringUTFChars(path, NULL); - printfDebug("Testing '%s'\n", path_str); + printfDebug(org_lwjgl_Sys_DEBUG, "Testing '%s'\n", path_str); #ifdef _WIN32 handleOAL = LoadLibrary(path_str); #endif @@ -208,7 +208,7 @@ handleOAL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR); #endif if (handleOAL != NULL) { - printfDebug("Found OpenAL at '%s'\n", path_str); + printfDebug(org_lwjgl_Sys_DEBUG, "Found OpenAL at '%s'\n", path_str); return true; } env->ReleaseStringUTFChars(path, path_str); Index: extgl.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/extgl.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/extgl.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- extgl.cpp 15 Dec 2003 11:49:16 -0000 1.6 +++ extgl.cpp 20 Dec 2003 14:01:30 -0000 1.7 @@ -1339,7 +1339,7 @@ err = FindFolder (kSystemDomain, kFrameworksFolderType, false, &fileRefParam.ioVRefNum, &fileRefParam.ioDirID); if (noErr != err) { - printfDebug("Could not find frameworks folder\n"); + printfDebug(org_lwjgl_Sys_DEBUG, "Could not find frameworks folder\n"); return NULL; } @@ -1350,7 +1350,7 @@ if (noErr != err) { - printfDebug("Could make FSref to frameworks folder\n"); + printfDebug(org_lwjgl_Sys_DEBUG, "Could make FSref to frameworks folder\n"); return NULL; } @@ -1359,7 +1359,7 @@ bundleURLOpenGL = CFURLCreateFromFSRef (kCFAllocatorDefault, &fileRef); if (!bundleURLOpenGL) { - printfDebug("Could create framework URL\n"); + printfDebug(org_lwjgl_Sys_DEBUG, "Could create framework URL\n"); return NULL; } @@ -1367,14 +1367,14 @@ CFRelease (bundleURLOpenGL); if (bundle_ref == NULL) { - printfDebug("Could not load framework\n"); + printfDebug(org_lwjgl_Sys_DEBUG, "Could not load framework\n"); return NULL; } // if the code was successfully loaded, look for our function. if (!CFBundleLoadExecutable(bundle_ref)) { - printfDebug("Could not load MachO executable\n"); + printfDebug(org_lwjgl_Sys_DEBUG, "Could not load MachO executable\n"); CFRelease(bundle_ref); return NULL; } @@ -1403,7 +1403,7 @@ { t = GetProcAddress(lib_glu_handle, name); if (t == NULL) { - printfDebug("Could not locate symbol %s\n", name); + printfDebug(org_lwjgl_Sys_DEBUG, "Could not locate symbol %s\n", name); extgl_error = true; } } @@ -1420,7 +1420,7 @@ { t = dlsym(lib_glu_handle, name); if (t == NULL) { - printfDebug("Could not locate symbol %s\n", name); + printfDebug(org_lwjgl_Sys_DEBUG, "Could not locate symbol %s\n", name); extgl_error = true; } } @@ -1434,7 +1434,7 @@ if (func_pointer == NULL) { func_pointer = CFBundleGetFunctionPointerForName(agl_bundle_ref, str); if (func_pointer == NULL) { - printfDebug("Could not locate symbol %s\n", name); + printfDebug(org_lwjgl_Sys_DEBUG, "Could not locate symbol %s\n", name); extgl_error = true; } } @@ -1449,7 +1449,7 @@ GLubyte *where, *terminator; if (extensions == NULL) { - printfDebug("NULL extension string\n"); + printfDebug(org_lwjgl_Sys_DEBUG, "NULL extension string\n"); extgl_error = true; return false; } @@ -3291,12 +3291,12 @@ { lib_gl_handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL); if (lib_gl_handle == NULL) { - printfDebug("Error loading libGL.so.1: %s\n", dlerror()); + printfDebug(org_lwjgl_Sys_DEBUG, "Error loading libGL.so.1: %s\n", dlerror()); return false; } lib_glu_handle = dlopen("libGLU.so.1", RTLD_LAZY | RTLD_GLOBAL); if (lib_glu_handle == NULL) { - printfDebug("Error loading libGLU.so.1: %s\n", dlerror()); + printfDebug(org_lwjgl_Sys_DEBUG, "Error loading libGLU.so.1: %s\n", dlerror()); dlclose(lib_gl_handle); return false; } Index: org_lwjgl_Sys.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/org_lwjgl_Sys.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_Sys.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- org_lwjgl_Sys.h 15 Dec 2003 11:49:16 -0000 1.16 +++ org_lwjgl_Sys.h 20 Dec 2003 14:01:30 -0000 1.17 @@ -7,11 +7,18 @@ #ifdef __cplusplus extern "C" { #endif -/* Inaccessible static: _00024assertionsDisabled */ -#undef org_lwjgl_Sys_DEBUG_DISABLED -#define org_lwjgl_Sys_DEBUG_DISABLED 1L -#undef org_lwjgl_Sys_DEBUG_ENABLED -#define org_lwjgl_Sys_DEBUG_ENABLED 2L +#undef org_lwjgl_Sys_DEBUG +#define org_lwjgl_Sys_DEBUG 6L +#undef org_lwjgl_Sys_INFO +#define org_lwjgl_Sys_INFO 5L +#undef org_lwjgl_Sys_WARN +#define org_lwjgl_Sys_WARN 4L +#undef org_lwjgl_Sys_ERROR +#define org_lwjgl_Sys_ERROR 3L +#undef org_lwjgl_Sys_FATAL +#define org_lwjgl_Sys_FATAL 2L +#undef org_lwjgl_Sys_NONE +#define org_lwjgl_Sys_NONE 1L #undef org_lwjgl_Sys_LOW_PRIORITY #define org_lwjgl_Sys_LOW_PRIORITY -1L #undef org_lwjgl_Sys_NORMAL_PRIORITY @@ -21,8 +28,7 @@ #undef org_lwjgl_Sys_REALTIME_PRIORITY #define org_lwjgl_Sys_REALTIME_PRIORITY 2L /* Inaccessible static: LIBRARY_NAME */ -/* Inaccessible static: DEBUG */ -/* Inaccessible static: class_00024org_00024lwjgl_00024Sys */ +/* Inaccessible static: debug_level */ /* * Class: org_lwjgl_Sys * Method: setDebugLevel |