glxcmds.c

来自「mesa-6.5-minigui源码」· C语言 代码 · 共 2,495 行 · 第 1/5 页

C
2,495 行
字号
	  (Display * dpy, GLXFBConfigSGIX config),	  (dpy, config),	  glXGetVisualFromFBConfig)PUBLIC GLXPixmap glXCreateGLXPixmapWithConfigSGIX(Display *dpy,                            GLXFBConfigSGIX config, Pixmap pixmap){    xGLXVendorPrivateWithReplyReq *vpreq;    xGLXCreateGLXPixmapWithConfigSGIXReq *req;    GLXPixmap xid = None;    CARD8 opcode;    const __GLcontextModes * const fbconfig = (__GLcontextModes *) config;    __GLXscreenConfigs * psc;    if ( (dpy == NULL) || (config == NULL) ) {	return None;    }    psc = GetGLXScreenConfigs( dpy, fbconfig->screen );    if ( (psc != NULL) 	 && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit ) ) {	opcode = __glXSetupForCommand(dpy);	if (!opcode) {	    return None;	}	/* Send the glXCreateGLXPixmapWithConfigSGIX request */	LockDisplay(dpy);	GetReqExtra(GLXVendorPrivateWithReply,		    sz_xGLXCreateGLXPixmapWithConfigSGIXReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);	req = (xGLXCreateGLXPixmapWithConfigSGIXReq *)vpreq;	req->reqType = opcode;	req->glxCode = X_GLXVendorPrivateWithReply;	req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX;	req->screen = fbconfig->screen;	req->fbconfig = fbconfig->fbconfigID;	req->pixmap = pixmap;	req->glxpixmap = xid = XAllocID(dpy);	UnlockDisplay(dpy);	SyncHandle();    }    return xid;}PUBLIC GLXContext glXCreateContextWithConfigSGIX(Display *dpy,                             GLXFBConfigSGIX config, int renderType,                             GLXContext shareList, Bool allowDirect){    GLXContext gc = NULL;    const __GLcontextModes * const fbconfig = (__GLcontextModes *) config;    __GLXscreenConfigs * psc;    if ( (dpy == NULL) || (config == NULL) ) {	return None;    }    psc = GetGLXScreenConfigs( dpy, fbconfig->screen );    if ( (psc != NULL) 	 && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit ) ) {	gc = CreateContext( dpy, NULL, (__GLcontextModes *) config, shareList,			    allowDirect, None, False, renderType );    }    return gc;}PUBLIC GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX(Display *dpy,						    XVisualInfo *vis){    __GLXdisplayPrivate *priv;    __GLXscreenConfigs *psc;    if ( (GetGLXPrivScreenConfig( dpy, vis->screen, & priv, & psc ) != Success)	 && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit )	 && (psc->configs->fbconfigID != GLX_DONT_CARE) ) {	return (GLXFBConfigSGIX) _gl_context_modes_find_visual( psc->configs,								vis->visualid );    }    return NULL;}/*** GLX_SGI_cushion*/PUBLIC void glXCushionSGI(Display *dpy, Window win, float cushion){   (void) dpy;   (void) win;   (void) cushion;}/*** GLX_SGIX_video_resize*/PUBLIC int glXBindChannelToWindowSGIX(Display *dpy, int screen,				      int channel , Window window){   (void) dpy;   (void) screen;   (void) channel;   (void) window;   return 0;}PUBLIC int glXChannelRectSGIX(Display *dpy, int screen, int channel,			      int x, int y, int w, int h){   (void) dpy;   (void) screen;   (void) channel;   (void) x;   (void) y;   (void) w;   (void) h;   return 0;}PUBLIC int glXQueryChannelRectSGIX(Display *dpy, int screen, int channel,				   int *x, int *y, int *w, int *h){   (void) dpy;   (void) screen;   (void) channel;   (void) x;   (void) y;   (void) w;   (void) h;   return 0;}int glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel,			      int *dx, int *dy, int *dw, int *dh){   (void) dpy;   (void) screen;   (void) channel;   (void) dx;   (void) dy;   (void) dw;   (void) dh;   return 0;}PUBLIC int glXChannelRectSyncSGIX(Display *dpy, int screen,				  int channel, GLenum synctype){   (void) dpy;   (void) screen;   (void) channel;   (void) synctype;   return 0;}#if defined(_DM_BUFFER_H_)PUBLIC Bool glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer,				      DMparams *params, DMbuffer dmbuffer){   (void) dpy;   (void) pbuffer;   (void) params;   (void) dmbuffer;   return False;}#endif/*** GLX_SGIX_swap_group*/PUBLIC void glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable,				 GLXDrawable member){   (void) dpy;   (void) drawable;   (void) member;}/*** GLX_SGIX_swap_barrier*/PUBLIC void glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable,				   int barrier){   (void) dpy;   (void) drawable;   (void) barrier;}PUBLIC Bool glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max){   (void) dpy;   (void) screen;   (void) max;   return False;}/*** GLX_SUN_get_transparent_index*/PUBLIC Status glXGetTransparentIndexSUN(Display *dpy, Window overlay,					Window underlay, long *pTransparent){   (void) dpy;   (void) overlay;   (void) underlay;   (void) pTransparent;   return 0;}/*** GLX_OML_sync_control*/PUBLIC Bool glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable,				int64_t *ust, int64_t *msc, int64_t *sbc){#ifdef GLX_DIRECT_RENDERING    __GLXdisplayPrivate * const priv = __glXInitialize(dpy);    if ( priv != NULL ) {	int   i;	__DRIdrawable * const pdraw = GetDRIDrawable( dpy, drawable, & i );	__GLXscreenConfigs * const psc = &priv->screenConfigs[i];	assert( (pdraw == NULL) || (i != -1) );	return ( (pdraw && pdraw->getSBC && psc->driScreen.getMSC)		 && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit )		 && ((*psc->driScreen.getMSC)( psc->driScreen.private, msc ) == 0)		 && ((*pdraw->getSBC)( dpy, psc->driScreen.private, sbc ) == 0)		 && (__glXGetUST( ust ) == 0) );    }#else   (void) dpy;   (void) drawable;   (void) ust;   (void) msc;   (void) sbc;#endif   return False;}/** * Determine the refresh rate of the specified drawable and display. *  * \param dpy          Display whose refresh rate is to be determined. * \param drawable     Drawable whose refresh rate is to be determined. * \param numerator    Numerator of the refresh rate. * \param demoninator  Denominator of the refresh rate. * \return  If the refresh rate for the specified display and drawable could *          be calculated, True is returned.  Otherwise False is returned. *  * \note This function is implemented entirely client-side.  A lot of other *       functionality is required to export GLX_OML_sync_control, so on *       XFree86 this function can be called for direct-rendering contexts *       when GLX_OML_sync_control appears in the client extension string. */PUBLIC Bool glXGetMscRateOML(Display * dpy, GLXDrawable drawable,			     int32_t * numerator, int32_t * denominator){#if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE )   __GLXdisplayPrivate * const priv = __glXInitialize(dpy);   if ( priv != NULL ) {      XF86VidModeModeLine   mode_line;      int   dot_clock;      int   screen_num;      int   i;      GetDRIDrawable( dpy, drawable, & screen_num );      if ( (screen_num != -1)	   && XF86VidModeQueryVersion( dpy, & i, & i )	   && XF86VidModeGetModeLine( dpy, screen_num, & dot_clock,				      & mode_line ) ) {	 unsigned   n = dot_clock * 1000;	 unsigned   d = mode_line.vtotal * mode_line.htotal;# define V_INTERLACE 0x010# define V_DBLSCAN   0x020	 if ( (mode_line.flags & V_INTERLACE) ) {	    n *= 2;	 }	 else if ( (mode_line.flags & V_DBLSCAN) ) {	    d *= 2;	 }	 /* The OML_sync_control spec requires that if the refresh rate is a	  * whole number, that the returned numerator be equal to the refresh	  * rate and the denominator be 1.	  */	 if ( (n % d) == 0 ) {	    n /= d;	    d = 1;	 }	 else {	    static const unsigned f[] = { 13, 11, 7, 5, 3, 2, 0 };	    /* This is a poor man's way to reduce a fraction.  It's far from	     * perfect, but it will work well enough for this situation.	     */	    for ( i = 0 ; f[i] != 0 ; i++ ) {	       while ( ((n % f[i]) == 0) && ((d % f[i]) == 0) ) {		  d /= f[i];		  n /= f[i];	       }	    }	 }	 *numerator = n;	 *denominator = d;	 (void) drawable;	 return True;      }   }#else   (void) dpy;   (void) drawable;   (void) numerator;   (void) denominator;#endif   return False;}PUBLIC int64_t glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable,				    int64_t target_msc, int64_t divisor,				    int64_t remainder){#ifdef GLX_DIRECT_RENDERING   int screen;   __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );   __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );   /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE    * error", but it also says "It [glXSwapBuffersMscOML] will return a value    * of -1 if the function failed because of errors detected in the input    * parameters"    */   if ( divisor < 0 || remainder < 0 || target_msc < 0 )      return -1;   if ( divisor > 0 && remainder >= divisor )      return -1;   if ( (pdraw != NULL) && (pdraw->swapBuffersMSC != NULL)       && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) {      return (*pdraw->swapBuffersMSC)(dpy, pdraw->private, target_msc,				      divisor, remainder);   }#else   (void) dpy;   (void) drawable;   (void) target_msc;   (void) divisor;   (void) remainder;#endif   return 0;}PUBLIC Bool glXWaitForMscOML(Display * dpy, GLXDrawable drawable,			     int64_t target_msc, int64_t divisor,			     int64_t remainder, int64_t *ust,			     int64_t *msc, int64_t *sbc){#ifdef GLX_DIRECT_RENDERING   int screen;   __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );   __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );   int  ret;   /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE    * error", but the return type in the spec is Bool.    */   if ( divisor < 0 || remainder < 0 || target_msc < 0 )      return False;   if ( divisor > 0 && remainder >= divisor )      return False;   if ( (pdraw != NULL) && (pdraw->waitForMSC != NULL)	&& __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) {      ret = (*pdraw->waitForMSC)( dpy, pdraw->private, target_msc,				  divisor, remainder, msc, sbc );      /* __glXGetUST returns zero on success and non-zero on failure.       * This function returns True on success and False on failure.       */      return ( (ret == 0) && (__glXGetUST( ust ) == 0) );   }#else   (void) dpy;   (void) drawable;   (void) target_msc;   (void) divisor;   (void) remainder;   (void) ust;   (void) msc;   (void) sbc;#endif   return False;}PUBLIC Bool glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,			     int64_t target_sbc, int64_t *ust,			     int64_t *msc, int64_t *sbc ){#ifdef GLX_DIRECT_RENDERING   int screen;   __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );   __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );   int  ret;   /* The OML_sync_control spec says this should "generate a GLX_BAD_VALUE    * error", but the return type in the spec is Bool.    */   if ( target_sbc < 0 )      return False;   if ( (pdraw != NULL) && (pdraw->waitForSBC != NULL)	&& __glXExtensionBitIsEnabled( psc, OML_sync_control_bit )) {      ret = (*pdraw->waitForSBC)( dpy, pdraw->private, target_sbc, msc, sbc );      /* __glXGetUST returns zero on success and non-zero on failure.       * This function returns True on success and False on failure.       */      return( (ret == 0) && (__glXGetUST( ust ) == 0) );   }#else   (void) dpy;   (void) drawable;   (void) target_sbc;   (void) ust;   (void) msc;   (void) sbc;#endif   return False;}/** * GLX_MESA_allocate_memory *//*@{*/PUBLIC void *glXAllocateMemoryMESA(Display *dpy, int scrn,				   size_t size, float readFreq,				   float writeFreq, float priority){#ifdef GLX_DIRECT_RENDERING   __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn );   if ( __glXExtensionBitIsEnabled( psc, MESA_allocate_memory_bit ) ) {      if (psc && psc->driScreen.private && psc->driScreen.allocateMemory) {	 return (*psc->driScreen.allocateMemory)( dpy, scrn, size,						  readFreq, writeFreq,						  priority );      }   }#else   (void) dpy;   (void) scrn;   (void) size;   (void) readFreq;   (void) writeFreq;   (void) priority;#endif /* GLX_DIRECT_RENDERING */   return NULL;}PUBLIC void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer){#ifdef GLX_DIRECT_RENDERING   __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn );   if ( __glXExtensionBitIsEnabled( psc, MESA_allocate_memory_bit ) ) {      if (psc && psc->driScreen.private && psc->driScreen.freeMemory) {

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?