change: old JNI Cimplementaion upgraded to C++

This commit is contained in:
Brian Matzon 2002-08-15 15:41:38 +00:00
parent 3d0e916e03
commit a2d48f3ce0
2 changed files with 23 additions and 23 deletions

View File

@ -52,7 +52,7 @@
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALUT_init (JNIEnv *env, jobject obj, jobjectArray jargv) {
/* obtain the size the array */
jsize argc = (*env)->GetArrayLength(env, jargv);
jsize argc = env->GetArrayLength(jargv);
/* Declare a char array for argv */
const char* argv[128];
@ -60,23 +60,23 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALUT_init (JNIEnv *env, jobject obj
for (i=0;i<argc;i++) {
/* obtain the current object from the object array */
jobject string = (*env)->GetObjectArrayElement(env, jargv, i);
jstring string = (jstring) env->GetObjectArrayElement(jargv, i);
/* Convert the object just obtained into a String */
const char *str = (*env)->GetStringUTFChars(env, string, 0);
const char *str = env->GetStringUTFChars(string, 0);
/* Build the argv array */
argv[i] = str;
/* Free up memory to prevent memory leaks */
(*env)->ReleaseStringUTFChars(env, string, str);
env->ReleaseStringUTFChars(string, str);
}
/* Increment argc to adjust the difference between Java and C arguments */
argc++;
/* call the actual implementation */
alutInit(&((int)argc),(char**) argv);
alutInit((ALint*) &argc,(char**) argv);
}
/*
* This function loads a WAV file into memory from a file.
@ -109,19 +109,19 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALUT_loadWAVFile (JNIEnv *env, j
jint format, size, freq;
jboolean loop;
void* data;
ALbyte* filename = (ALbyte*) ((*env)->GetStringUTFChars(env, file, 0));
ALbyte* filename = (ALbyte*) (env->GetStringUTFChars(file, 0));
/* load wave file */
alutLoadWAVFile(filename, &format, (void**) &data, &size, &freq, &loop);
alutLoadWAVFile(filename, (ALenum*) &format, (void**) &data, (ALsizei*) &size, (ALsizei*) &freq, (ALboolean*) &loop);
/* get class */
alutLoadWAVFile_class = (*env)->FindClass(env, "org/lwjgl/openal/ALUTLoadWAVFile");
alutLoadWAVFile_class = env->FindClass("org/lwjgl/openal/ALUTLoadWAVFile");
/* get constructor */
methodID = (*env)->GetMethodID(env, alutLoadWAVFile_class, "<init>", "(IIIIZ)V");
methodID = env->GetMethodID(alutLoadWAVFile_class, "<init>", "(IIIIZ)V");
/* create object */
alutLoadWAVFile_object = (*env)->NewObject(env, alutLoadWAVFile_class, methodID, format, (int) data, size, freq, loop);
alutLoadWAVFile_object = env->NewObject(alutLoadWAVFile_class, methodID, format, (int) data, size, freq, loop);
return alutLoadWAVFile_object;
}

View File

@ -60,7 +60,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_openal_CoreAL_getError (JNIEnv *env, jobje
* ALubyte * alGetString(ALenum pname);
*/
JNIEXPORT jstring JNICALL Java_org_lwjgl_openal_CoreAL_getString (JNIEnv *env, jobject obj, jint param) {
return (*env)->NewStringUTF(env, alGetString(param));
return env->NewStringUTF((const char*) alGetString(param));
}
/**
@ -70,9 +70,9 @@ JNIEXPORT jstring JNICALL Java_org_lwjgl_openal_CoreAL_getString (JNIEnv *env, j
* ALvoid alGenBuffers(ALsizei n,ALuint *buffers);
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genBuffers (JNIEnv *env, jobject obj, jint n, jintArray buffers) {
int* array = (*env)->GetIntArrayElements(env, buffers, 0);
alGenBuffers(n, array);
(*env)->ReleaseIntArrayElements(env, buffers, array, 0);
int* array = (int*) env->GetIntArrayElements(buffers, 0);
alGenBuffers(n, (ALuint*) array);
env->ReleaseIntArrayElements(buffers, (jint*) array, 0);
}
/**
* This function generates one or more sources.
@ -81,9 +81,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genBuffers (JNIEnv *env, job
* ALvoid alGenSources(ALsizei n,ALuint *sources);
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genSources (JNIEnv *env, jobject obj, jint n, jintArray sources) {
int* array = (*env)->GetIntArrayElements(env, sources, 0);
alGenSources(n, array);
(*env)->ReleaseIntArrayElements(env, sources, array, 0);
int* array = (int*) env->GetIntArrayElements(sources, 0);
alGenSources(n, (ALuint*) array);
env->ReleaseIntArrayElements(sources, (jint*) array, 0);
}
/**
@ -133,9 +133,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceStop (JNIEnv *env, job
* ALvoid alDeleteSources(ALsizei n,ALuint *sources);
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_deleteSources (JNIEnv *env, jobject obj, jint n, jintArray source) {
int* array = (*env)->GetIntArrayElements(env, source, 0);
alDeleteSources(n, array);
(*env)->ReleaseIntArrayElements(env, source, array, 0);
int* array = (int*) env->GetIntArrayElements(source, 0);
alDeleteSources(n, (ALuint*) array);
env->ReleaseIntArrayElements(source, (jint*) array, 0);
}
/**
@ -145,7 +145,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_deleteSources (JNIEnv *env,
* ALvoid alDeleteBuffers(ALsizei n,ALuint *buffers);
*/
JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_deleteBuffers (JNIEnv *env, jobject obj, jint n, jintArray buffer) {
int* array = (*env)->GetIntArrayElements(env, buffer, 0);
alDeleteBuffers(n, array);
(*env)->ReleaseIntArrayElements(env, buffer, array, 0);
int* array = (int*) env->GetIntArrayElements(buffer, 0);
alDeleteBuffers(n, (ALuint*) array);
env->ReleaseIntArrayElements(buffer, (jint*) array, 0);
}