diff options
Diffstat (limited to 'xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c')
-rw-r--r-- | xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c | 98 |
1 files changed, 96 insertions, 2 deletions
diff --git a/xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c b/xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c index 9b210ac6e..dfa7b8166 100644 --- a/xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c +++ b/xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c @@ -4,7 +4,7 @@ * **************************************************************/ /* - * Copyright (c) 2001 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2001-2003 Torrey T. Lyons. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -28,18 +28,29 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c,v 1.1 2002/03/28 02:21:19 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c,v 1.3 2003/01/19 06:35:13 torrey Exp $ */ #include <fcntl.h> +#include <unistd.h> +#include <CoreFoundation/CoreFoundation.h> #include "quartzCommon.h" #include "darwin.h" #include "opaque.h" +#include "micmap.h" int NSApplicationMain(int argc, char *argv[]); char **envpGlobal; // argcGlobal and argvGlobal // are from dix/globals.c +// GLX bundle function pointers +typedef void (*GlxExtensionInitPtr)(void); +static GlxExtensionInitPtr GlxExtensionInit = NULL; + +typedef void (*GlxWrapInitVisualsPtr)(miInitVisualsProcPtr *); +static GlxWrapInitVisualsPtr GlxWrapInitVisuals = NULL; + + /* * DarwinHandleGUI * This function is called first from main(). The first time @@ -92,6 +103,89 @@ void DarwinHandleGUI( exit(main_exit); } + +/* + * LoadGlxBundle + * The Quartz mode X server needs to dynamically load the appropriate + * bundle before initializing GLX. + */ +static void LoadGlxBundle(void) +{ + CFBundleRef mainBundle; + CFStringRef bundleName; + CFURLRef bundleURL; + CFBundleRef glxBundle; + + // Get the main bundle for the application + mainBundle = CFBundleGetMainBundle(); + + // Choose the bundle to load + ErrorF("Loading GLX bundle "); + if (quartzUseAGL) { + bundleName = CFSTR("glxAGL.bundle"); + ErrorF("glxAGL.bundle (using Apple's OpenGL)\n"); + } else { + bundleName = CFSTR("glxMesa.bundle"); + ErrorF("glxMesa.bundle (using Mesa)\n"); + } + + // Look for the appropriate GLX bundle in the main bundle by name + bundleURL = CFBundleCopyResourceURL(mainBundle, bundleName, + NULL, NULL); + if (!bundleURL) { + FatalError("Could not find GLX bundle."); + } + + // Make a bundle instance using the URLRef + glxBundle = CFBundleCreate(kCFAllocatorDefault, bundleURL); + + if (!CFBundleLoadExecutable(glxBundle)) { + FatalError("Could not load GLX bundle."); + } + + // Find the GLX init functions + GlxExtensionInit = (void *) CFBundleGetFunctionPointerForName( + glxBundle, CFSTR("GlxExtensionInit")); + + GlxWrapInitVisuals = (void *) CFBundleGetFunctionPointerForName( + glxBundle, CFSTR("GlxWrapInitVisuals")); + + if (!GlxExtensionInit || !GlxWrapInitVisuals) { + FatalError("Could not initialize GLX bundle."); + } + + // Release the CF objects + CFRelease(mainBundle); + CFRelease(bundleURL); +} + + +/* + * DarwinGlxExtensionInit + * Initialize the GLX extension. + */ +void DarwinGlxExtensionInit(void) +{ + if (!GlxExtensionInit) + LoadGlxBundle(); + + GlxExtensionInit(); +} + + +/* + * DarwinGlxWrapInitVisuals + */ +void DarwinGlxWrapInitVisuals( + miInitVisualsProcPtr *procPtr) +{ + if (!GlxWrapInitVisuals) + LoadGlxBundle(); + + GlxWrapInitVisuals(procPtr); +} + + int QuartzProcessArgument( int argc, char *argv[], int i ) { // fullscreen: CoreGraphics full-screen mode |