*** empty log message ***

This commit is contained in:
Caspian Rychlik-Prince 2003-06-12 14:08:10 +00:00
parent 2e30eff2a5
commit 13edf0ce99
5 changed files with 111 additions and 88 deletions

View file

@ -107,6 +107,7 @@ public final class Sys {
}
}
/**
* @return the name of the native library to load

View file

@ -149,7 +149,7 @@ public abstract class Window {
/**
* Minimize the game and allow the operating system's default display to become
* visible. It is NOT the responsibility of LWJGL's native code to restore the display
* visible. It is the responsibility of LWJGL's native code to restore the display
* to its normal display settings.
*
* If the display is already minimized then this is a no-op.
@ -157,7 +157,7 @@ public abstract class Window {
public final native void minimize();
/**
* Restore the game and hide the operating system away. It is NOT the responsibility of
* Restore the game and hide the operating system away. It is the responsibility of
* LWJGL's native code to restore the display to its game display settings.
*
* If the display is not minimized then this is a no-op/

View file

@ -47,87 +47,90 @@ import java.util.StringTokenizer;
* @version $Revision$
*/
public abstract class BaseAL {
/** Have we been created? */
protected static boolean created;
static {
initialize();
}
/**
* Override to provide any initialization code after creation.
*/
protected void init() throws OpenALException {
}
/**
* Static initialization
*/
private static void initialize() {
System.loadLibrary(org.lwjgl.Sys.getLibraryName());
}
/**
* Creates the AL instance
*
* @throws Exception if a failiure occured in the AL creation process
*/
public void create() throws OpenALException {
if (created) {
return;
}
/** Have we been created? */
protected static boolean created;
// need to pass path of possible locations of OAL to native side
String libpath = System.getProperty("java.library.path");
String seperator = System.getProperty("path.separator");
String libname;
static {
initialize();
}
// libname is hardcoded atm - this will change in a near future...
libname = (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1)
? "libopenal.so"
: "OpenAL32.dll";
/**
* Override to provide any initialization code after creation.
*/
protected void init() throws OpenALException {
}
StringTokenizer st = new StringTokenizer(libpath, seperator);
//create needed string array
String[] oalPaths = new String[st.countTokens()+1];
/**
* Static initialization
*/
private static void initialize() {
System.loadLibrary(org.lwjgl.Sys.getLibraryName());
try {
System.loadLibrary("OpenAL32");
} catch (Exception e) {
System.loadLibrary("openal");
}
}
//build paths
for(int i=0;i<oalPaths.length - 1;i++) {
oalPaths[i] = st.nextToken() + File.separator + libname;
}
/**
* Creates the AL instance
*
* @throws Exception if a failiure occured in the AL creation process
*/
public void create() throws OpenALException {
if (created) {
return;
}
//add cwd path
oalPaths[oalPaths.length-1] = libname;
if (!nCreate(oalPaths)) {
throw new OpenALException("AL instance could not be created.");
}
init();
created = true;
}
/**
* Native method to create AL instance
*
* @param oalPaths Array of strings containing paths to search for OpenAL library
* @return true if the AL creation process succeeded
*/
protected native boolean nCreate(String[] oalPaths);
/**
* Calls whatever destruction rutines that are needed
*/
public void destroy() {
if (!created) {
return;
}
created = false;
nDestroy();
}
/**
* Native method the destroy the AL
*/
protected native void nDestroy();
// need to pass path of possible locations of OAL to native side
String libpath = System.getProperty("java.library.path");
String seperator = System.getProperty("path.separator");
String libname;
// libname is hardcoded atm - this will change in a near future...
libname = (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) ? "libopenal.so" : "OpenAL32.dll";
StringTokenizer st = new StringTokenizer(libpath, seperator);
//create needed string array
String[] oalPaths = new String[st.countTokens() + 1];
//build paths
for (int i = 0; i < oalPaths.length - 1; i++) {
oalPaths[i] = st.nextToken() + File.separator + libname;
}
//add cwd path
oalPaths[oalPaths.length - 1] = libname;
if (!nCreate(oalPaths)) {
throw new OpenALException("AL instance could not be created.");
}
init();
created = true;
}
/**
* Native method to create AL instance
*
* @param oalPaths Array of strings containing paths to search for OpenAL library
* @return true if the AL creation process succeeded
*/
protected native boolean nCreate(String[] oalPaths);
/**
* Calls whatever destruction rutines that are needed
*/
public void destroy() {
if (!created) {
return;
}
created = false;
nDestroy();
}
/**
* Native method the destroy the AL
*/
protected native void nDestroy();
}