/* This returns a referenced object via resultptr. */ bool apple_glx_surface_create(Display * dpy, int screen, GLXDrawable drawable, struct apple_glx_drawable ** resultptr) { struct apple_glx_drawable *d; if (apple_glx_drawable_create(dpy, screen, drawable, &d, &callbacks)) return true; /* apple_glx_drawable_create creates a locked and referenced object. */ if (create_surface(dpy, screen, d)) { d->unlock(d); d->destroy(d); return true; } *resultptr = d; d->unlock(d); return false; }
/* Return true if an error occurred. */ bool apple_glx_pbuffer_create(Display * dpy, GLXFBConfig config, int width, int height, int *errorcode, GLXPbuffer * result) { struct apple_glx_drawable *d; struct apple_glx_pbuffer *pbuf = NULL; CGLError err; Window root; int screen; Pixmap xid; struct glx_config *modes = (struct glx_config *) config; root = DefaultRootWindow(dpy); screen = DefaultScreen(dpy); /* * This pixmap is only used for a persistent XID. * The XC-MISC extension cleans up XIDs and reuses them transparently, * so we need to retain a server-side reference. */ xid = XCreatePixmap(dpy, root, (unsigned int) 1, (unsigned int) 1, DefaultDepth(dpy, screen)); if (None == xid) { *errorcode = BadAlloc; return true; } if (apple_glx_drawable_create(dpy, screen, xid, &d, &callbacks)) { *errorcode = BadAlloc; return true; } /* The lock is held in d from create onward. */ pbuf = &d->types.pbuffer; pbuf->xid = xid; pbuf->width = width; pbuf->height = height; err = apple_cgl.create_pbuffer(width, height, GL_TEXTURE_RECTANGLE_EXT, (modes->alphaBits > 0) ? GL_RGBA : GL_RGB, 0, &pbuf->buffer_obj); if (kCGLNoError != err) { d->unlock(d); d->destroy(d); *errorcode = BadMatch; return true; } pbuf->fbconfigID = modes->fbconfigID; pbuf->event_mask = 0; *result = pbuf->xid; d->unlock(d); return false; }