/* Return true if an error occured. */ bool apple_init_glx(Display * dpy) { int eventBase, errorBase; int major, minor, patch; if (!XAppleDRIQueryExtension(dpy, &eventBase, &errorBase)) return true; if (!XAppleDRIQueryVersion(dpy, &major, &minor, &patch)) return true; if (initialized) return false; apple_glx_log_init(); apple_glx_log(ASL_LEVEL_INFO, "Initializing libGL."); apple_cgl_init(); (void) apple_glx_get_client_id(); XAppleDRISetSurfaceNotifyHandler(surface_notify_handler); /* This should really be per display. */ dri_event_base = eventBase; initialized = true; return false; }
/* Return true if an error occured. */ static bool create_surface(Display * dpy, int screen, struct apple_glx_drawable *d) { struct apple_glx_surface *s = &d->types.surface; unsigned int key[2]; xp_client_id id; id = apple_glx_get_client_id(); if (0 == id) return true; assert(None != d->drawable); s->pending_destroy = false; if (XAppleDRICreateSurface(dpy, screen, d->drawable, id, key, &s->uid)) { xp_error error; error = xp_import_surface(key, &s->surface_id); if (error) { fprintf(stderr, "error: xp_import_surface returned: %d\n", error); return true; } apple_glx_diagnostic("%s: created a surface for drawable 0x%lx" " with uid %u\n", __func__, d->drawable, s->uid); return false; /*success */ } return true; /* unable to create a surface. */ }