📄 glx_pbuffer.c
字号:
req->reqType = opcode; req->glxCode = glxCode; req->screen = (CARD32) fbconfig->screen; req->fbconfig = fbconfig->fbconfigID; req->window = (CARD32) drawable; req->glxwindow = (GLXWindow) XAllocID(dpy); req->numAttribs = (CARD32) i; memcpy( data, attrib_list, 8 * i ); UnlockDisplay(dpy); SyncHandle(); #ifdef GLX_DIRECT_RENDERING do { /* FIXME: Maybe delay __DRIdrawable creation until the drawable * is actually bound to a context... */ __GLXdisplayPrivate * const priv = __glXInitialize(dpy); __GLXDRIdrawable *pdraw; __GLXscreenConfigs *psc; psc = &priv->screenConfigs[fbconfig->screen]; if (psc->driScreen == NULL) break; pdraw = psc->driScreen->createDrawable(psc, drawable, req->glxwindow, fbconfig); if (pdraw == NULL) { fprintf(stderr, "failed to create drawable\n"); break; } if (__glxHashInsert(psc->drawHash, req->glxwindow, pdraw)) { (*pdraw->destroyDrawable)(pdraw); return None; /* FIXME: Check what we're supposed to do here... */ } pdraw->textureTarget = determineTextureTarget(attrib_list, i); } while (0);#endif return (GLXDrawable)req->glxwindow;}/** * Destroy a non-pbuffer GLX drawable. * * \todo * This function needs to be modified to work with direct-rendering drivers. */static voidDestroyDrawable( Display * dpy, GLXDrawable drawable, CARD32 glxCode ){ xGLXDestroyPbufferReq * req; CARD8 opcode; if ( (dpy == NULL) || (drawable == 0) ) { return; } opcode = __glXSetupForCommand(dpy); if (!opcode) return; LockDisplay(dpy); GetReqExtra( GLXDestroyPbuffer, 4, req ); req->reqType = opcode; req->glxCode = glxCode; req->pbuffer = (GLXPbuffer) drawable; UnlockDisplay(dpy); SyncHandle();#ifdef GLX_DIRECT_RENDERING { int screen; __GLXdisplayPrivate * const priv = __glXInitialize(dpy); __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); __GLXscreenConfigs *psc = &priv->screenConfigs[screen]; if (pdraw != NULL) { (*pdraw->destroyDrawable)(pdraw); __glxHashDelete(psc->drawHash, drawable); } }#endif return;}/** * Create a pbuffer. * * This function is used to implement \c glXCreatePbuffer and * \c glXCreateGLXPbufferSGIX. * * \note * This function dynamically determines whether to use the SGIX_pbuffer * version of the protocol or the GLX 1.3 version of the protocol. * * \todo * This function needs to be modified to work with direct-rendering drivers. */static GLXDrawableCreatePbuffer( Display *dpy, const __GLcontextModes * fbconfig, unsigned int width, unsigned int height, const int *attrib_list, GLboolean size_in_attribs ){ __GLXdisplayPrivate *priv = __glXInitialize(dpy); GLXDrawable id = 0; CARD32 * data; CARD8 opcode; unsigned int i; i = 0; if (attrib_list) { while (attrib_list[i * 2]) i++; } opcode = __glXSetupForCommand(dpy); if (!opcode) return None; LockDisplay(dpy); id = XAllocID(dpy); if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) { xGLXCreatePbufferReq * req; unsigned int extra = (size_in_attribs) ? 0 : 2; GetReqExtra( GLXCreatePbuffer, (8 * (i + extra)), req ); data = (CARD32 *) (req + 1); req->reqType = opcode; req->glxCode = X_GLXCreatePbuffer; req->screen = (CARD32) fbconfig->screen; req->fbconfig = fbconfig->fbconfigID; req->pbuffer = (GLXPbuffer) id; req->numAttribs = (CARD32) (i + extra); if ( ! size_in_attribs ) { data[(2 * i) + 0] = GLX_PBUFFER_WIDTH; data[(2 * i) + 1] = width; data[(2 * i) + 2] = GLX_PBUFFER_HEIGHT; data[(2 * i) + 3] = height; data += 4; } } else { xGLXVendorPrivateReq *vpreq; GetReqExtra( GLXVendorPrivate, 20 + (8 * i), vpreq ); data = (CARD32 *) (vpreq + 1); vpreq->reqType = opcode; vpreq->glxCode = X_GLXVendorPrivate; vpreq->vendorCode = X_GLXvop_CreateGLXPbufferSGIX; data[0] = (CARD32) fbconfig->screen; data[1] = (CARD32) fbconfig->fbconfigID; data[2] = (CARD32) id; data[3] = (CARD32) width; data[4] = (CARD32) height; data += 5; } (void) memcpy( data, attrib_list, sizeof(CARD32) * 2 * i ); UnlockDisplay(dpy); SyncHandle(); return id;}/** * Create a new pbuffer. */PUBLIC GLXPbufferSGIXglXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list){ return (GLXPbufferSGIX) CreatePbuffer( dpy, (__GLcontextModes *) config, width, height, attrib_list, GL_FALSE );}/** * Create a new pbuffer. */PUBLIC GLXPbufferglXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attrib_list){ int i, width, height; width = 0; height = 0; for (i = 0; attrib_list[i * 2]; i++) { switch (attrib_list[i * 2]) { case GLX_PBUFFER_WIDTH: width = attrib_list[i * 2 + 1]; break; case GLX_PBUFFER_HEIGHT: height = attrib_list[i * 2 + 1]; break; } } return (GLXPbuffer) CreatePbuffer( dpy, (__GLcontextModes *) config, width, height, attrib_list, GL_TRUE );}/** * Destroy an existing pbuffer. */PUBLIC voidglXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf){ DestroyPbuffer( dpy, pbuf );}/** * Query an attribute of a drawable. */PUBLIC voidglXQueryDrawable(Display *dpy, GLXDrawable drawable, int attribute, unsigned int *value){ GetDrawableAttribute( dpy, drawable, attribute, value );}/** * Query an attribute of a pbuffer. */PUBLIC intglXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX drawable, int attribute, unsigned int *value){ return GetDrawableAttribute( dpy, drawable, attribute, value );}/** * Select the event mask for a drawable. */PUBLIC voidglXSelectEvent(Display *dpy, GLXDrawable drawable, unsigned long mask){ CARD32 attribs[2]; attribs[0] = (CARD32) GLX_EVENT_MASK; attribs[1] = (CARD32) mask; ChangeDrawableAttribute( dpy, drawable, attribs, 1 );}/** * Get the selected event mask for a drawable. */PUBLIC voidglXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask){ unsigned int value; /* The non-sense with value is required because on LP64 platforms * sizeof(unsigned int) != sizeof(unsigned long). On little-endian * we could just type-cast the pointer, but why? */ GetDrawableAttribute( dpy, drawable, GLX_EVENT_MASK_SGIX, & value ); *mask = value;}PUBLIC GLXPixmapglXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list ){ return CreateDrawable( dpy, (__GLcontextModes *) config, (Drawable) pixmap, attrib_list, X_GLXCreatePixmap );}PUBLIC GLXWindowglXCreateWindow( Display *dpy, GLXFBConfig config, Window win, const int *attrib_list ){ return CreateDrawable( dpy, (__GLcontextModes *) config, (Drawable) win, attrib_list, X_GLXCreateWindow );}PUBLIC voidglXDestroyPixmap(Display *dpy, GLXPixmap pixmap){ DestroyDrawable( dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap );}PUBLIC voidglXDestroyWindow(Display *dpy, GLXWindow win){ DestroyDrawable( dpy, (GLXDrawable) win, X_GLXDestroyWindow );}PUBLIC GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX, (Display *dpy, GLXPbufferSGIX pbuf), (dpy, pbuf), glXDestroyPbuffer)PUBLIC GLX_ALIAS_VOID(glXSelectEventSGIX, (Display *dpy, GLXDrawable drawable, unsigned long mask), (dpy, drawable, mask), glXSelectEvent)PUBLIC GLX_ALIAS_VOID(glXGetSelectedEventSGIX, (Display *dpy, GLXDrawable drawable, unsigned long *mask), (dpy, drawable, mask), glXGetSelectedEvent)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -