From 1a0b7c61155813ac0bf3c6d58b4dac15f0225101 Mon Sep 17 00:00:00 2001 From: kbr Date: Tue, 10 Jan 2006 11:07:30 +0000 Subject: Merged gluegen-branch-1-0 on to the main JOAL trunk. JOAL is now built using GlueGen and currently requires a built JOGL workspace as a sibling workspace of the JOAL workspace. git-svn-id: file:///home/mbien/NetBeansProjects/JOGAMP/joal-sync/git-svn/../svn-server-sync/joal/trunk@101 03bf7f67-59de-4072-a415-9a990d468a3f --- make/joal-CustomCCode.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 make/joal-CustomCCode.c (limited to 'make/joal-CustomCCode.c') diff --git a/make/joal-CustomCCode.c b/make/joal-CustomCCode.c new file mode 100755 index 0000000..a6d0bb6 --- /dev/null +++ b/make/joal-CustomCCode.c @@ -0,0 +1,40 @@ +#if defined(_MSC_VER) /* Windows */ +#include +static HMODULE oalModule = NULL; +#endif + +/* Java->C glue code: + * Java package: net.java.games.joal.impl.ALImpl + * Java method: long dynamicLookupFunction0(java.lang.String fname) + * C function: ALproc alGetProcAddress(const ALchar * fname); + */ +JNIEXPORT jlong JNICALL +Java_net_java_games_joal_impl_ALImpl_dynamicLookupFunction0__Ljava_lang_String_2(JNIEnv *env, jobject _unused, jstring fname) { + const char* _UTF8fname = NULL; + ALproc _res; + if (fname != NULL) { + if (fname != NULL) { + _UTF8fname = (*env)->GetStringUTFChars(env, fname, (jboolean*)NULL); + if (_UTF8fname == NULL) { + (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"), + "Failed to get UTF-8 chars for argument \"fname\" in native dispatcher for \"alGetProcAddress\""); + return 0; + } + } + } +#if defined(_MSC_VER) /* Windows */ + if (oalModule == NULL) { + oalModule = GetModuleHandle("OpenAL32"); + } + _res = (ALproc) GetProcAddress(oalModule, _UTF8fname); +/* Looks like we can use dlsym on OS X as well as other Unix flavors */ +/* #elif defined(__APPLE__) && defined(__MACH__) */ /* OS X */ +#else /* Assume vanilla Unix */ + _res = (ALproc) dlsym(RTLD_DEFAULT, _UTF8fname); +#endif + + if (fname != NULL) { + (*env)->ReleaseStringUTFChars(env, fname, _UTF8fname); + } + return (jlong) (intptr_t) _res; +} -- cgit v1.2.3