Ported codebase to Java 1.5.

Misc OpenCL fixes and API improvements.
Changed fractal demo to use events/sync objects instead of cl/glFinish for synchronization. (untested)
This commit is contained in:
Ioannis Tsakpinis 2010-09-28 21:11:35 +00:00
parent d17e13f24b
commit a8bcb7fd25
211 changed files with 7927 additions and 6549 deletions

View file

@ -1,31 +1,31 @@
/*
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
@ -47,14 +47,14 @@ import org.lwjgl.Sys;
*/
public final class AL {
/** ALCdevice instance. */
protected static ALCdevice device;
static ALCdevice device;
/** Current ALCcontext. */
protected static ALCcontext context;
static ALCcontext context;
/** Have we been created? */
private static boolean created;
static {
Sys.initialize();
}
@ -64,16 +64,14 @@ public final class AL {
/**
* Native method to create AL instance
*
* @param oalPaths Array of strings containing paths to search for OpenAL library
*
* @param oalPath Path to search for OpenAL library
*/
private static native void nCreate(String oalPath) throws LWJGLException;
/**
* Native method to create AL instance from the Mac OS X 10.4 OpenAL framework.
* It is only defined in the Mac OS X native library.
*
* @param oalPaths Array of strings containing paths to search for OpenAL library
*/
private static native void nCreateDefault() throws LWJGLException;
@ -81,36 +79,36 @@ public final class AL {
* Native method the destroy the AL
*/
private static native void nDestroy();
/**
* @return true if AL has been created
*/
public static boolean isCreated() {
return created;
}
}
/**
* Creates an OpenAL instance. Using this constructor will cause OpenAL to
* open the device using supplied device argument, and create a context using the context values
* supplied.
*
* supplied.
*
* @param deviceArguments Arguments supplied to native device
* @param contextFrequency Frequency for mixing output buffer, in units of Hz (Common values include 11025, 22050, and 44100).
* @param contextRefresh Refresh intervalls, in units of Hz.
* @param contextSynchronized Flag, indicating a synchronous context.*
*/
public static void create(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized)
* @param contextSynchronized Flag, indicating a synchronous context.*
*/
public static void create(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized)
throws LWJGLException {
create(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, true);
}
/**
* @param openDevice Whether to automatically open the device
* @see #create(String, int, int, boolean)
*/
public static void create(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized, boolean openDevice)
throws LWJGLException {
if (created)
throw new IllegalStateException("Only one OpenAL context may be instantiated at any one time.");
String libname;
@ -133,14 +131,14 @@ public final class AL {
}
String[] oalPaths = LWJGLUtil.getLibraryPaths(libname, library_names, AL.class.getClassLoader());
LWJGLUtil.log("Found " + oalPaths.length + " OpenAL paths");
for (int i = 0; i < oalPaths.length; i++) {
for ( String oalPath : oalPaths ) {
try {
nCreate(oalPaths[i]);
nCreate(oalPath);
created = true;
init(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, openDevice);
break;
} catch (LWJGLException e) {
LWJGLUtil.log("Failed to load " + oalPaths[i] + ": " + e.getMessage());
LWJGLUtil.log("Failed to load " + oalPath + ": " + e.getMessage());
}
}
if (!created && LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX) {
@ -157,18 +155,18 @@ public final class AL {
try {
AL10.initNativeStubs();
ALC10.initNativeStubs();
if(openDevice) {
device = ALC10.alcOpenDevice(deviceArguments);
if (device == null) {
throw new LWJGLException("Could not open ALC device");
}
if (contextFrequency == -1) {
context = ALC10.alcCreateContext(device, null);
} else {
context = ALC10.alcCreateContext(device,
ALCcontext.createAttributeList(contextFrequency, contextRefresh,
ALCcontext.createAttributeList(contextFrequency, contextRefresh,
contextSynchronized ? ALC10.ALC_TRUE : ALC10.ALC_FALSE));
}
ALC10.alcMakeContextCurrent(context);
@ -177,7 +175,7 @@ public final class AL {
destroy();
throw e;
}
ALC11.initialize();
// Load EFX10 native stubs if ALC_EXT_EFX is supported.
@ -197,7 +195,7 @@ public final class AL {
* open the default device, and create a context using default values.
* This method used to use default values that the OpenAL implementation
* chose but this produces unexpected results on some systems; so now
* it defaults to 44100Hz mixing @ 60Hz refresh.
* it defaults to 44100Hz mixing @ 60Hz refresh.
*/
public static void create() throws LWJGLException {
create(null, 44100, 60, false);
@ -228,7 +226,7 @@ public final class AL {
}
private static native void resetNativeStubs(Class clazz);
/**
* @return handle to the default AL context.
*/