summaryrefslogtreecommitdiffstats
path: root/src/native/alcbind.c
diff options
context:
space:
mode:
authorathomas <[email protected]>2003-11-23 01:39:59 +0000
committerathomas <[email protected]>2003-11-23 01:39:59 +0000
commit958b4a62bbfa639ad27756037049c9db3e7d3bf2 (patch)
treefc2bc580070c584a799c32e4509980e99309fb64 /src/native/alcbind.c
parentebe0f9a9ea29dd09332cafe65286f563bb08f6d6 (diff)
Several changes, uses newest lwjgl extal, throws exceptions from native code if AL doesn't load correctly and creates Context and Device objects in Native code.
git-svn-id: file:///home/mbien/NetBeansProjects/JOGAMP/joal-sync/git-svn/../svn-server-sync/joal/trunk@69 03bf7f67-59de-4072-a415-9a990d468a3f
Diffstat (limited to 'src/native/alcbind.c')
-rw-r--r--src/native/alcbind.c78
1 files changed, 76 insertions, 2 deletions
diff --git a/src/native/alcbind.c b/src/native/alcbind.c
index 48c1404..0917599 100644
--- a/src/native/alcbind.c
+++ b/src/native/alcbind.c
@@ -40,7 +40,7 @@ JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_alcGetErrorNative
return alcGetError((ALCdevice*)pointer);
}
-
+/*
JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_openDeviceNative
(JNIEnv *env, jobject obj, jstring deviceName) {
printf("Entering openDeviceNative()\n");
@@ -65,13 +65,54 @@ JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_openDeviceNative
printf("Exiting openDeviceNative()\n");
return result;
}
+*/
+JNIEXPORT jobject JNICALL Java_net_java_games_joal_ALCImpl_openDeviceNative
+ (JNIEnv *env, jobject obj, jstring deviceName) {
+ const char * tokenstring;
+
+ jboolean isCopy = JNI_FALSE;
+ if(deviceName != NULL) {
+ tokenstring = ((*env)->GetStringUTFChars(env, deviceName, &isCopy));
+ } else {
+ tokenstring = NULL;
+ }
+
+ /* get device */
+ ALCdevice* device = alcOpenDevice((ALubyte *) tokenstring);
+
+ /* if error - cleanup and get out */
+ if(device == NULL) {
+ if(tokenstring != NULL) {
+ (*env)->ReleaseStringUTFChars(env, deviceName, tokenstring);
+ }
+ return NULL;
+ }
+
+ /* get ready to create ALCdevice instance */
+ jobject alcDevice_object = NULL;
+ jclass alcDevice_class = NULL;
+ jmethodID alcDevice_method = NULL;
+
+ /* find class and constructor */
+ alcDevice_class = (*env)->FindClass(env, "net/java/games/joal/ALC$Device");
+ alcDevice_method = (*env)->GetMethodID(env, alcDevice_class, "<init>", "(I)V");
+
+ /* create instance */
+ alcDevice_object = (*env)->NewObject(env, alcDevice_class, alcDevice_method, (int) device);
+
+ /* clean up */
+ if (tokenstring != NULL)
+ (*env)->ReleaseStringUTFChars(env, deviceName, tokenstring);
+
+ return alcDevice_object;
+}
JNIEXPORT void JNICALL Java_net_java_games_joal_ALCImpl_closeDeviceNative
(JNIEnv *env, jobject obj, jint pointer) {
ALCdevice* device = (ALCdevice*)pointer;
alcCloseDevice(device);
}
-
+/*
JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_createContextNative
(JNIEnv *env, jobject obj, jint pointer, jintArray attrs) {
ALCdevice* device = (ALCdevice*)pointer;
@@ -86,6 +127,39 @@ JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_createContextNative
return ctxPtr;
}
}
+*/
+
+JNIEXPORT jobject JNICALL Java_net_java_games_joal_ALCImpl_createContextNative
+ (JNIEnv *env, jobject obj, jint deviceAddress, jintArray attrs) {
+ ALint* address = NULL;
+
+ if(attrs != NULL) {
+ address = (ALint*)(*env)->GetPrimitiveArrayCritical(env,attrs,0);
+ }
+ ALCcontext* context = alcCreateContext((ALCdevice*)deviceAddress, address);
+ if(address != NULL) {
+ (*env)->ReleasePrimitiveArrayCritical(env,attrs,address,0);
+ }
+ /* if error - get out */
+ if(context == NULL) {
+ return NULL;
+ }
+
+ /* get ready to create ALCcontext instance */
+ jobject alcContext_object = NULL;
+ jclass alcContext_class = NULL;
+ jmethodID alcContext_method = NULL;
+
+ /* find class and constructor */
+ alcContext_class = (*env)->FindClass(env, "net/java/games/joal/ALC$Context");
+ alcContext_method = (*env)->GetMethodID(env, alcContext_class, "<init>", "(Lnet/java/games/joal/ALC;I)V");
+
+ /* create instance */
+ alcContext_object = (*env)->NewObject(env, alcContext_class, alcContext_method, obj, (int) context);
+
+ return alcContext_object;
+}
+
JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_makeContextCurrentNative
(JNIEnv *env, jobject obj, jint pointer) {