Replaced debug libraries with runtime debug condition

This commit is contained in:
Elias Naur 2003-12-15 11:49:17 +00:00
parent cd2a1cc13f
commit 472b5337d4
28 changed files with 679 additions and 952 deletions

View file

@ -80,7 +80,7 @@ public final class Display {
static {
System.loadLibrary(Sys.getLibraryName());
init();
if (Sys.DEBUG) {
if (Sys.atDebugLevel()) {
System.out.println("Adapter: "+getAdapter()+" Version: "+getVersion());
}
}
@ -120,7 +120,7 @@ public final class Display {
DisplayMode[] filteredModes = new DisplayMode[modes.size()];
modes.toArray(filteredModes);
if (Sys.DEBUG) {
if (Sys.atDebugLevel()) {
System.out.println("Removed " + (unfilteredModes.length - filteredModes.length) + " duplicate displaymodes");
}
@ -239,7 +239,7 @@ public final class Display {
gammaRamp.put(i, rampEntry);
}
setGammaRamp(gammaRamp);
if (Sys.DEBUG) {
if (Sys.atDebugLevel()) {
System.out.println("Gamma set, gamma = " + gamma + ", brightness = " + brightness + ", contrast = " + contrast);
}
}

View file

@ -47,6 +47,9 @@ import org.lwjgl.input.Mouse;
* @version $Revision$
*/
public final class Sys {
/** Debug level constants */
public static final int DEBUG_DISABLED = 1;
public static final int DEBUG_ENABLED = 2;
/** Low process priority. @see #setProcessPriority() */
public static final int LOW_PRIORITY = -1;
@ -78,38 +81,26 @@ public final class Sys {
public static final int REALTIME_PRIORITY = 2;
/** The native library name */
private static String LIBRARY_NAME;
private static String LIBRARY_NAME = "lwjgl";
/**
* Debug flag. This will tell you if you are using the debug version of
* Debug level. This will tell you if you are using the debug version of
* the library, and whether assertions are enabled or not.
*/
public static final boolean DEBUG;
public static final int DEBUG;
/**
* The ByteBuffer equivalent of the native NULL constant
*/
// public static final ByteBuffer NULL;
private static boolean _debug;
static {
int _debug = DEBUG_DISABLED;
try {
assert false;
LIBRARY_NAME = "lwjgl";
_debug = false;
} catch (AssertionError e) {
// Assertions are enabled, so we'll use the debug version of the
// library
LIBRARY_NAME = "lwjgl_d";
_debug = true;
// Assertions are enabled, so we'll enabled debugging
_debug = DEBUG_ENABLED;
} finally {
DEBUG = _debug;
initialize();
}
}
/**
* @return the name of the native library to load
@ -124,11 +115,16 @@ public final class Sys {
private Sys() {
}
public static boolean atDebugLevel() {
return DEBUG >= DEBUG_ENABLED;
}
/**
* Initialization.
*/
private static void initialize() {
System.loadLibrary(LIBRARY_NAME);
setDebugLevel(DEBUG);
setTime(0);
Runtime.getRuntime().addShutdownHook(new Thread() {
@ -145,6 +141,11 @@ public final class Sys {
}
/**
* Set the debug level of the native library
*/
private static native void setDebugLevel(int level);
/**
* Obtains the number of ticks that the hires timer does in a second.
*

View file

@ -142,7 +142,7 @@ public abstract class BaseAL {
private static String getPathFromJWS(String libname) {
try {
if(Sys.DEBUG) {
if(Sys.atDebugLevel()) {
System.out.println("JWS Classloader looking for: " + libname);
}
@ -154,7 +154,7 @@ public abstract class BaseAL {
return (String) findLibrary.invoke(o, arguments);
} catch (Exception e) {
if(Sys.DEBUG) {
if(Sys.atDebugLevel()) {
System.out.println("Failure locating OpenAL using classloader:");
e.printStackTrace();
}

View file

@ -162,13 +162,13 @@ public abstract class GLCaps {
}
private static void setExtensionFields(HashSet exts, HashMap field_map) {
if(org.lwjgl.Sys.DEBUG) {
if(org.lwjgl.Sys.atDebugLevel()) {
System.out.println("Available extensions:");
}
Iterator it = exts.iterator();
while (it.hasNext()) {
String ext = (String)it.next();
if(org.lwjgl.Sys.DEBUG) {
if(org.lwjgl.Sys.atDebugLevel()) {
System.out.println(ext);
}