Linux: removed redundant last_z from Mouse.c. Mac: Compile fixes. Use NSAddImage for loading GL library

This commit is contained in:
Elias Naur 2004-11-05 10:30:04 +00:00
parent 7ecf2516fb
commit b4fde6438a
5 changed files with 33 additions and 151 deletions

View File

@ -144,7 +144,6 @@ static void closeVorbisLibs(void) {
* Loads the OpenAL Library * Loads the OpenAL Library
*/ */
static bool LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) { static bool LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) {
jsize pathcount = (*env)->GetArrayLength(env, oalPaths); jsize pathcount = (*env)->GetArrayLength(env, oalPaths);
int i; int i;
jstring path; jstring path;
@ -159,33 +158,33 @@ static bool LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) {
#ifdef _WIN32 #ifdef _WIN32
lib_str = concatenate(path_str, "lwjglaudio.dll"); lib_str = concatenate(path_str, "lwjglaudio.dll");
handleOAL = LoadLibrary(lib_str); handleOAL = LoadLibrary(lib_str);
free(lib_str); free(lib_str);
#endif #endif
#ifdef _X11 #ifdef _X11
char *lib_str = concatenate(path_str, "libogg.so.0"); lib_str = concatenate(path_str, "libogg.so.0");
handleOGG = dlopen(lib_str, RTLD_LAZY); handleOGG = dlopen(lib_str, RTLD_LAZY);
free(lib_str); free(lib_str);
lib_str = concatenate(path_str, "libvorbis.so.0"); lib_str = concatenate(path_str, "libvorbis.so.0");
handleVorbis = dlopen(lib_str, RTLD_LAZY); handleVorbis = dlopen(lib_str, RTLD_LAZY);
free(lib_str); free(lib_str);
lib_str = concatenate(path_str, "libvorbisfile.so.3"); lib_str = concatenate(path_str, "libvorbisfile.so.3");
handleVorbisFile = dlopen(lib_str, RTLD_LAZY); handleVorbisFile = dlopen(lib_str, RTLD_LAZY);
free(lib_str); free(lib_str);
lib_str = concatenate(path_str, "libopenal.so"); lib_str = concatenate(path_str, "libopenal.so");
handleOAL = dlopen(lib_str, RTLD_LAZY); handleOAL = dlopen(lib_str, RTLD_LAZY);
free(lib_str); free(lib_str);
if (handleOAL == NULL) { if (handleOAL == NULL) {
closeVorbisLibs(); closeVorbisLibs();
} }
#endif #endif
#ifdef _MACOSX #ifdef _MACOSX
char *lib_str = concatenate(path_str, "openal.dylib"); lib_str = concatenate(path_str, "openal.dylib");
handleOAL = NSAddImage(lib_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR); handleOAL = NSAddImage(lib_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
free(lib_str); free(lib_str);
#endif #endif
if (handleOAL != NULL) { if (handleOAL != NULL) {
printfDebug("Found OpenAL at '%s'\n", path_str); printfDebug("Found OpenAL at '%s'\n", path_str);

View File

@ -85,7 +85,9 @@ aglResetLibraryPROC aglResetLibrary = NULL;
aglSurfaceTexturePROC aglSurfaceTexture = NULL; aglSurfaceTexturePROC aglSurfaceTexture = NULL;
#endif #endif
#ifndef _MACOSX
struct ExtensionTypes extgl_Extensions; struct ExtensionTypes extgl_Extensions;
#endif
#ifdef _WIN32 #ifdef _WIN32
HMODULE lib_gl_handle = NULL; HMODULE lib_gl_handle = NULL;
@ -100,8 +102,8 @@ static glXGetProcAddressARBPROC glXGetProcAddressARB;
#endif #endif
#ifdef _MACOSX #ifdef _MACOSX
CFBundleRef opengl_bundle_ref = NULL; #include <mach-o/dyld.h>
//CFBundleRef agl_bundle_ref = NULL; static const struct mach_header *opengl_lib_handle = NULL;
#endif #endif
/* getProcAddress */ /* getProcAddress */
@ -135,16 +137,16 @@ void *extgl_GetProcAddress(const char *name)
#endif #endif
#ifdef _MACOSX #ifdef _MACOSX
CFStringRef str = CFStringCreateWithCStringNoCopy(NULL, name, kCFStringEncodingUTF8, kCFAllocatorNull); #define BUFFER_SIZE 1024
void *func_pointer = CFBundleGetFunctionPointerForName(opengl_bundle_ref, str); char mach_name[BUFFER_SIZE] = "_";
if (func_pointer == NULL) { strncat(mach_name, name, BUFFER_SIZE - 1);
/* func_pointer = CFBundleGetFunctionPointerForName(agl_bundle_ref, str);
if (func_pointer == NULL) {*/ if (NSIsSymbolNameDefinedInImage(opengl_lib_handle, mach_name)) {
printfDebug("Could not locate symbol %s\n", name); NSSymbol sym = NSLookupSymbolInImage(opengl_lib_handle, mach_name, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
// } void *address = NSAddressOfSymbol(sym);
} return address;
CFRelease(str); } else
return func_pointer; return NULL;
#endif #endif
} }
@ -157,74 +159,9 @@ bool extgl_InitializeFunctions(int num_functions, ExtFunction *functions) {
} }
#ifdef _MACOSX #ifdef _MACOSX
// ------------------------- static const struct mach_header *loadImage(const char *lib_name) {
static CFBundleRef loadBundle(const Str255 frameworkName) return NSAddImage(lib_name, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
{
OSStatus err = noErr;
FSRefParam fileRefParam;
FSRef fileRef;
CFURLRef bundleURLOpenGL;
CFBundleRef bundle_ref;
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)
{
printfDebug("Could not find frameworks folder\n");
return NULL;
}
// make FSRef for folder
//
err = PBMakeFSRefSync (&fileRefParam);
if (noErr != err)
{
printfDebug("Could make FSref to frameworks folder\n");
return NULL;
}
// create URL to folder
//
bundleURLOpenGL = CFURLCreateFromFSRef (kCFAllocatorDefault, &fileRef);
if (!bundleURLOpenGL)
{
printfDebug("Could create framework URL\n");
return NULL;
}
bundle_ref = CFBundleCreate(kCFAllocatorDefault,bundleURLOpenGL);
CFRelease (bundleURLOpenGL);
if (bundle_ref == NULL)
{
printfDebug("Could not load framework\n");
return NULL;
}
// if the code was successfully loaded, look for our function.
if (!CFBundleLoadExecutable(bundle_ref))
{
printfDebug("Could not load MachO executable\n");
CFRelease(bundle_ref);
return NULL;
}
return bundle_ref;
} }
static void aglUnloadFramework(CFBundleRef f)
{
CFBundleUnloadExecutable(f);
CFRelease(f);
}
#endif #endif
bool extgl_QueryExtension(JNIEnv *env, const GLubyte*extensions, const char *name) bool extgl_QueryExtension(JNIEnv *env, const GLubyte*extensions, const char *name)
@ -262,69 +199,16 @@ bool extgl_QueryExtension(JNIEnv *env, const GLubyte*extensions, const char *nam
} }
/*-----------------------------------------------------*/
/* AGL stuff BEGIN*/
/*-----------------------------------------------------*/
#ifdef _MACOSX
// Commecnted out as AGL is not needed
/*bool extgl_InitAGL(JNIEnv *env)
{
aglChoosePixelFormat = (aglChoosePixelFormatPROC)extgl_GetProcAddress("aglChoosePixelFormat");
aglDestroyPixelFormat = (aglDestroyPixelFormatPROC)extgl_GetProcAddress("aglDestroyPixelFormat");
aglNextPixelFormat = (aglNextPixelFormatPROC)extgl_GetProcAddress("aglNextPixelFormat");
aglDescribePixelFormat = (aglDescribePixelFormatPROC)extgl_GetProcAddress("aglDescribePixelFormat");
aglDevicesOfPixelFormat = (aglDevicesOfPixelFormatPROC)extgl_GetProcAddress("aglDevicesOfPixelFormat");
aglQueryRendererInfo = (aglQueryRendererInfoPROC)extgl_GetProcAddress("aglQueryRendererInfo");
aglDestroyRendererInfo = (aglDestroyRendererInfoPROC)extgl_GetProcAddress("aglDestroyRendererInfo");
aglNextRendererInfo = (aglNextRendererInfoPROC)extgl_GetProcAddress("aglNextRendererInfo");
aglDescribeRenderer = (aglDescribeRendererPROC)extgl_GetProcAddress("aglDescribeRenderer");
aglCreateContext = (aglCreateContextPROC)extgl_GetProcAddress("aglCreateContext");
aglDestroyContext = (aglDestroyContextPROC)extgl_GetProcAddress("aglDestroyContext");
aglCopyContext = (aglCopyContextPROC)extgl_GetProcAddress("aglCopyContext");
aglUpdateContext = (aglUpdateContextPROC)extgl_GetProcAddress("aglUpdateContext");
aglSetCurrentContext = (aglSetCurrentContextPROC)extgl_GetProcAddress("aglSetCurrentContext");
aglGetCurrentContext = (aglGetCurrentContextPROC)extgl_GetProcAddress("aglGetCurrentContext");
aglSetDrawable = (aglSetDrawablePROC)extgl_GetProcAddress("aglSetDrawable");
aglSetOffScreen = (aglSetOffScreenPROC)extgl_GetProcAddress("aglSetOffScreen");
aglSetFullScreen = (aglSetFullScreenPROC)extgl_GetProcAddress("aglSetFullScreen");
aglGetDrawable = (aglGetDrawablePROC)extgl_GetProcAddress("aglGetDrawable");
aglSetVirtualScreen = (aglSetVirtualScreenPROC)extgl_GetProcAddress("aglSetVirtualScreen");
aglGetVirtualScreen = (aglGetVirtualScreenPROC)extgl_GetProcAddress("aglGetVirtualScreen");
aglGetVersion = (aglGetVersionPROC)extgl_GetProcAddress("aglGetVersion");
aglSwapBuffers = (aglSwapBuffersPROC)extgl_GetProcAddress("aglSwapBuffers");
aglEnable = (aglEnablePROC)extgl_GetProcAddress("aglEnable");
aglDisable = (aglDisablePROC)extgl_GetProcAddress("aglDisable");
aglIsEnabled = (aglIsEnabledPROC)extgl_GetProcAddress("aglIsEnabled");
aglSetInteger = (aglSetIntegerPROC)extgl_GetProcAddress("aglSetInteger");
aglGetInteger = (aglGetIntegerPROC)extgl_GetProcAddress("aglGetInteger");
aglUseFont = (aglUseFontPROC)extgl_GetProcAddress("aglUseFont");
aglGetError = (aglGetErrorPROC)extgl_GetProcAddress("aglGetError");
aglErrorString = (aglErrorStringPROC)extgl_GetProcAddress("aglErrorString");
aglResetLibrary = (aglResetLibraryPROC)extgl_GetProcAddress("aglResetLibrary");
aglSurfaceTexture = (aglSurfaceTexturePROC)extgl_GetProcAddress("aglSurfaceTexture");
return !extgl_error; // Split out AGL into extgl_agl.cpp like wgl and glx and replace with InitializeFunctions
}
*/
#endif
/*-----------------------------------------------------*/ /*-----------------------------------------------------*/
/* AGL stuff END*/ /* AGL stuff END*/
/*-----------------------------------------------------*/ /*-----------------------------------------------------*/
#ifdef _MACOSX #ifdef _MACOSX
bool extgl_Open(void) { bool extgl_Open(void) {
if (opengl_bundle_ref != NULL) if (opengl_lib_handle != NULL)
return true; return true;
opengl_bundle_ref = loadBundle("\pOpenGL.framework"); opengl_lib_handle = loadImage("/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib");
if (opengl_bundle_ref == NULL) return opengl_lib_handle != NULL;
return false;
/* agl_bundle_ref = loadBundle("\pAGL.framework");
if (agl_bundle_ref == NULL) {
aglUnloadFramework(opengl_bundle_ref);
return false;
}*/
return true;
} }
#endif #endif
@ -372,9 +256,7 @@ void extgl_Close(void)
lib_gl_handle = NULL; lib_gl_handle = NULL;
#endif #endif
#ifdef _MACOSX #ifdef _MACOSX
aglUnloadFramework(opengl_bundle_ref); opengl_lib_handle = NULL;
// aglUnloadFramework(agl_bundle_ref);
opengl_bundle_ref = NULL;
#endif #endif
} }

View File

@ -399,6 +399,7 @@ extern aglSurfaceTexturePROC aglSurfaceTexture;
/* helper stuff */ /* helper stuff */
#ifndef _MACOSX
struct ExtensionTypes struct ExtensionTypes
{ {
#ifdef _WIN32 /* WGL extensions */ #ifdef _WIN32 /* WGL extensions */
@ -425,6 +426,7 @@ struct ExtensionTypes
}; };
extern struct ExtensionTypes extgl_Extensions; extern struct ExtensionTypes extgl_Extensions;
#endif
typedef GLenum (APIENTRY * glGetErrorPROC) (void); typedef GLenum (APIENTRY * glGetErrorPROC) (void);
typedef const GLubyte * (APIENTRY * glGetStringPROC) (GLenum name); typedef const GLubyte * (APIENTRY * glGetStringPROC) (GLenum name);

View File

@ -312,7 +312,7 @@ static glGenTexturesPROC glGenTextures;
static glGetBooleanvPROC glGetBooleanv; static glGetBooleanvPROC glGetBooleanv;
static glGetClipPlanePROC glGetClipPlane; static glGetClipPlanePROC glGetClipPlane;
static glGetDoublevPROC glGetDoublev; static glGetDoublevPROC glGetDoublev;
glGetErrorPROC glGetError; glGetErrorPROC glGetError = NULL;
static glGetFloatvPROC glGetFloatv; static glGetFloatvPROC glGetFloatv;
static glGetIntegervPROC glGetIntegerv; static glGetIntegervPROC glGetIntegerv;
static glGetLightfvPROC glGetLightfv; static glGetLightfvPROC glGetLightfv;
@ -326,7 +326,7 @@ static glGetPixelMapuivPROC glGetPixelMapuiv;
static glGetPixelMapusvPROC glGetPixelMapusv; static glGetPixelMapusvPROC glGetPixelMapusv;
static glGetPointervPROC glGetPointerv; static glGetPointervPROC glGetPointerv;
static glGetPolygonStipplePROC glGetPolygonStipple; static glGetPolygonStipplePROC glGetPolygonStipple;
glGetStringPROC glGetString; glGetStringPROC glGetString = NULL;
static glGetTexEnvfvPROC glGetTexEnvfv; static glGetTexEnvfvPROC glGetTexEnvfv;
static glGetTexEnvivPROC glGetTexEnviv; static glGetTexEnvivPROC glGetTexEnviv;
static glGetTexGenfvPROC glGetTexGenfv; static glGetTexGenfvPROC glGetTexGenfv;

View File

@ -67,7 +67,6 @@ static int last_poll_x;
static int last_poll_y; static int last_poll_y;
static int last_event_x; static int last_event_x;
static int last_event_y; static int last_event_y;
static int last_z;
static jbyte buttons[NUM_BUTTONS]; static jbyte buttons[NUM_BUTTONS];
static event_queue_t event_queue; static event_queue_t event_queue;
static bool buffer_enabled; static bool buffer_enabled;
@ -251,7 +250,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_createMouse
if (disp == NULL) if (disp == NULL)
return; return;
int i; int i;
last_z = last_poll_y = last_poll_x = last_event_x = last_event_y = accum_dx = accum_dy = accum_dz = 0; last_poll_y = last_poll_x = last_event_x = last_event_y = accum_dx = accum_dy = accum_dz = 0;
resetCursorToCenter(); resetCursorToCenter();
for (i = 0; i < NUM_BUTTONS; i++) for (i = 0; i < NUM_BUTTONS; i++)
buttons[i] = 0; buttons[i] = 0;