summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorathomas <[email protected]>2003-06-27 20:48:28 +0000
committerathomas <[email protected]>2003-06-27 20:48:28 +0000
commit02667f25fb77eb595948d731dfcd1f66d8e52373 (patch)
treeeb4d98135f94d8618d932e8766eeeb7c5447a7b0
parent65cca6ebd99b0c08b6772a495f4601edad5f0f5e (diff)
a few bug fixes and checks for nul
git-svn-id: file:///home/mbien/NetBeansProjects/JOGAMP/joal-sync/git-svn/../svn-server-sync/joal/trunk@40 03bf7f67-59de-4072-a415-9a990d468a3f
-rw-r--r--src/java/net/java/games/joal/ALCImpl.java46
-rw-r--r--src/java/net/java/games/joal/ALFactory.java12
2 files changed, 41 insertions, 17 deletions
diff --git a/src/java/net/java/games/joal/ALCImpl.java b/src/java/net/java/games/joal/ALCImpl.java
index d58b220..ed5906e 100644
--- a/src/java/net/java/games/joal/ALCImpl.java
+++ b/src/java/net/java/games/joal/ALCImpl.java
@@ -40,34 +40,42 @@ final class ALCImpl implements ALC {
ALCImpl() {
System.loadLibrary("joal");
+ /*
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
public void run() {
exit();
}
}));
+ */
}
public Device alcOpenDevice(String deviceName) {
Device result = null;
- result = new Device(openDeviceNative(deviceName));
-
+ int pointer = openDeviceNative(deviceName);
+ if(pointer != 0) {
+ result = new Device(openDeviceNative(deviceName));
+ }
return result;
}
private native int openDeviceNative(String deviceName);
public void alcCloseDevice(Device device) {
- closeDeviceNative(device.pointer);
+ if(device != null) {
+ closeDeviceNative(device.pointer);
+ }
}
private native void closeDeviceNative(int pointer);
public Context alcCreateContext(Device device, int[] attrs) {
Context result = null;
- int pointer = createContextNative(device.pointer, attrs);
- if (pointer != 0) {
- result = new Context(this, pointer);
- contextMap.put(new Integer(pointer), result);
+ if(device != null) {
+ int pointer = createContextNative(device.pointer, attrs);
+ if (pointer != 0) {
+ result = new Context(this, pointer);
+ contextMap.put(new Integer(pointer), result);
+ }
}
return result;
}
@@ -90,19 +98,25 @@ final class ALCImpl implements ALC {
private native int makeContextCurrentNative(int pointer);
public void alcProcessContext(Context context) {
- processContextNative(context.pointer);
+ if(context != null) {
+ processContextNative(context.pointer);
+ }
}
private native void processContextNative(int pointer);
public void alcSuspendContext(Context context) {
- suspendContextNative(context.pointer);
+ if(context != null) {
+ suspendContextNative(context.pointer);
+ }
}
private native void suspendContextNative(int pointer);
public void alcDestroyContext(Context context) {
- destroyContextNative(context.pointer);
+ if(context != null) {
+ destroyContextNative(context.pointer);
+ }
}
private native void destroyContextNative(int pointer);
@@ -112,7 +126,9 @@ final class ALCImpl implements ALC {
public Context alcGetCurrentContext() {
Context result = null;
int pointer = getCurrentContextNative();
- result = (Context) contextMap.get(new Integer(pointer));
+ if(pointer != 0) {
+ result = (Context) contextMap.get(new Integer(pointer));
+ }
return result;
}
@@ -155,8 +171,12 @@ final class ALCImpl implements ALC {
public Device alcGetContextsDevice(Context context) {
Device result = null;
- int devicePtr = getContextsDeviceNative(context.pointer);
- result = new ALC.Device(devicePtr);
+ if(context != null) {
+ int devicePtr = getContextsDeviceNative(context.pointer);
+ if(devicePtr != 0) {
+ result = new ALC.Device(devicePtr);
+ }
+ }
return result;
}
diff --git a/src/java/net/java/games/joal/ALFactory.java b/src/java/net/java/games/joal/ALFactory.java
index 70b6fd8..04276ad 100644
--- a/src/java/net/java/games/joal/ALFactory.java
+++ b/src/java/net/java/games/joal/ALFactory.java
@@ -82,10 +82,12 @@ public class ALFactory {
* @return the AL object
*/
public static AL getAL() {
- if (al == null) {
+ if(!isInitialized) {
+ initialize();
+ }
+ if (isInitialized && al == null) {
al = new ALImpl();
}
-
return al;
}
@@ -96,10 +98,12 @@ public class ALFactory {
* @return the ALC object
*/
public static ALC getALC() {
- if (alc == null) {
+ if(!isInitialized) {
+ initialize();
+ }
+ if (isInitialized && alc == null) {
alc = new ALCImpl();
}
-
return alc;
}
}