Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv8597/src/native/linux Modified Files: extxcursor.cpp org_lwjgl_Display.cpp org_lwjgl_Sys.cpp org_lwjgl_input_Mouse.cpp org_lwjgl_opengl_Pbuffer.cpp org_lwjgl_opengl_Window.cpp Log Message: Replaced debug libraries with runtime debug condition Index: extxcursor.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/extxcursor.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/extxcursor.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- extxcursor.cpp 20 May 2003 14:28:30 -0000 1.4 +++ extxcursor.cpp 15 Dec 2003 11:49:17 -0000 1.5 @@ -1,6 +1,7 @@ #include <stdio.h> #include <dlfcn.h> #include "extxcursor.h" +#include "common_tools.h" static void * xcursor_handle = NULL; static const char *xcursor_lib_name = "libXcursor.so.1"; @@ -39,9 +40,7 @@ load_success = false; xcursor_handle = dlopen(xcursor_lib_name, RTLD_GLOBAL | RTLD_LAZY); if (xcursor_handle == NULL) { -#ifdef _DEBUG - printf("Could not load %s: %s\n", xcursor_lib_name, dlerror()); -#endif + printfDebug("Could not load %s: %s\n", xcursor_lib_name, dlerror()); return load_success; } loadFunctionPointers(); Index: org_lwjgl_Display.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Display.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- org_lwjgl_Display.cpp 24 Oct 2003 05:51:50 -0000 1.42 +++ org_lwjgl_Display.cpp 15 Dec 2003 11:49:17 -0000 1.43 @@ -61,20 +61,14 @@ int event_base, error_base; if (!XF86VidModeQueryExtension(disp, &event_base, &error_base)) { -#ifdef _DEBUG - printf("XF86VidMode extension not available\n"); -#endif + printfDebug("XF86VidMode extension not available\n"); return false; } if (!XF86VidModeQueryVersion(disp, major, minor)) { -#ifdef _DEBUG - printf("Could not determine XF86VidMode version\n"); -#endif + printfDebug("Could not determine XF86VidMode version\n"); return false; } -#ifdef _DEBUG - printf("XF86VidMode extension version %i.%i\n", *major, *minor); -#endif + printfDebug("XF86VidMode extension version %i.%i\n", *major, *minor); return true; } @@ -90,24 +84,17 @@ int num_modes, i; XF86VidModeModeInfo **avail_modes; if (!getDisplayModes(disp, screen, &num_modes, &avail_modes)) { -#ifdef _DEBUG - printf("Could not get display modes\n"); -#endif + printfDebug("Could not get display modes\n"); return false; } XF86VidModeLockModeSwitch(disp, screen, 0); for ( i = 0; i < num_modes; ++i ) { -#ifdef _DEBUG - printf("Mode %d: %dx%d\n", i, avail_modes[i]->hdisplay, avail_modes[i]->vdisplay); -#endif + printfDebug("Mode %d: %dx%d\n", i, avail_modes[i]->hdisplay, avail_modes[i]->vdisplay); if (avail_modes[i]->hdisplay == width && avail_modes[i]->vdisplay == height) { if (!XF86VidModeSwitchToMode(disp, screen, avail_modes[i])) { -#ifdef _DEBUG - printf("Could not switch mode\n"); -#endif + printfDebug("Could not switch mode\n"); break; } -// XF86VidModeSetViewPort(disp, screen, 0, 0); if (lock_mode) XF86VidModeLockModeSwitch(disp, screen, 1); XFree(avail_modes); @@ -131,15 +118,11 @@ static int getGammaRampLength(Display *disp, int screen) { int minor_ver, major_ver, ramp_size; if (!getVidModeExtensionVersion(disp, screen, &major_ver, &minor_ver) || major_ver < 2) { -#ifdef _DEBUG - printf("XF86VidMode extension version >= 2 not found\n"); -#endif + printfDebug("XF86VidMode extension version >= 2 not found\n"); return 0; } if (XF86VidModeGetGammaRampSize(disp, screen, &ramp_size) == False) { -#ifdef _DEBUG - printf("XF86VidModeGetGammaRampSize call failed\n"); -#endif + printfDebug("XF86VidModeGetGammaRampSize call failed\n"); return 0; } return ramp_size; @@ -153,24 +136,18 @@ int screen; Display *disp = XOpenDisplay(NULL); if (disp == NULL) { -#ifdef _DEBUG - printf("Could not open X connection\n"); -#endif + printfDebug("Could not open X connection\n"); return; } screen = DefaultScreen(disp); if (!getDisplayModes(disp, screen, &num_modes, &avail_modes)) { -#ifdef _DEBUG - printf("Could not get display modes\n"); -#endif + printfDebug("Could not get display modes\n"); } saved_width = avail_modes[0]->hdisplay; saved_height = avail_modes[0]->vdisplay; int bpp = XDefaultDepth(disp, screen); -#ifdef _DEBUG - printf("Saved width, height %d, %d\n", saved_width, saved_height); -#endif + printfDebug("Saved width, height %d, %d\n", saved_width, saved_height); jclass jclass_DisplayMode = env->FindClass("org/lwjgl/DisplayMode"); jmethodID ctor = env->GetMethodID(jclass_DisplayMode, "<init>", "(IIII)V"); jobject newMode = env->NewObject(jclass_DisplayMode, ctor, saved_width, saved_height, bpp, 0); @@ -218,9 +195,7 @@ Display *disp = XOpenDisplay(NULL); if (disp == NULL) { -#ifdef _DEBUG - printf("Could not open X connection\n"); -#endif + printfDebug("Could not open X connection\n"); return; } screen = DefaultScreen(disp); @@ -232,11 +207,6 @@ XCloseDisplay(disp); } -/* - * Class: org_lwjgl_Display - * Method: nGetAvailableDisplayModes - * Signature: ()[Lorg/lwjgl/DisplayMode; - */ JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_Display_nGetAvailableDisplayModes (JNIEnv * env, jclass clazz) { @@ -246,9 +216,7 @@ XF86VidModeModeInfo **avail_modes; if (disp == NULL) { -#ifdef _DEBUG - printf("Could not open X connection\n"); -#endif + printfDebug("Could not open X connection\n"); return NULL; } @@ -256,9 +224,7 @@ int bpp = XDefaultDepth(disp, screen); if (!getDisplayModes(disp, screen, &num_modes, &avail_modes)) { -#ifdef _DEBUG - printf("Could not get display modes\n"); -#endif + printfDebug("Could not get display modes\n"); XCloseDisplay(disp); return NULL; } Index: org_lwjgl_Sys.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Sys.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Sys.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- org_lwjgl_Sys.cpp 22 Nov 2003 19:20:05 -0000 1.19 +++ org_lwjgl_Sys.cpp 15 Dec 2003 11:49:17 -0000 1.20 @@ -43,6 +43,7 @@ #include <sys/time.h> #include <sys/resource.h> #include "org_lwjgl_Sys.h" +#include "common_tools.h" static long int hires_timer_freq; // Hires timer frequency static long int hires_timer_start; // Hires timer start @@ -62,15 +63,17 @@ static long queryTime(void) { struct timeval tv; if (gettimeofday(&tv, NULL) == -1) { -#ifdef _DEBUG - printf("Could not read current time\n"); -#endif + printfDebug("Could not read current time\n"); } long result = tv.tv_sec * 1000000l + tv.tv_usec; return result; } +JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setDebugLevel(JNIEnv *env, jclass clazz, jint debug_level) { + setDebugLevel(debug_level); +} + /* * Class: org_lwjgl_Sys * Method: getTime @@ -114,9 +117,7 @@ // Reset scheduler to normal sched_pri.sched_priority = 0; if (sched_setscheduler(0, SCHED_OTHER, &sched_pri) != 0) { -#ifdef _DEBUG - printf("Could not set realtime priority\n"); -#endif + printfDebug("Could not set realtime priority\n"); return; } } @@ -126,16 +127,12 @@ min_pri = sched_get_priority_min(SCHED_FIFO); max_pri = sched_get_priority_max(SCHED_FIFO); if (min_pri == -1 || max_pri == -1) { -#ifdef _DEBUG - printf("Failed to set realtime priority\n"); -#endif + printfDebug("Failed to set realtime priority\n"); return; } sched_pri.sched_priority = (max_pri + min_pri)/2; if (sched_setscheduler(0, SCHED_FIFO, &sched_pri) != 0) { -#ifdef _DEBUG - printf("Could not set realtime priority\n"); -#endif + printfDebug("Could not set realtime priority\n"); return; } return; @@ -153,9 +150,7 @@ } if (setpriority(PRIO_PROCESS, 0, linux_priority) == -1) { -#ifdef _DEBUG - printf("Failed to set priority.\n"); -#endif + printfDebug("Failed to set priority.\n"); } } Index: org_lwjgl_input_Mouse.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- org_lwjgl_input_Mouse.cpp 20 Oct 2003 12:49:50 -0000 1.41 +++ org_lwjgl_input_Mouse.cpp 15 Dec 2003 11:49:17 -0000 1.42 @@ -122,9 +122,7 @@ static bool blankCursor(void) { unsigned int best_width, best_height; if (XQueryBestCursor(getCurrentDisplay(), getCurrentWindow(), 1, 1, &best_width, &best_height) == 0) { -#ifdef _DEBUG - printf("Could not query best cursor size\n"); -#endif + printfDebug("Could not query best cursor size\n"); return false; } Pixmap mask = XCreatePixmap(getCurrentDisplay(), getCurrentWindow(), best_width, best_height, 1); @@ -201,14 +199,10 @@ event.xmotion.y > current_y - POINTER_WARP_BORDER && event.xmotion.y < current_y + POINTER_WARP_BORDER) break; -#ifdef _DEBUG - printf("Skipped event searching for warp event %d, %d\n", event.xmotion.x, event.xmotion.y); -#endif + printfDebug("Skipped event searching for warp event %d, %d\n", event.xmotion.x, event.xmotion.y); } -#ifdef _DEBUG if (i == WARP_RETRY) - printf("Never got warp event\n"); -#endif + printfDebug("Never got warp event\n"); } static void warpPointer(void) { Index: org_lwjgl_opengl_Pbuffer.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- org_lwjgl_opengl_Pbuffer.cpp 22 Oct 2003 11:45:51 -0000 1.4 +++ org_lwjgl_opengl_Pbuffer.cpp 15 Dec 2003 11:49:17 -0000 1.5 @@ -161,9 +161,7 @@ GLXPbuffer buffer = buffer_info->buffer; GLXContext context = buffer_info->context; if (glXMakeContextCurrent(getCurrentDisplay(), buffer, buffer, context) == False) { -#ifdef _DEBUG - printf("Could not make pbuffer current"); -#endif + printfDebug("Could not make pbuffer current"); } } Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- org_lwjgl_opengl_Window.cpp 2 Nov 2003 14:41:20 -0000 1.11 +++ org_lwjgl_opengl_Window.cpp 15 Dec 2003 11:49:17 -0000 1.12 @@ -208,9 +208,7 @@ } win = XCreateWindow(disp, root_win, x, y, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs); XFreeColormap(disp, cmap); -#ifdef _DEBUG - printf("Created window\n"); -#endif + printfDebug("Created window\n"); current_win = win; Java_org_lwjgl_opengl_Window_nSetTitle(env, NULL, title); XSizeHints * size_hints = XAllocSizeHints(); @@ -383,9 +381,8 @@ throwException(env, "Could not create visual info from FB config"); return false; } -#ifdef _DEBUG - dumpVisualInfo(disp, vis_info); -#endif + if (ATDEBUGLEVEL()) + dumpVisualInfo(disp, vis_info); createWindow(env, disp, screen, vis_info, title, x, y, width, height, fscreen); glx_window = glXCreateWindow(disp, configs[0], getCurrentWindow(), NULL); makeCurrent(); @@ -400,9 +397,8 @@ throwException(env, "Could not find a matching pixel format"); return false; } -#ifdef _DEBUG - dumpVisualInfo(disp, vis_info); -#endif + if (ATDEBUGLEVEL()) + dumpVisualInfo(disp, vis_info); context = glXCreateContext(disp, vis_info, NULL, True); if (context == NULL) { XFree(vis_info); @@ -467,10 +463,10 @@ throwException(env, "Could not init gl function pointers"); return; } -#ifdef _DEBUG - const GLubyte * extensions = glGetString(GL_EXTENSIONS); - printf("Supported extensions: %s\n", extensions); -#endif + if (ATDEBUGLEVEL()) { + const GLubyte * extensions = glGetString(GL_EXTENSIONS); + printf("Supported extensions: %s\n", extensions); + } } /* |