moved Sys.log to LWJGLUtils and renamed property to org.lwjgl.util.Debug

This commit is contained in:
Brian Matzon 2005-03-29 18:09:33 +00:00
parent c9fc024fa4
commit ad8d7676c2
18 changed files with 89 additions and 83 deletions

View File

@ -9,7 +9,7 @@ Do not create the mouse when creating the display
org.lwjgl.opengl.Display.nokeyboard org.lwjgl.opengl.Display.nokeyboard
Do not create the keyboard when creating the display Do not create the keyboard when creating the display
org.lwjgl.Sys.debug org.lwjgl.util.Debug
Whether to output debug info Whether to output debug info
org.lwjgl.opengl.Display.allowSoftwareOpenGL org.lwjgl.opengl.Display.allowSoftwareOpenGL

View File

@ -63,7 +63,7 @@ abstract class J2SESysImplementation extends DefaultSysImplementation {
return (String)transferable.getTransferData(java.awt.datatransfer.DataFlavor.stringFlavor); return (String)transferable.getTransferData(java.awt.datatransfer.DataFlavor.stringFlavor);
} }
} catch (Exception e) { } catch (Exception e) {
Sys.log("Exception while getting clipboard: " + e); LWJGLUtil.log("Exception while getting clipboard: " + e);
} }
return null; return null;
} }

View File

@ -32,7 +32,6 @@
package org.lwjgl; package org.lwjgl;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.Sys;
import java.io.File; import java.io.File;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -51,7 +50,10 @@ import java.util.StringTokenizer;
*/ */
public class LWJGLUtil { public class LWJGLUtil {
/** /** Debug flag. */
public static final boolean DEBUG = Boolean.getBoolean("org.lwjgl.util.Debug");
/**
* Locates the paths required by a library. * Locates the paths required by a library.
* *
* @param libNames List of library names to look for, in the form of Local Library name, Platform library name. * @param libNames List of library names to look for, in the form of Local Library name, Platform library name.
@ -89,13 +91,13 @@ public class LWJGLUtil {
String classloader_path = LWJGLUtil.getPathFromClassLoader(libname, classloader); String classloader_path = LWJGLUtil.getPathFromClassLoader(libname, classloader);
if (classloader_path != null) { if (classloader_path != null) {
Sys.log("getPathFromClassLoader: Path found: " + classloader_path); LWJGLUtil.log("getPathFromClassLoader: Path found: " + classloader_path);
possible_paths.add(classloader_path); possible_paths.add(classloader_path);
} }
String lwjgl_classloader_path = LWJGLUtil.getPathFromClassLoader("lwjgl", classloader); String lwjgl_classloader_path = LWJGLUtil.getPathFromClassLoader("lwjgl", classloader);
if (lwjgl_classloader_path != null) { if (lwjgl_classloader_path != null) {
Sys.log("getPathFromClassLoader: Path found: " + lwjgl_classloader_path); LWJGLUtil.log("getPathFromClassLoader: Path found: " + lwjgl_classloader_path);
possible_paths.add(lwjgl_classloader_path.substring(0, lwjgl_classloader_path.lastIndexOf(File.separator)) possible_paths.add(lwjgl_classloader_path.substring(0, lwjgl_classloader_path.lastIndexOf(File.separator))
+ File.separator + platform_lib_name); + File.separator + platform_lib_name);
} }
@ -123,7 +125,7 @@ public class LWJGLUtil {
*/ */
public static String getPathFromClassLoader(String libname, ClassLoader classloader) { public static String getPathFromClassLoader(String libname, ClassLoader classloader) {
try { try {
Sys.log("getPathFromClassLoader: searching for: " + libname); LWJGLUtil.log("getPathFromClassLoader: searching for: " + libname);
Object o = classloader; Object o = classloader;
Class c = o.getClass(); Class c = o.getClass();
while (c != null) { while (c != null) {
@ -137,8 +139,19 @@ public class LWJGLUtil {
} }
} }
} catch (Exception e) { } catch (Exception e) {
Sys.log("Failure locating " + e + " using classloader:" + e); LWJGLUtil.log("Failure locating " + e + " using classloader:" + e);
} }
return null; return null;
} }
/**
* Prints the given message to System.err if DEBUG is true.
*
* @param msg Message to print
*/
public static void log(String msg) {
if (LWJGLUtil.DEBUG) {
System.err.println(msg);
}
}
} }

View File

@ -53,10 +53,7 @@ public final class Sys {
/** The native library name */ /** The native library name */
private static final String LIBRARY_NAME = "lwjgl"; private static final String LIBRARY_NAME = "lwjgl";
/** Debug flag. */ /** OS Name */
public static final boolean DEBUG = Boolean.getBoolean("org.lwjgl.Sys.debug");
/** OS Name */
private final static String OS_NAME = System.getProperty("os.name"); private final static String OS_NAME = System.getProperty("os.name");
/** The implementation instance to delegate platform specific behavior to */ /** The implementation instance to delegate platform specific behavior to */
@ -69,7 +66,7 @@ public final class Sys {
if (!native_version.equals(VERSION)) if (!native_version.equals(VERSION))
throw new LinkageError("Version mismatch: jar version is '" + VERSION + throw new LinkageError("Version mismatch: jar version is '" + VERSION +
"', native libary version is '" + native_version + "'"); "', native libary version is '" + native_version + "'");
implementation.setDebug(DEBUG); implementation.setDebug(LWJGLUtil.DEBUG);
} }
private static SysImplementation createImplementation() { private static SysImplementation createImplementation() {
@ -100,16 +97,6 @@ public final class Sys {
private Sys() { private Sys() {
} }
/**
* Prints the given message to System.err if isDebugEnabled()
* is true.
*/
public static void log(String msg) {
if (Sys.DEBUG) {
System.err.println(msg);
}
}
/** /**
* Initialization. This is just a dummy method to trigger the static constructor. * Initialization. This is just a dummy method to trigger the static constructor.
*/ */

View File

@ -38,7 +38,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.lwjgl.Sys; import org.lwjgl.LWJGLUtil;
/** /**
* $Id$ * $Id$
@ -276,7 +276,7 @@ public class FMOD {
} }
String jwsPath = getPathFromJWS(dllName); String jwsPath = getPathFromJWS(dllName);
Sys.log("getPathFromJWS: Paths found: " + jwsPath); LWJGLUtil.log("getPathFromJWS: Paths found: " + jwsPath);
if (jwsPath != null) { if (jwsPath != null) {
libpath += seperator libpath += seperator
+ jwsPath.substring(0, jwsPath.lastIndexOf(File.separator)); + jwsPath.substring(0, jwsPath.lastIndexOf(File.separator));
@ -292,7 +292,7 @@ public class FMOD {
} }
for(int i=0 ; i<paths.length; i++) { for(int i=0 ; i<paths.length; i++) {
Sys.log("Will search " + paths[i] + " for " + dllName); LWJGLUtil.log("Will search " + paths[i] + " for " + dllName);
} }
//add cwd path //add cwd path
@ -329,7 +329,7 @@ public class FMOD {
*/ */
private static String getPathFromJWS(String libname) { private static String getPathFromJWS(String libname) {
try { try {
Sys.log("getPathFromJWS: searching for: " + libname); LWJGLUtil.log("getPathFromJWS: searching for: " + libname);
Object o = FMOD.class.getClassLoader(); Object o = FMOD.class.getClassLoader();
Class c = o.getClass(); Class c = o.getClass();
Method findLibrary = Method findLibrary =
@ -338,7 +338,7 @@ public class FMOD {
return (String) findLibrary.invoke(o, arguments); return (String) findLibrary.invoke(o, arguments);
} catch (Exception e) { } catch (Exception e) {
Sys.log("Failure locating FMOD using classloader:" + e); LWJGLUtil.log("Failure locating FMOD using classloader:" + e);
} }
return null; return null;
} }
@ -360,7 +360,7 @@ public class FMOD {
if (callbackList == null ) { if (callbackList == null ) {
if (callbackHandler == null) { if (callbackHandler == null) {
Sys.log("No callbackhandlers registered for handle: " + handle); LWJGLUtil.log("No callbackhandlers registered for handle: " + handle);
} else { } else {
callbackList = new ArrayList(); callbackList = new ArrayList();
callbacks[type].put(callbackID, callbackList); callbacks[type].put(callbackID, callbackList);

View File

@ -38,6 +38,7 @@ import java.util.Map;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.Sys; import org.lwjgl.Sys;
import org.lwjgl.opengl.Display; import org.lwjgl.opengl.Display;
@ -526,7 +527,7 @@ public class Mouse {
try { try {
setNativeCursor(currentCursor); setNativeCursor(currentCursor);
} catch (LWJGLException e) { } catch (LWJGLException e) {
if (Sys.DEBUG) e.printStackTrace(); if (LWJGLUtil.DEBUG) e.printStackTrace();
} }
} }
} }

View File

@ -34,6 +34,7 @@ package org.lwjgl.opengl;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.Sys; import org.lwjgl.Sys;
/** /**
@ -198,7 +199,7 @@ final class Context {
thread = null; thread = null;
GLContext.unloadOpenGLLibrary(); GLContext.unloadOpenGLLibrary();
} catch (LWJGLException e) { } catch (LWJGLException e) {
Sys.log("Exception occurred while destroying context: " + e); LWJGLUtil.log("Exception occurred while destroying context: " + e);
} }
} }
} }

View File

@ -49,6 +49,7 @@ import java.util.HashSet;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.Sys; import org.lwjgl.Sys;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
@ -96,7 +97,7 @@ public final class Display {
display_impl = createDisplayImplementation(); display_impl = createDisplayImplementation();
try { try {
current_mode = initial_mode = display_impl.init(); current_mode = initial_mode = display_impl.init();
Sys.log("Initial mode: " + initial_mode); LWJGLUtil.log("Initial mode: " + initial_mode);
Runtime.getRuntime().addShutdownHook(new Thread() { Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() { public void run() {
reset(); reset();
@ -177,7 +178,7 @@ public final class Display {
DisplayMode[] filteredModes = new DisplayMode[modes.size()]; DisplayMode[] filteredModes = new DisplayMode[modes.size()];
modes.toArray(filteredModes); modes.toArray(filteredModes);
Sys.log("Removed " + (unfilteredModes.length - filteredModes.length) + " duplicate displaymodes"); LWJGLUtil.log("Removed " + (unfilteredModes.length - filteredModes.length) + " duplicate displaymodes");
return filteredModes; return filteredModes;
} }
@ -257,7 +258,7 @@ public final class Display {
if (context.isCurrent()) if (context.isCurrent())
Context.releaseCurrentContext(); Context.releaseCurrentContext();
} catch (LWJGLException e) { } catch (LWJGLException e) {
Sys.log("Exception occurred while trying to release context"); LWJGLUtil.log("Exception occurred while trying to release context");
} }
if (!window_created) if (!window_created)
@ -316,7 +317,7 @@ public final class Display {
gammaRamp.put(i, rampEntry); gammaRamp.put(i, rampEntry);
} }
display_impl.setGammaRamp(gammaRamp); display_impl.setGammaRamp(gammaRamp);
Sys.log("Gamma set, gamma = " + gamma + ", brightness = " + brightness + ", contrast = " + contrast); LWJGLUtil.log("Gamma set, gamma = " + gamma + ", brightness = " + brightness + ", contrast = " + contrast);
} }
/** /**
@ -628,10 +629,10 @@ public final class Display {
try { try {
Mouse.create(); Mouse.create();
} catch (LWJGLException e) { } catch (LWJGLException e) {
if (Sys.DEBUG) { if (LWJGLUtil.DEBUG) {
e.printStackTrace(System.err); e.printStackTrace(System.err);
} else { } else {
Sys.log("Failed to create Mouse: "+e); LWJGLUtil.log("Failed to create Mouse: "+e);
} }
} }
} }
@ -639,10 +640,10 @@ public final class Display {
try { try {
Keyboard.create(); Keyboard.create();
} catch (LWJGLException e) { } catch (LWJGLException e) {
if (Sys.DEBUG) { if (LWJGLUtil.DEBUG) {
e.printStackTrace(System.err); e.printStackTrace(System.err);
} else { } else {
Sys.log("Failed to create Keyboard: "+e); LWJGLUtil.log("Failed to create Keyboard: "+e);
} }
} }
} }

View File

@ -32,6 +32,7 @@
package org.lwjgl.opengl; package org.lwjgl.opengl;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.Sys; import org.lwjgl.Sys;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -169,7 +170,7 @@ public final class GLContext {
Method init_stubs_method = extension_class.getDeclaredMethod("initNativeStubs", null); Method init_stubs_method = extension_class.getDeclaredMethod("initNativeStubs", null);
init_stubs_method.invoke(null, null); init_stubs_method.invoke(null, null);
} catch (Exception e) { } catch (Exception e) {
Sys.log("Failed to initialize extension " + extension_class + " - exception: " + e); LWJGLUtil.log("Failed to initialize extension " + extension_class + " - exception: " + e);
supported_extensions.remove(ext_name); supported_extensions.remove(ext_name);
} }
} }

View File

@ -42,7 +42,7 @@ import java.nio.ByteBuffer;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import org.lwjgl.Sys; import org.lwjgl.LWJGLUtil;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
@ -383,7 +383,7 @@ final class LinuxDisplay implements DisplayImplementation {
decDisplay(); decDisplay();
return caps; return caps;
} catch (LWJGLException e) { } catch (LWJGLException e) {
Sys.log("Exception occurred in getPbufferCapabilities: " + e); LWJGLUtil.log("Exception occurred in getPbufferCapabilities: " + e);
return 0; return 0;
} finally { } finally {
unlockAWT(); unlockAWT();

View File

@ -57,7 +57,7 @@ import java.util.StringTokenizer;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
import org.lwjgl.Sys; import org.lwjgl.LWJGLUtil;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
final class MacOSXDisplay implements DisplayImplementation { final class MacOSXDisplay implements DisplayImplementation {
@ -376,7 +376,7 @@ final class MacOSXDisplay implements DisplayImplementation {
if (major_version > 10 || (major_version == 10 && minor_version >= 3)) if (major_version > 10 || (major_version == 10 && minor_version >= 3))
return Pbuffer.PBUFFER_SUPPORTED; return Pbuffer.PBUFFER_SUPPORTED;
} catch (Exception e) { } catch (Exception e) {
Sys.log("Exception occurred when trying to determine OS version: " + e); LWJGLUtil.log("Exception occurred when trying to determine OS version: " + e);
} }
return 0; return 0;
} }

View File

@ -34,6 +34,7 @@ package org.lwjgl.opengl;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.Sys; import org.lwjgl.Sys;
/** /**
@ -250,7 +251,7 @@ public final class Pbuffer implements Drawable {
peer_info.destroy(); peer_info.destroy();
destroyed = true; destroyed = true;
} catch (LWJGLException e) { } catch (LWJGLException e) {
Sys.log("Exception occurred while destroying pbuffer: " + e); LWJGLUtil.log("Exception occurred while destroying pbuffer: " + e);
} }
} }

View File

@ -42,7 +42,7 @@ import java.nio.ByteBuffer;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import org.lwjgl.Sys; import org.lwjgl.LWJGLUtil;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.input.Cursor; import org.lwjgl.input.Cursor;
@ -84,7 +84,7 @@ final class Win32Display implements DisplayImplementation {
if (Display.getContext().isCurrent()) if (Display.getContext().isCurrent())
Display.getContext().makeCurrent(); Display.getContext().makeCurrent();
} catch (LWJGLException e) { } catch (LWJGLException e) {
Sys.log("Exception occurred while trying to make context current: " + e); LWJGLUtil.log("Exception occurred while trying to make context current: " + e);
} }
} }
} }
@ -129,7 +129,7 @@ final class Win32Display implements DisplayImplementation {
// Return the capabilities of a minimum pixel format // Return the capabilities of a minimum pixel format
return nGetPbufferCapabilities(new PixelFormat(0, 0, 0, 0, 0, 0, 0, 0, false)); return nGetPbufferCapabilities(new PixelFormat(0, 0, 0, 0, 0, 0, 0, 0, false));
} catch (LWJGLException e) { } catch (LWJGLException e) {
Sys.log("Exception occurred while determining pbuffer capabilities: " + e); LWJGLUtil.log("Exception occurred while determining pbuffer capabilities: " + e);
return 0; return 0;
} }
} }

View File

@ -32,6 +32,7 @@
package org.lwjgl.test; package org.lwjgl.test;
import org.lwjgl.opengl.Display; import org.lwjgl.opengl.Display;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.Sys; import org.lwjgl.Sys;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
@ -67,8 +68,8 @@ public class SysTest {
*/ */
private void testDebug() { private void testDebug() {
System.out.println("==== Test Debug ===="); System.out.println("==== Test Debug ====");
if (Sys.DEBUG) { if (LWJGLUtil.DEBUG) {
Sys.log("Debug is enabled, you should now see output from LWJGL during the following tests."); LWJGLUtil.log("Debug is enabled, you should now see output from LWJGL during the following tests.");
} else { } else {
System.out.println("Debug is not enabled. Please set the org.lwjgl.Sys.debug property to true to enable debugging"); System.out.println("Debug is not enabled. Please set the org.lwjgl.Sys.debug property to true to enable debugging");
System.out.println("Example:\n java -Dorg.lwjgl.Sys.debug=true ..."); System.out.println("Example:\n java -Dorg.lwjgl.Sys.debug=true ...");

View File

@ -35,7 +35,7 @@ import java.nio.FloatBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
import org.lwjgl.Sys; import org.lwjgl.LWJGLUtil;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import org.lwjgl.openal.AL; import org.lwjgl.openal.AL;
@ -145,7 +145,7 @@ public class PositionTest extends BasicTest {
// Setup Window // Setup Window
// ===================================================== // =====================================================
Sys.log("Setting up window"); LWJGLUtil.log("Setting up window");
// calc center // calc center
int centerX = (Display.getDisplayMode().getWidth() - WINDOW_WIDTH) / 2; int centerX = (Display.getDisplayMode().getWidth() - WINDOW_WIDTH) / 2;
@ -158,7 +158,7 @@ public class PositionTest extends BasicTest {
// Setup OpenGL // Setup OpenGL
// ===================================================== // =====================================================
Sys.log("Setting up OpenGL"); LWJGLUtil.log("Setting up OpenGL");
GL11.glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); GL11.glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glMatrixMode(GL11.GL_PROJECTION);
@ -175,7 +175,7 @@ public class PositionTest extends BasicTest {
// Setup OpenAL // Setup OpenAL
// ===================================================== // =====================================================
Sys.log("Setting up OpenAL"); LWJGLUtil.log("Setting up OpenAL");
AL.create(); AL.create();
@ -184,7 +184,7 @@ public class PositionTest extends BasicTest {
AL10.alListener(AL10.AL_ORIENTATION, listenerOrientation); AL10.alListener(AL10.AL_ORIENTATION, listenerOrientation);
// creating buffers // creating buffers
Sys.log("Creating buffers"); LWJGLUtil.log("Creating buffers");
AL10.alGenBuffers(soundBuffers); AL10.alGenBuffers(soundBuffers);
soundBuffers.rewind(); soundBuffers.rewind();
@ -193,9 +193,9 @@ public class PositionTest extends BasicTest {
soundSources.rewind(); soundSources.rewind();
// load sound files (left, center, right).wav // load sound files (left, center, right).wav
Sys.log("Loading soundfiles..."); LWJGLUtil.log("Loading soundfiles...");
Sys.log("Loading left.wav"); LWJGLUtil.log("Loading left.wav");
WaveData left = WaveData.create("left.wav"); WaveData left = WaveData.create("left.wav");
AL10.alBufferData(soundBuffers.get(LEFT), left.format, left.data, left.samplerate); AL10.alBufferData(soundBuffers.get(LEFT), left.format, left.data, left.samplerate);
AL10.alSourcef(soundSources.get(LEFT), AL10.AL_PITCH, 1.0f); AL10.alSourcef(soundSources.get(LEFT), AL10.AL_PITCH, 1.0f);
@ -205,7 +205,7 @@ public class PositionTest extends BasicTest {
AL10.alSourcei(soundSources.get(LEFT), AL10.AL_BUFFER, soundBuffers.get(LEFT)); AL10.alSourcei(soundSources.get(LEFT), AL10.AL_BUFFER, soundBuffers.get(LEFT));
AL10.alSourcei(soundSources.get(LEFT), AL10.AL_LOOPING, AL10.AL_TRUE); AL10.alSourcei(soundSources.get(LEFT), AL10.AL_LOOPING, AL10.AL_TRUE);
Sys.log("Loading center.wav"); LWJGLUtil.log("Loading center.wav");
WaveData center = WaveData.create("center.wav"); WaveData center = WaveData.create("center.wav");
AL10.alBufferData(soundBuffers.get(CENTER), center.format, center.data, center.samplerate); AL10.alBufferData(soundBuffers.get(CENTER), center.format, center.data, center.samplerate);
AL10.alSourcef(soundSources.get(CENTER), AL10.AL_PITCH, 1.0f); AL10.alSourcef(soundSources.get(CENTER), AL10.AL_PITCH, 1.0f);
@ -215,7 +215,7 @@ public class PositionTest extends BasicTest {
AL10.alSourcei(soundSources.get(CENTER), AL10.AL_BUFFER, soundBuffers.get(CENTER)); AL10.alSourcei(soundSources.get(CENTER), AL10.AL_BUFFER, soundBuffers.get(CENTER));
AL10.alSourcei(soundSources.get(CENTER), AL10.AL_LOOPING, AL10.AL_TRUE); AL10.alSourcei(soundSources.get(CENTER), AL10.AL_LOOPING, AL10.AL_TRUE);
Sys.log("Loading right.wav"); LWJGLUtil.log("Loading right.wav");
WaveData right = WaveData.create("right.wav"); WaveData right = WaveData.create("right.wav");
AL10.alBufferData(soundBuffers.get(RIGHT), right.format, right.data, right.samplerate); AL10.alBufferData(soundBuffers.get(RIGHT), right.format, right.data, right.samplerate);
AL10.alSourcef(soundSources.get(RIGHT), AL10.AL_PITCH, 1.0f); AL10.alSourcef(soundSources.get(RIGHT), AL10.AL_PITCH, 1.0f);
@ -225,7 +225,7 @@ public class PositionTest extends BasicTest {
AL10.alSourcei(soundSources.get(RIGHT), AL10.AL_BUFFER, soundBuffers.get(RIGHT)); AL10.alSourcei(soundSources.get(RIGHT), AL10.AL_BUFFER, soundBuffers.get(RIGHT));
AL10.alSourcei(soundSources.get(RIGHT), AL10.AL_LOOPING, AL10.AL_TRUE); AL10.alSourcei(soundSources.get(RIGHT), AL10.AL_LOOPING, AL10.AL_TRUE);
Sys.log("Soundfiles loaded successfully"); LWJGLUtil.log("Soundfiles loaded successfully");
// ----------------------------------------------------- // -----------------------------------------------------
Mouse.setGrabbed(true); Mouse.setGrabbed(true);
@ -245,16 +245,16 @@ public class PositionTest extends BasicTest {
System.out.println("Press LEFT or RIGHT mouse button to move along z axis"); System.out.println("Press LEFT or RIGHT mouse button to move along z axis");
System.out.println("Press ESC to exit demo"); System.out.println("Press ESC to exit demo");
Sys.log( LWJGLUtil.log(
"Listener position: " "Listener position: "
+ listenerPosition.get(0) + listenerPosition.get(0)
+ ", " + ", "
+ listenerPosition.get(1) + listenerPosition.get(1)
+ ", " + ", "
+ listenerPosition.get(2)); + listenerPosition.get(2));
Sys.log("Left position: " + leftPosition.get(0) + ", " + leftPosition.get(1) + ", " + leftPosition.get(2)); LWJGLUtil.log("Left position: " + leftPosition.get(0) + ", " + leftPosition.get(1) + ", " + leftPosition.get(2));
Sys.log("Center position: " + centerPosition.get(0) + ", " + centerPosition.get(1) + ", " + centerPosition.get(2)); LWJGLUtil.log("Center position: " + centerPosition.get(0) + ", " + centerPosition.get(1) + ", " + centerPosition.get(2));
Sys.log("Right position: " + rightPosition.get(0) + ", " + rightPosition.get(1) + ", " + rightPosition.get(2)); LWJGLUtil.log("Right position: " + rightPosition.get(0) + ", " + rightPosition.get(1) + ", " + rightPosition.get(2));
while (!finished) { while (!finished) {
// handle any input // handle any input
@ -333,17 +333,17 @@ public class PositionTest extends BasicTest {
// ============================================ // ============================================
if (Keyboard.isKeyDown(Keyboard.KEY_1)) { if (Keyboard.isKeyDown(Keyboard.KEY_1)) {
AL10.alSourcePlay(soundSources.get(LEFT)); AL10.alSourcePlay(soundSources.get(LEFT));
Sys.log("Playing left.wav"); LWJGLUtil.log("Playing left.wav");
} }
if (Keyboard.isKeyDown(Keyboard.KEY_2)) { if (Keyboard.isKeyDown(Keyboard.KEY_2)) {
AL10.alSourcePlay(soundSources.get(CENTER)); AL10.alSourcePlay(soundSources.get(CENTER));
Sys.log("Playing center.wav"); LWJGLUtil.log("Playing center.wav");
} }
if (Keyboard.isKeyDown(Keyboard.KEY_3)) { if (Keyboard.isKeyDown(Keyboard.KEY_3)) {
AL10.alSourcePlay(soundSources.get(RIGHT)); AL10.alSourcePlay(soundSources.get(RIGHT));
Sys.log("Playing right.wav"); LWJGLUtil.log("Playing right.wav");
} }
// -------------------------------------------- // --------------------------------------------
@ -351,17 +351,17 @@ public class PositionTest extends BasicTest {
// ============================================ // ============================================
if (Keyboard.isKeyDown(Keyboard.KEY_4)) { if (Keyboard.isKeyDown(Keyboard.KEY_4)) {
AL10.alSourceStop(soundSources.get(LEFT)); AL10.alSourceStop(soundSources.get(LEFT));
Sys.log("Stopped left.wav"); LWJGLUtil.log("Stopped left.wav");
} }
if (Keyboard.isKeyDown(Keyboard.KEY_5)) { if (Keyboard.isKeyDown(Keyboard.KEY_5)) {
AL10.alSourceStop(soundSources.get(CENTER)); AL10.alSourceStop(soundSources.get(CENTER));
Sys.log("Stopped center.wav"); LWJGLUtil.log("Stopped center.wav");
} }
if (Keyboard.isKeyDown(Keyboard.KEY_6)) { if (Keyboard.isKeyDown(Keyboard.KEY_6)) {
AL10.alSourceStop(soundSources.get(RIGHT)); AL10.alSourceStop(soundSources.get(RIGHT));
Sys.log("Stopped right.wav"); LWJGLUtil.log("Stopped right.wav");
} }
// -------------------------------------------- // --------------------------------------------
@ -465,13 +465,13 @@ public class PositionTest extends BasicTest {
* Shutdown of demonstration * Shutdown of demonstration
*/ */
private void shutdown() { private void shutdown() {
Sys.log("Shutting down OpenAL"); LWJGLUtil.log("Shutting down OpenAL");
AL10.alSourceStop(soundSources); AL10.alSourceStop(soundSources);
AL10.alDeleteSources(soundSources); AL10.alDeleteSources(soundSources);
AL10.alDeleteBuffers(soundBuffers); AL10.alDeleteBuffers(soundBuffers);
AL.destroy(); AL.destroy();
Sys.log("Shutting down Window"); LWJGLUtil.log("Shutting down Window");
Display.destroy(); Display.destroy();
} }

View File

@ -36,7 +36,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import org.lwjgl.Sys; import org.lwjgl.LWJGLUtil;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.DisplayMode;
@ -71,7 +71,7 @@ public final class Display {
// First get the available display modes // First get the available display modes
DisplayMode[] modes = org.lwjgl.opengl.Display.getAvailableDisplayModes(); DisplayMode[] modes = org.lwjgl.opengl.Display.getAvailableDisplayModes();
if (Sys.DEBUG || DEBUG) { if (LWJGLUtil.DEBUG || DEBUG) {
System.out.println("Available screen modes:"); System.out.println("Available screen modes:");
for (int i = 0; i < modes.length; i ++) { for (int i = 0; i < modes.length; i ++) {
System.out.println(modes[i]); System.out.println(modes[i]);
@ -107,7 +107,7 @@ public final class Display {
DisplayMode[] ret = new DisplayMode[matches.size()]; DisplayMode[] ret = new DisplayMode[matches.size()];
matches.toArray(ret); matches.toArray(ret);
if (Sys.DEBUG && DEBUG) { if (LWJGLUtil.DEBUG && DEBUG) {
System.out.println("Filtered screen modes:"); System.out.println("Filtered screen modes:");
for (int i = 0; i < ret.length; i ++) { for (int i = 0; i < ret.length; i ++) {
System.out.println(ret[i]); System.out.println(ret[i]);
@ -210,7 +210,7 @@ public final class Display {
Arrays.sort(dm, new Sorter()); Arrays.sort(dm, new Sorter());
// Try them out in the appropriate order // Try them out in the appropriate order
if (Sys.DEBUG || DEBUG) { if (LWJGLUtil.DEBUG || DEBUG) {
System.out.println("Sorted display modes:"); System.out.println("Sorted display modes:");
for (int i = 0; i < dm.length; i ++) { for (int i = 0; i < dm.length; i ++) {
System.out.println(dm[i]); System.out.println(dm[i]);
@ -218,12 +218,12 @@ public final class Display {
} }
for (int i = 0; i < dm.length; i ++) { for (int i = 0; i < dm.length; i ++) {
try { try {
if (Sys.DEBUG || DEBUG) if (LWJGLUtil.DEBUG || DEBUG)
System.out.println("Attempting to set displaymode: "+dm[i]); System.out.println("Attempting to set displaymode: "+dm[i]);
org.lwjgl.opengl.Display.setDisplayMode(dm[i]); org.lwjgl.opengl.Display.setDisplayMode(dm[i]);
return dm[i]; return dm[i];
} catch (Exception e) { } catch (Exception e) {
if (Sys.DEBUG || DEBUG) { if (LWJGLUtil.DEBUG || DEBUG) {
System.out.println("Failed to set display mode to "+dm[i]); System.out.println("Failed to set display mode to "+dm[i]);
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -94,7 +94,7 @@ public class WaveData {
AudioSystem.getAudioInputStream( AudioSystem.getAudioInputStream(
new BufferedInputStream(WaveData.class.getClassLoader().getResourceAsStream(filepath)))); new BufferedInputStream(WaveData.class.getClassLoader().getResourceAsStream(filepath))));
} catch (Exception e) { } catch (Exception e) {
org.lwjgl.Sys.log("Unable to load file: " + filepath); org.lwjgl.LWJGLUtil.log("Unable to load file: " + filepath);
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }

View File

@ -82,7 +82,7 @@ void printfDebugJava(JNIEnv *env, const char *format, ...) {
#define BUFFER_SIZE 4000 #define BUFFER_SIZE 4000
static char buffer[BUFFER_SIZE]; static char buffer[BUFFER_SIZE];
jstring str; jstring str;
jclass org_lwjgl_Sys_class; jclass org_lwjgl_LWJGLUtil_class;
jmethodID log_method; jmethodID log_method;
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
@ -94,9 +94,9 @@ void printfDebugJava(JNIEnv *env, const char *format, ...) {
#endif #endif
buffer[BUFFER_SIZE - 1] = '\0'; buffer[BUFFER_SIZE - 1] = '\0';
str = (*env)->NewStringUTF(env, buffer); str = (*env)->NewStringUTF(env, buffer);
org_lwjgl_Sys_class = (*env)->FindClass(env, "org/lwjgl/Sys"); org_lwjgl_LWJGLUtil_class = (*env)->FindClass(env, "org/lwjgl/LWJGLUtil");
log_method = (*env)->GetStaticMethodID(env, org_lwjgl_Sys_class, "log", "(Ljava/lang/String;)V"); log_method = (*env)->GetStaticMethodID(env, org_lwjgl_LWJGLUtil_class, "log", "(Ljava/lang/String;)V");
(*env)->CallStaticVoidMethod(env, org_lwjgl_Sys_class, log_method, str); (*env)->CallStaticVoidMethod(env, org_lwjgl_LWJGLUtil_class, log_method, str);
} }
va_end(ap); va_end(ap);
} }