From 8b947a575f7a8eecf27138d5e3882a43fb196e72 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 7 Sep 2003 16:11:15 +0000 Subject: [PATCH] *** empty log message *** --- src/native/Makefile.am | 4 +- src/native/autogen.sh | 1 - src/native/common/extal.cpp | 10 +- src/native/common/extal.h | 10 +- src/native/common/extgl.c | 193 +++++++++++++++++------------------ src/native/common/extgl.h | 26 ++--- src/native/configure.in | 16 +-- src/native/linux/Makefile.am | 4 +- 8 files changed, 125 insertions(+), 139 deletions(-) diff --git a/src/native/Makefile.am b/src/native/Makefile.am index f72c925e..22084926 100644 --- a/src/native/Makefile.am +++ b/src/native/Makefile.am @@ -2,5 +2,5 @@ SUBDIRS = common @native_build_dir@ lib_LTLIBRARIES = liblwjgl.la liblwjgl_la_SOURCES = -liblwjgl_la_LIBADD = common/libcommon.la linux/liblinux.la -liblwjgl_la_DEPENDENCIES = common/libcommon.la linux/liblinux.la +liblwjgl_la_LIBADD = common/libcommon.la @native_build_dir@/libnative.la +liblwjgl_la_DEPENDENCIES = common/libcommon.la @native_build_dir@/libnative.la diff --git a/src/native/autogen.sh b/src/native/autogen.sh index f70b7be1..a606dd28 100755 --- a/src/native/autogen.sh +++ b/src/native/autogen.sh @@ -1,5 +1,4 @@ aclocal autoheader -#libtoolize --automake automake --foreign --include-deps --add-missing --copy autoconf diff --git a/src/native/common/extal.cpp b/src/native/common/extal.cpp index 20eef598..e04944c7 100644 --- a/src/native/common/extal.cpp +++ b/src/native/common/extal.cpp @@ -127,7 +127,7 @@ HMODULE handleOAL; #ifdef _X11 void* handleOAL; #endif -#ifdef TARGET_OS_MAC +#ifdef _AGL #include OSStatus oalInitEntryPoints (void); void oalDellocEntryPoints (void); @@ -165,7 +165,7 @@ void* GetFunctionPointer(const char* function) { #ifdef _X11 return dlsym(handleOAL, function); #endif -#ifdef TARGET_OS_MAC +#ifdef _AGL return CFBundleGetFunctionPointerForName (handleOAL,CFStringCreateWithCStringNoCopy (NULL, function, CFStringGetSystemEncoding (), NULL)); #endif } @@ -191,7 +191,7 @@ void LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) { #ifdef _X11 handleOAL = dlopen(path_str, RTLD_LAZY); #endif -#ifdef TARGET_OS_MAC +#ifdef _AGL // NOTE: This totally ignores the input array! - SWP oalInitEntryPoints(); #endif @@ -215,7 +215,7 @@ void UnLoadOpenAL() { #ifdef _X11 dlclose(handleOAL); #endif -#ifdef TARGET_OS_MAC +#ifdef _AGL oalDellocEntryPoints(); #endif } @@ -431,7 +431,7 @@ int LoadALExtensions() { return JNI_TRUE; } -#ifdef TARGET_OS_MAC +#ifdef _AGL // ------------------------- OSStatus oalInitEntryPoints (void) { diff --git a/src/native/common/extal.h b/src/native/common/extal.h index 2cf40f5e..5d003214 100644 --- a/src/native/common/extal.h +++ b/src/native/common/extal.h @@ -61,12 +61,11 @@ extern "C" { #define ALCAPIENTRY __cdecl #else - #ifdef TARGET_OS_MAC - #if TARGET_OS_MAC + #ifdef _AGL + #if _AGL typedef struct ALCdevice_struct ALCdevice; typedef struct ALCcontext_struct ALCcontext; - #pragma export on #endif #endif #define ALCAPI @@ -116,11 +115,6 @@ typedef void ALCvoid; #define ALAPIENTRY __cdecl #define AL_CALLBACK #else - #ifdef TARGET_OS_MAC - #if TARGET_OS_MAC - #pragma export on - #endif - #endif #define ALAPI #define ALAPIENTRY #define AL_CALLBACK diff --git a/src/native/common/extgl.c b/src/native/common/extgl.c index d41beff6..e8efaa35 100644 --- a/src/native/common/extgl.c +++ b/src/native/common/extgl.c @@ -774,9 +774,9 @@ glXAllocateMemoryNVPROC glXAllocateMemoryNV = NULL; glXFreeMemoryNVPROC glXFreeMemoryNV = NULL; #endif /* X11 */ -#ifdef TARGET_OS_MAC +#ifdef _AGL // TODO: find the OSX equivalent of these functions -#endif /* TARGET_OS_MAC */ +#endif /* _AGL */ #endif /* GL_NV_vertex_array_range */ @@ -1359,10 +1359,93 @@ void * lib_gl_handle = NULL; void * lib_glu_handle = NULL; #endif -#ifdef TARGET_OS_MAC -// Note: Not used, there is a CFBundleRef in the header file that handles the -// dynamic load from the GL Framework bundle and this framework include gl -// and glu in the same library +#ifdef _AGL +CFBundleRef gBundleRefOpenGL = NULL; +#endif + +#ifdef _AGL +// ------------------------- +OSStatus aglInitEntryPoints (void) +{ + OSStatus err = noErr; + const Str255 frameworkName = "\pOpenGL.framework"; + FSRefParam fileRefParam; + FSRef fileRef; + CFURLRef bundleURLOpenGL; + memset(&fileRefParam, 0, sizeof(fileRefParam)); + memset(&fileRef, 0, sizeof(fileRef)); + fileRefParam.ioNamePtr = frameworkName; + fileRefParam.newRef = &fileRef; + + // Frameworks directory/folder + // + err = FindFolder (kSystemDomain, kFrameworksFolderType, false, &fileRefParam.ioVRefNum, &fileRefParam.ioDirID); + if (noErr != err) + { + DebugStr ("\pCould not find frameworks folder"); + return err; + } + + // make FSRef for folder + // + err = PBMakeFSRefSync (&fileRefParam); + + + if (noErr != err) + { + DebugStr ("\pCould make FSref to frameworks folder"); + return err; + } + + // create URL to folder + // + bundleURLOpenGL = CFURLCreateFromFSRef (kCFAllocatorDefault, &fileRef); + if (!bundleURLOpenGL) + { + DebugStr ("\pCould create OpenGL Framework bundle URL"); + return paramErr; + } + + // create ref to GL's bundle + // + gBundleRefOpenGL = CFBundleCreate (kCFAllocatorDefault,bundleURLOpenGL); + if (!gBundleRefOpenGL) + { + DebugStr ("\pCould not create OpenGL Framework bundle"); + return paramErr; + } + + // release created bundle + // + CFRelease (bundleURLOpenGL); + + // if the code was successfully loaded, look for our function. + if (!CFBundleLoadExecutable (gBundleRefOpenGL)) + { + DebugStr ("\pCould not load MachO executable"); + return paramErr; + } + + return err; +} + + +static void aglDellocEntryPoints (void) +{ + if (gBundleRefOpenGL != NULL) + { + // unload the bundle's code. + CFBundleUnloadExecutable (gBundleRefOpenGL); + CFRelease (gBundleRefOpenGL); + gBundleRefOpenGL = NULL; + } +} + + +static void * aglGetProcAddress (char * pszProc) +{ + return CFBundleGetFunctionPointerForName (gBundleRefOpenGL,CFStringCreateWithCStringNoCopy (NULL, pszProc, CFStringGetSystemEncoding (), NULL)); +} #endif /* getProcAddress */ @@ -1400,7 +1483,7 @@ static void *extgl_GetProcAddress(char *name) return t; #endif -#ifdef TARGET_OS_MAC +#ifdef _AGL void *t =(void *)aglGetProcAddress(name); return t; @@ -1560,7 +1643,7 @@ static int extgl_InitializeWGL() /*-----------------------------------------------------*/ /* AGL stuff BEGIN*/ /*-----------------------------------------------------*/ -#ifdef TARGET_OS_MAC +#ifdef _AGL static int extgl_InitializeAGL() { @@ -3286,7 +3369,7 @@ int extgl_Initialize() extgl_InitializeWGL(); #endif -#ifdef TARGET_OS_MAC +#ifdef _AGL /* load AGL extensions */ extgl_InitializeAGL(); #endif @@ -3331,7 +3414,7 @@ int extgl_Open(void) } #endif /* WIN32 */ -#ifdef TARGET_OS_MAC +#ifdef _AGL int extgl_Open(void) { OSStatus err = aglInitEntryPoints(); @@ -3347,7 +3430,7 @@ int extgl_Open(void) // return 0; } -#endif /* TARGET_OS_MAC */ +#endif /* _AGL */ void extgl_Close(void) { @@ -3359,97 +3442,11 @@ void extgl_Close(void) FreeLibrary(lib_gl_handle); FreeLibrary(lib_glu_handle); #endif -#ifdef TARGET_OS_MAC +#ifdef _AGL aglDellocEntryPoints(); #endif } -#ifdef TARGET_OS_MAC -CFBundleRef gBundleRefOpenGL = NULL; -// ------------------------- -OSStatus aglInitEntryPoints (void) -{ - OSStatus err = noErr; - const Str255 frameworkName = "\pOpenGL.framework"; - FSRefParam fileRefParam; - FSRef fileRef; - CFURLRef bundleURLOpenGL; - memset(&fileRefParam, 0, sizeof(fileRefParam)); - memset(&fileRef, 0, sizeof(fileRef)); - fileRefParam.ioNamePtr = frameworkName; - fileRefParam.newRef = &fileRef; - - // Frameworks directory/folder - // - err = FindFolder (kSystemDomain, kFrameworksFolderType, false, &fileRefParam.ioVRefNum, &fileRefParam.ioDirID); - if (noErr != err) - { - DebugStr ("\pCould not find frameworks folder"); - return err; - } - - // make FSRef for folder - // - err = PBMakeFSRefSync (&fileRefParam); - - - if (noErr != err) - { - DebugStr ("\pCould make FSref to frameworks folder"); - return err; - } - - // create URL to folder - // - bundleURLOpenGL = CFURLCreateFromFSRef (kCFAllocatorDefault, &fileRef); - if (!bundleURLOpenGL) - { - DebugStr ("\pCould create OpenGL Framework bundle URL"); - return paramErr; - } - - // create ref to GL's bundle - // - gBundleRefOpenGL = CFBundleCreate (kCFAllocatorDefault,bundleURLOpenGL); - if (!gBundleRefOpenGL) - { - DebugStr ("\pCould not create OpenGL Framework bundle"); - return paramErr; - } - - // release created bundle - // - CFRelease (bundleURLOpenGL); - - // if the code was successfully loaded, look for our function. - if (!CFBundleLoadExecutable (gBundleRefOpenGL)) - { - DebugStr ("\pCould not load MachO executable"); - return paramErr; - } - - return err; -} - - -static void aglDellocEntryPoints (void) -{ - if (gBundleRefOpenGL != NULL) - { - // unload the bundle's code. - CFBundleUnloadExecutable (gBundleRefOpenGL); - CFRelease (gBundleRefOpenGL); - gBundleRefOpenGL = NULL; - } -} - - -static void * aglGetProcAddress (char * pszProc) -{ - return CFBundleGetFunctionPointerForName (gBundleRefOpenGL,CFStringCreateWithCStringNoCopy (NULL, pszProc, CFStringGetSystemEncoding (), NULL)); -} -#endif - /* turn on the warning for the borland compiler*/ #ifdef __BORLANDC__ #pragma warn .8064 diff --git a/src/native/common/extgl.h b/src/native/common/extgl.h index d6ceb524..d0cf3651 100644 --- a/src/native/common/extgl.h +++ b/src/native/common/extgl.h @@ -324,7 +324,7 @@ extern glXQueryExtensionsStringPROC glXQueryExtensionsString; #endif /* X11 */ -#ifdef TARGET_OS_MAC +#ifdef _AGL #include #include #include @@ -337,10 +337,10 @@ typedef struct __AGLContextRec *AGLContext; typedef GDHandle AGLDevice; typedef CGrafPtr AGLDrawable; -OSStatus aglInitEntryPoints(void); +/*OSStatus aglInitEntryPoints(void); void aglDellocEntryPoints (void); void * aglGetProcAddress (char * pszProc); - +*/ typedef AGLPixelFormat (APIENTRY * aglChoosePixelFormatEXTPROC)(const AGLDevice *gdevs, GLint ndev, const GLint *attribs); typedef void (APIENTRY * aglDestroyPixelFormatEXTPROC)(AGLPixelFormat pix); typedef AGLPixelFormat (APIENTRY * aglNextPixelFormatEXTPROC)(AGLPixelFormat pix); @@ -593,7 +593,7 @@ extern aglSurfaceTextureEXTPROC aglSurfaceTexture; /************************************************************************/ -#endif /* TARGET_OS_MAC */ +#endif /* _AGL */ /*************************************************************/ /* GLU functions */ @@ -5829,11 +5829,11 @@ struct GLXExtensionTypes }; #endif /* X11 */ -#ifdef TARGET_OS_MAC +#ifdef _AGL struct AGLExtensionTypes { }; -#endif /* TARGET_OS_MAC */ +#endif /* _AGL */ struct GLUExtensionTypes { @@ -5851,9 +5851,9 @@ struct ExtensionTypes #ifdef _X11 struct GLXExtensionTypes glx; #endif /* X11 */ -#ifdef TARGET_OS_MAC +#ifdef _AGL struct AGLExtensionTypes agl; -#endif /* TARGET_OS_MAC */ +#endif /* _AGL */ struct GLUExtensionTypes glu; int ARB_imaging; @@ -5951,19 +5951,11 @@ extern struct ExtensionTypes extgl_Extensions; /* initializes everything, call this right after the rc is created. the function returns 0 if successful */ int extgl_Initialize(); +int extgl_Open(void); #ifdef _X11 -int extgl_Open(void); int extgl_InitGLX(Display *disp, int screen); #endif -#ifdef _WIN32 -int extgl_Open(void); -#endif - -#ifdef TARGET_OS_MAC -int extgl_Open(void); -#endif - void extgl_Close(void); int glInitialize(); /* deprecated, please do not use */ diff --git a/src/native/configure.in b/src/native/configure.in index 07504661..c2afb552 100644 --- a/src/native/configure.in +++ b/src/native/configure.in @@ -31,16 +31,17 @@ AC_LIBTOOL_DLOPEN AC_PROG_LIBTOOL case "$host_os" in - darwin*) _BUILD_FLAGS="-D_AGL" - AC_CHECK_HEADERS([altypes.h alctypes.h],, AC_MSG_ERROR([OpenAL headers required1])) - AC_SUBST(native_build_dir, [macosx]) + darwin*) _BUILD_FLAGS="-D_AGL -fpascal-strings -I/Library/Frameworks/OpenAL.framework/Headers" + AC_CHECK_HEADER([/Library/Frameworks/OpenAL.framework/Headers/altypes.h],, AC_MSG_ERROR([OpenAL headers required])) + AC_CHECK_HEADER([/Library/Frameworks/OpenAL.framework/Headers/alctypes.h],, AC_MSG_ERROR([OpenAL headers required])) + NATIVE_BUILD_DIR=macosx CXXFLAGS="$CXXFLAGS $DEBUG_FLAGS -Wall $_BUILD_FLAGS" CFLAGS="$CFLAGS $DEBUG_FLAGS -Wall $_BUILD_FLAGS" ;; bsdi* | linux* | solaris*) AC_PATH_XTRA _BUILD_FLAGS="-pthread -D_X11 $X_CFLAGS" AC_CHECK_HEADERS([AL/altypes.h AL/alctypes.h],, AC_MSG_ERROR([OpenAL headers required])) - AC_SUBST(native_build_dir, [linux]) + NATIVE_BUILD_DIR=linux CXXFLAGS="$CXXFLAGS $DEBUG_FLAGS -Wall $_BUILD_FLAGS" CFLAGS="$CFLAGS $DEBUG_FLAGS -Wall $_BUILD_FLAGS" LIBS="$LIBS $X_LIBS" @@ -50,9 +51,11 @@ case "$host_os" in AC_CHECK_LIB(pthread, pthread_create,, AC_MSG_ERROR(pthread is required)) ;; - *) AC_MSG_ERROR([Unknown system $host_os]);; + *) AC_MSG_ERROR([Unsupported system $host_os]);; esac +AC_SUBST(native_build_dir, [$NATIVE_BUILD_DIR]) + # Checks for libraries. # Checks for header files. @@ -79,5 +82,6 @@ AC_CHECK_FUNCS([gettimeofday memset strchr strstr]) AC_CONFIG_FILES([Makefile common/Makefile - linux/Makefile]) + linux/Makefile + macosx/Makefile]) AC_OUTPUT diff --git a/src/native/linux/Makefile.am b/src/native/linux/Makefile.am index 4e534277..8488d792 100644 --- a/src/native/linux/Makefile.am +++ b/src/native/linux/Makefile.am @@ -1,6 +1,6 @@ -noinst_LTLIBRARIES = liblinux.la +noinst_LTLIBRARIES = libnative.la -liblinux_la_SOURCES = $(NATIVE) +libnative_la_SOURCES = $(NATIVE) INCLUDES = -I../common NATIVE = \