📄 glxcmds.c
字号:
if (numValues == 0) retval = Success; else if (numValues > __GLX_MAX_CONTEXT_PROPS) retval = 0; else { int *propList, *pProp; int nPropListBytes; int i; nPropListBytes = numValues << 3; propList = (int *) Xmalloc(nPropListBytes); if (NULL == propList) { retval = 0; } else { _XRead(dpy, (char *)propList, nPropListBytes); pProp = propList; for (i=0; i < numValues; i++) { switch (*pProp++) { case GLX_SHARE_CONTEXT_EXT: ctx->share_xid = *pProp++; break; case GLX_VISUAL_ID_EXT: ctx->mode = _gl_context_modes_find_visual(ctx->psc->visuals, *pProp++); break; case GLX_SCREEN: ctx->screen = *pProp++; break; case GLX_FBCONFIG_ID: ctx->mode = _gl_context_modes_find_fbconfig(ctx->psc->configs, *pProp++); break; case GLX_RENDER_TYPE: ctx->renderType = *pProp++; break; default: pProp++; continue; } } Xfree((char *)propList); retval = Success; } } UnlockDisplay(dpy); SyncHandle(); return retval;}PUBLIC intglXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value){ int retVal; /* get the information from the server if we don't have it already */#ifdef GLX_DIRECT_RENDERING if (!ctx->driContext && (ctx->mode == NULL)) {#else if (ctx->mode == NULL) {#endif retVal = __glXQueryContextInfo(dpy, ctx); if (Success != retVal) return retVal; } switch (attribute) { case GLX_SHARE_CONTEXT_EXT: *value = (int)(ctx->share_xid); break; case GLX_VISUAL_ID_EXT: *value = ctx->mode ? ctx->mode->visualID : None; break; case GLX_SCREEN: *value = (int)(ctx->screen); break; case GLX_FBCONFIG_ID: *value = ctx->mode ? ctx->mode->fbconfigID : None; break; case GLX_RENDER_TYPE: *value = (int)(ctx->renderType); break; default: return GLX_BAD_ATTRIBUTE; } return Success;}PUBLIC GLX_ALIAS( int, glXQueryContextInfoEXT, (Display *dpy, GLXContext ctx, int attribute, int *value), (dpy, ctx, attribute, value), glXQueryContext )PUBLIC GLXContextID glXGetContextIDEXT(const GLXContext ctx){ return ctx->xid;}PUBLIC GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID){ GLXContext ctx; if (contextID == None) { return NULL; } if (__glXIsDirect(dpy, contextID)) { return NULL; } ctx = CreateContext(dpy, NULL, NULL, NULL, False, contextID, False, 0); if (NULL != ctx) { if (Success != __glXQueryContextInfo(dpy, ctx)) { return NULL; } } return ctx;}PUBLIC void glXFreeContextEXT(Display *dpy, GLXContext ctx){ DestroyContext(dpy, ctx);}/* * GLX 1.3 functions - these are just stubs for now! */PUBLIC GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen, const int *attribList, int *nitems){ __GLcontextModes ** config_list; int list_size; config_list = (__GLcontextModes **) glXGetFBConfigs( dpy, screen, & list_size ); if ( (config_list != NULL) && (list_size > 0) && (attribList != NULL) ) { list_size = choose_visual( config_list, list_size, attribList, GL_TRUE ); if ( list_size == 0 ) { XFree( config_list ); config_list = NULL; } } *nitems = list_size; return (GLXFBConfig *) config_list;}PUBLIC GLXContext glXCreateNewContext(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool allowDirect){ return CreateContext( dpy, NULL, (__GLcontextModes *) config, shareList, allowDirect, None, True, renderType );}PUBLIC GLXDrawable glXGetCurrentReadDrawable(void){ GLXContext gc = __glXGetCurrentContext(); return gc->currentReadable;}PUBLIC GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements){ __GLXdisplayPrivate *priv = __glXInitialize(dpy); __GLcontextModes ** config = NULL; int i; *nelements = 0; if ( (priv->screenConfigs != NULL) && (screen >= 0) && (screen <= ScreenCount(dpy)) && (priv->screenConfigs[screen].configs != NULL) && (priv->screenConfigs[screen].configs->fbconfigID != GLX_DONT_CARE) ) { unsigned num_configs = 0; __GLcontextModes * modes; for ( modes = priv->screenConfigs[screen].configs ; modes != NULL ; modes = modes->next ) { if ( modes->fbconfigID != GLX_DONT_CARE ) { num_configs++; } } config = (__GLcontextModes **) Xmalloc( sizeof(__GLcontextModes *) * num_configs ); if ( config != NULL ) { *nelements = num_configs; i = 0; for ( modes = priv->screenConfigs[screen].configs ; modes != NULL ; modes = modes->next ) { if ( modes->fbconfigID != GLX_DONT_CARE ) { config[i] = modes; i++; } } } } return (GLXFBConfig *) config;}PUBLIC int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *value){ __GLcontextModes * const modes = ValidateGLXFBConfig( dpy, config ); return (modes != NULL) ? _gl_get_context_mode_data( modes, attribute, value ) : GLXBadFBConfig;}PUBLIC XVisualInfo *glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config){ XVisualInfo visualTemplate; __GLcontextModes * fbconfig = (__GLcontextModes *) config; int count; /* ** Get a list of all visuals, return if list is empty */ visualTemplate.visualid = fbconfig->visualID; return XGetVisualInfo(dpy,VisualIDMask,&visualTemplate,&count);}/*** GLX_SGI_swap_control*/static int __glXSwapIntervalSGI(int interval){ xGLXVendorPrivateReq *req; GLXContext gc = __glXGetCurrentContext(); Display * dpy; CARD32 * interval_ptr; CARD8 opcode; if ( gc == NULL ) { return GLX_BAD_CONTEXT; } if ( interval <= 0 ) { return GLX_BAD_VALUE; }#ifdef __DRI_SWAP_CONTROL if (gc->driContext) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen ); __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); if (psc->swapControl != NULL && pdraw != NULL) { psc->swapControl->setSwapInterval(pdraw->driDrawable, interval); return 0; } else { return GLX_BAD_CONTEXT; } }#endif dpy = gc->currentDpy; opcode = __glXSetupForCommand(dpy); if (!opcode) { return 0; } /* Send the glXSwapIntervalSGI request */ LockDisplay(dpy); GetReqExtra(GLXVendorPrivate,sizeof(CARD32),req); req->reqType = opcode; req->glxCode = X_GLXVendorPrivate; req->vendorCode = X_GLXvop_SwapIntervalSGI; req->contextTag = gc->currentContextTag; interval_ptr = (CARD32 *) (req + 1); *interval_ptr = interval; UnlockDisplay(dpy); SyncHandle(); XFlush(dpy); return 0;}/*** GLX_MESA_swap_control*/static int __glXSwapIntervalMESA(unsigned int interval){#ifdef __DRI_SWAP_CONTROL GLXContext gc = __glXGetCurrentContext(); if ( interval < 0 ) { return GLX_BAD_VALUE; } if (gc != NULL && gc->driContext) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen ); if ( (psc != NULL) && (psc->driScreen != NULL) ) { __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); if (psc->swapControl != NULL && pdraw != NULL) { psc->swapControl->setSwapInterval(pdraw->driDrawable, interval); return 0; } } }#else (void) interval;#endif return GLX_BAD_CONTEXT;} static int __glXGetSwapIntervalMESA(void){#ifdef __DRI_SWAP_CONTROL GLXContext gc = __glXGetCurrentContext(); if (gc != NULL && gc->driContext) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen ); if ( (psc != NULL) && (psc->driScreen != NULL) ) { __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); if (psc->swapControl != NULL && pdraw != NULL) { return psc->swapControl->getSwapInterval(pdraw->driDrawable); } } }#endif return 0;}/*** GLX_MESA_swap_frame_usage*/static GLint __glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable){ int status = GLX_BAD_CONTEXT;#ifdef __DRI_FRAME_TRACKING int screen; __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen); if (pdraw != NULL && psc->frameTracking != NULL) status = psc->frameTracking->frameTracking(pdraw->driDrawable, GL_TRUE);#else (void) dpy; (void) drawable;#endif return status;} static GLint __glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable){ int status = GLX_BAD_CONTEXT;#ifdef __DRI_FRAME_TRACKING int screen; __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, & screen); __GLXscreenConfigs *psc = GetGLXScreenConfigs(dpy, screen); if (pdraw != NULL && psc->frameTracking != NULL) status = psc->frameTracking->frameTracking(pdraw->driDrawable, GL_FALSE);#else (void) dpy; (void) drawable;#endif return status;}static GLint __glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable, GLfloat *usage){ int status = GLX_BAD_CONTEXT;#ifdef __DRI_FRAME_TRACKING int screen; __GLXDRIdrawable * const pdraw = GetGLXDRIDrawable(dpy, drawable, & screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen); if (pdraw != NULL && psc->frameTracking != NULL) { int64_t sbc, missedFrames; float lastMissedUsage; status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable, &sbc, &missedFrames, &lastMissedUsage, usage); }#else (void) dpy; (void) drawable; (void) usage;#endif return status;}static GLint __glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable, int64_t *sbc, int64_t *missedFrames, GLfloat *lastMissedUsage){ int status = GLX_BAD_CONTEXT;#ifdef __DRI_FRAME_TRACKING int screen; __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, & screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen); if (pdraw != NULL && psc->frameTracking != NULL) { float usage; status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable, sbc, missedFrames, lastMissedUsage, &usage); }#else (void) dpy; (void) drawable; (void) sbc; (void) missedFrames; (void) lastMissedUsage;#endif return status;}/*** GLX_SGI_video_sync*/static int __glXGetVideoSyncSGI(unsigned int *count){ /* FIXME: Looking at the GLX_SGI_video_sync spec in the extension registry, * FIXME: there should be a GLX encoding for this call. I can find no * FIXME: documentation for the GLX encoding. */#ifdef __DRI_MEDIA_STREAM_COUNTER GLXContext gc = __glXGetCurrentContext(); if (gc != NULL && gc->driContext) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen ); if ( psc->msc && psc->driScreen ) { __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); int64_t temp; int ret; ret = (*psc->msc->getDrawableMSC)(psc->__driScreen, pdraw->driDrawable, &temp); *count = (unsigned) temp; return (ret == 0) ? 0 : GLX_BAD_CONTEXT; } }#else (void) count;#endif return GLX_BAD_CONTEXT;}static int __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count){#ifdef __DRI_MEDIA_STREAM_COUNTER GLXContext gc = __glXGetCurrentContext(); if ( divisor <= 0 || remainder < 0 ) return GLX_BAD_VALUE; if (gc != NULL && gc->driContext) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -