📄 glxcmds.c
字号:
Xfree((char *) gc->client_state_private); XFree((char *) gc); }/*** Destroy the named context*/static void DestroyContext(Display *dpy, GLXContext gc){ xGLXDestroyContextReq *req; GLXContextID xid; CARD8 opcode; GLboolean imported; opcode = __glXSetupForCommand(dpy); if (!opcode || !gc) { return; } __glXLock(); xid = gc->xid; imported = gc->imported; gc->xid = None;#ifdef GLX_DIRECT_RENDERING /* Destroy the direct rendering context */ if (gc->driContext) { (*gc->driContext->destroyContext)(gc->driContext, gc->psc, dpy); gc->driContext = NULL; GarbageCollectDRIDrawables(dpy, gc->psc); }#endif __glXFreeVertexArrayState(gc); if (gc->currentDpy) { /* Have to free later cuz it's in use now */ __glXUnlock(); } else { /* Destroy the handle if not current to anybody */ __glXUnlock(); __glXFreeContext(gc); } if (!imported) { /* ** This dpy also created the server side part of the context. ** Send the glXDestroyContext request. */ LockDisplay(dpy); GetReq(GLXDestroyContext,req); req->reqType = opcode; req->glxCode = X_GLXDestroyContext; req->context = xid; UnlockDisplay(dpy); SyncHandle(); }}PUBLIC void glXDestroyContext(Display *dpy, GLXContext gc){ DestroyContext(dpy, gc);}/*** Return the major and minor version #s for the GLX extension*/PUBLIC Bool glXQueryVersion(Display *dpy, int *major, int *minor){ __GLXdisplayPrivate *priv; /* Init the extension. This fetches the major and minor version. */ priv = __glXInitialize(dpy); if (!priv) return GL_FALSE; if (major) *major = priv->majorVersion; if (minor) *minor = priv->minorVersion; return GL_TRUE;}/*** Query the existance of the GLX extension*/PUBLIC Bool glXQueryExtension(Display *dpy, int *errorBase, int *eventBase){ int major_op, erb, evb; Bool rv; rv = XQueryExtension(dpy, GLX_EXTENSION_NAME, &major_op, &evb, &erb); if (rv) { if (errorBase) *errorBase = erb; if (eventBase) *eventBase = evb; } return rv;}/*** Put a barrier in the token stream that forces the GL to finish its** work before X can proceed.*/PUBLIC void glXWaitGL(void){ xGLXWaitGLReq *req; GLXContext gc = __glXGetCurrentContext(); Display *dpy = gc->currentDpy; if (!dpy) return; /* Flush any pending commands out */ __glXFlushRenderBuffer(gc, gc->pc);#ifdef GLX_DIRECT_RENDERING if (gc->driContext) {/* This bit of ugliness unwraps the glFinish function */#ifdef glFinish#undef glFinish#endif glFinish(); return; }#endif /* Send the glXWaitGL request */ LockDisplay(dpy); GetReq(GLXWaitGL,req); req->reqType = gc->majorOpcode; req->glxCode = X_GLXWaitGL; req->contextTag = gc->currentContextTag; UnlockDisplay(dpy); SyncHandle();}/*** Put a barrier in the token stream that forces X to finish its** work before GL can proceed.*/PUBLIC void glXWaitX(void){ xGLXWaitXReq *req; GLXContext gc = __glXGetCurrentContext(); Display *dpy = gc->currentDpy; if (!dpy) return; /* Flush any pending commands out */ __glXFlushRenderBuffer(gc, gc->pc);#ifdef GLX_DIRECT_RENDERING if (gc->driContext) { XSync(dpy, False); return; }#endif /* ** Send the glXWaitX request. */ LockDisplay(dpy); GetReq(GLXWaitX,req); req->reqType = gc->majorOpcode; req->glxCode = X_GLXWaitX; req->contextTag = gc->currentContextTag; UnlockDisplay(dpy); SyncHandle();}PUBLIC void glXUseXFont(Font font, int first, int count, int listBase){ xGLXUseXFontReq *req; GLXContext gc = __glXGetCurrentContext(); Display *dpy = gc->currentDpy; if (!dpy) return; /* Flush any pending commands out */ (void) __glXFlushRenderBuffer(gc, gc->pc);#ifdef GLX_DIRECT_RENDERING if (gc->driContext) { DRI_glXUseXFont(font, first, count, listBase); return; }#endif /* Send the glXUseFont request */ LockDisplay(dpy); GetReq(GLXUseXFont,req); req->reqType = gc->majorOpcode; req->glxCode = X_GLXUseXFont; req->contextTag = gc->currentContextTag; req->font = font; req->first = first; req->count = count; req->listBase = listBase; UnlockDisplay(dpy); SyncHandle();}/************************************************************************//*** Copy the source context to the destination context using the** attribute "mask".*/PUBLIC void glXCopyContext(Display *dpy, GLXContext source, GLXContext dest, unsigned long mask){ xGLXCopyContextReq *req; GLXContext gc = __glXGetCurrentContext(); GLXContextTag tag; CARD8 opcode; opcode = __glXSetupForCommand(dpy); if (!opcode) { return; }#ifdef GLX_DIRECT_RENDERING if (gc->driContext) { /* NOT_DONE: This does not work yet */ }#endif /* ** If the source is the current context, send its tag so that the context ** can be flushed before the copy. */ if (source == gc && dpy == gc->currentDpy) { tag = gc->currentContextTag; } else { tag = 0; } /* Send the glXCopyContext request */ LockDisplay(dpy); GetReq(GLXCopyContext,req); req->reqType = opcode; req->glxCode = X_GLXCopyContext; req->source = source ? source->xid : None; req->dest = dest ? dest->xid : None; req->mask = mask; req->contextTag = tag; UnlockDisplay(dpy); SyncHandle();}/** * Determine if a context uses direct rendering. * * \param dpy Display where the context was created. * \param contextID ID of the context to be tested. * * \returns \c GL_TRUE if the context is direct rendering or not. */static Bool __glXIsDirect(Display *dpy, GLXContextID contextID){ xGLXIsDirectReq *req; xGLXIsDirectReply reply; CARD8 opcode; opcode = __glXSetupForCommand(dpy); if (!opcode) { return GL_FALSE; } /* Send the glXIsDirect request */ LockDisplay(dpy); GetReq(GLXIsDirect,req); req->reqType = opcode; req->glxCode = X_GLXIsDirect; req->context = contextID; _XReply(dpy, (xReply*) &reply, 0, False); UnlockDisplay(dpy); SyncHandle(); return reply.isDirect;}/** * \todo * Shouldn't this function \b always return \c GL_FALSE when * \c GLX_DIRECT_RENDERING is not defined? Do we really need to bother with * the GLX protocol here at all? */PUBLIC Bool glXIsDirect(Display *dpy, GLXContext gc){ if (!gc) { return GL_FALSE;#ifdef GLX_DIRECT_RENDERING } else if (gc->driContext) { return GL_TRUE;#endif } return __glXIsDirect(dpy, gc->xid);}PUBLIC GLXPixmap glXCreateGLXPixmap(Display *dpy, XVisualInfo *vis, Pixmap pixmap){ xGLXCreateGLXPixmapReq *req; GLXPixmap xid; CARD8 opcode; opcode = __glXSetupForCommand(dpy); if (!opcode) { return None; } /* Send the glXCreateGLXPixmap request */ LockDisplay(dpy); GetReq(GLXCreateGLXPixmap,req); req->reqType = opcode; req->glxCode = X_GLXCreateGLXPixmap; req->screen = vis->screen; req->visual = vis->visualid; req->pixmap = pixmap; req->glxpixmap = xid = XAllocID(dpy); UnlockDisplay(dpy); SyncHandle(); return xid;}/*** Destroy the named pixmap*/PUBLIC void glXDestroyGLXPixmap(Display *dpy, GLXPixmap glxpixmap){ xGLXDestroyGLXPixmapReq *req; CARD8 opcode; opcode = __glXSetupForCommand(dpy); if (!opcode) { return; } /* Send the glXDestroyGLXPixmap request */ LockDisplay(dpy); GetReq(GLXDestroyGLXPixmap,req); req->reqType = opcode; req->glxCode = X_GLXDestroyGLXPixmap; req->glxpixmap = glxpixmap; UnlockDisplay(dpy); SyncHandle();}PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable){ xGLXSwapBuffersReq *req; GLXContext gc; GLXContextTag tag; CARD8 opcode;#ifdef GLX_DIRECT_RENDERING __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); if (pdraw != NULL) { (*pdraw->psc->core->swapBuffers)(pdraw->driDrawable); return; }#endif opcode = __glXSetupForCommand(dpy); if (!opcode) { return; } /* ** The calling thread may or may not have a current context. If it ** does, send the context tag so the server can do a flush. */ gc = __glXGetCurrentContext(); if ((gc != NULL) && (dpy == gc->currentDpy) && ((drawable == gc->currentDrawable) || (drawable == gc->currentReadable)) ) { tag = gc->currentContextTag; } else { tag = 0; } /* Send the glXSwapBuffers request */ LockDisplay(dpy); GetReq(GLXSwapBuffers,req); req->reqType = opcode; req->glxCode = X_GLXSwapBuffers; req->drawable = drawable; req->contextTag = tag; UnlockDisplay(dpy); SyncHandle(); XFlush(dpy);}/*** Return configuration information for the given display, screen and** visual combination.*/PUBLIC int glXGetConfig(Display *dpy, XVisualInfo *vis, int attribute, int *value_return){ __GLXdisplayPrivate *priv; __GLXscreenConfigs *psc; __GLcontextModes *modes; int status; status = GetGLXPrivScreenConfig( dpy, vis->screen, & priv, & psc ); if ( status == Success ) { modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid); /* Lookup attribute after first finding a match on the visual */ if ( modes != NULL ) { return _gl_get_context_mode_data( modes, attribute, value_return ); } status = GLX_BAD_VISUAL; } /* ** If we can't find the config for this visual, this visual is not ** supported by the OpenGL implementation on the server. */ if ( (status == GLX_BAD_VISUAL) && (attribute == GLX_USE_GL) ) { *value_return = GL_FALSE; status = Success; } return status;}/************************************************************************/static voidinit_fbconfig_for_chooser( __GLcontextModes * config, GLboolean fbconfig_style_tags ){ memset( config, 0, sizeof( __GLcontextModes ) ); config->visualID = (XID) GLX_DONT_CARE; config->visualType = GLX_DONT_CARE; /* glXChooseFBConfig specifies different defaults for these two than * glXChooseVisual. */ if ( fbconfig_style_tags ) { config->rgbMode = GL_TRUE; config->doubleBufferMode = GLX_DONT_CARE; } config->visualRating = GLX_DONT_CARE; config->transparentPixel = GLX_NONE; config->transparentRed = GLX_DONT_CARE; config->transparentGreen = GLX_DONT_CARE; config->transparentBlue = GLX_DONT_CARE; config->transparentAlpha = GLX_DONT_CARE; config->transparentIndex = GLX_DONT_CARE; config->drawableType = GLX_WINDOW_BIT; config->renderType = (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT; config->xRenderable = GLX_DONT_CARE; config->fbconfigID = (GLXFBConfigID)(GLX_DONT_CARE); config->swapMethod = GLX_DONT_CARE;}#define MATCH_DONT_CARE( param ) \ do { \ if ( (a-> param != GLX_DONT_CARE) \ && (a-> param != b-> param) ) { \ return False; \ } \ } while ( 0 )#define MATCH_MINIMUM( param ) \ do { \ if ( (a-> param != GLX_DONT_CARE) \ && (a-> param > b-> param) ) { \ return False; \ } \ } while ( 0 )#define MATCH_EXACT( param ) \ do { \ if ( a-> param != b-> param) { \ return False; \ } \ } while ( 0 )/** * Determine if two GLXFBConfigs are compatible. * * \param a Application specified config to test. * \param b Server specified config to test against \c a. */static Bool
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -