#include <assert.h>
#include <stdarg.h>
#include <dlfcn.h>
+#include <pthread.h>
+#include <inttypes.h>
#include "appledri.h"
#include "apple_glx.h"
#include "apple_glx_context.h"
#include "apple_cgl.h"
-#include "apple_xgl_api.h"
static bool initialized = false;
static int dri_event_base = 0;
-const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 };
-
-#ifndef OPENGL_LIB_PATH
-#define OPENGL_LIB_PATH "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
-#endif
-
-static void *libgl_handle = NULL;
-
-static bool diagnostic = false;
-
-void
-apple_glx_diagnostic(const char *fmt, ...)
-{
- va_list vl;
-
- if (diagnostic) {
- fprintf(stderr, "DIAG: ");
-
- va_start(vl, fmt);
- vfprintf(stderr, fmt, vl);
- va_end(vl);
- }
-}
-
int
apple_get_dri_event_base(void)
{
if (initialized)
return false;
- if (getenv("LIBGL_DIAGNOSTIC")) {
- printf("initializing libGL in %s\n", __func__);
- diagnostic = true;
- }
+ apple_glx_log_init();
+
+ apple_glx_log(ASL_LEVEL_INFO, "Initializing libGL.");
apple_cgl_init();
- apple_xgl_init_direct();
- libgl_handle = dlopen(OPENGL_LIB_PATH, RTLD_LAZY);
(void) apple_glx_get_client_id();
XAppleDRISetSurfaceNotifyHandler(surface_notify_handler);
{
struct apple_glx_context *ac = ptr;
- /* This may not be needed with CGLFlushDrawable: */
- glFlush();
apple_cgl.flush_drawable(ac->context_obj);
}
-void *
-apple_glx_get_proc_address(const GLubyte * procname)
-{
- size_t len;
- void *h, *s;
- char *pname = (char *) procname;
-
- assert(NULL != procname);
- len = strlen(pname);
-
- if (len < 3) {
- return NULL;
- }
-
- if ((pname != strstr(pname, "glX")) && (pname != strstr(pname, "gl"))) {
- fprintf(stderr,
- "warning: get proc address request is not for a gl or glX function");
- return NULL;
- }
-
- /* Search using the default symbols first. */
- (void) dlerror(); /*drain dlerror */
- h = dlopen(NULL, RTLD_NOW);
- if (NULL == h) {
- fprintf(stderr, "warning: get proc address: %s\n", dlerror());
- return NULL;
- }
-
- s = dlsym(h, pname);
-
- if (NULL == s) {
- /* Try the libGL.dylib from the OpenGL.framework. */
- s = dlsym(libgl_handle, pname);
- }
-
- dlclose(h);
-
- return s;
-}
-
void
apple_glx_waitx(Display * dpy, void *ptr)
{