⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fakeglx.c

📁 mesa-6.5-minigui源码
💻 C
📖 第 1 页 / 共 5 页
字号:
   (void) screen;   switch (name) {      case GLX_EXTENSIONS:         return get_extensions();      case GLX_VENDOR:	 return VENDOR;      case GLX_VERSION:	 return version;      default:         return NULL;   }}/* GLX 1.1 and later */static const char *Fake_glXGetClientString( Display *dpy, int name ){   static char version[1000];   _mesa_sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION,                 CLIENT_MINOR_VERSION, MESA_GLX_VERSION);   (void) dpy;   switch (name) {      case GLX_EXTENSIONS:         return get_extensions();      case GLX_VENDOR:	 return VENDOR;      case GLX_VERSION:	 return version;      default:         return NULL;   }}/* * GLX 1.3 and later */static intFake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,                           int attribute, int *value ){   XMesaVisual v = (XMesaVisual) config;   (void) dpy;   (void) config;   if (!dpy || !config || !value)      return -1;   return get_config(v, attribute, value, GL_TRUE);}static GLXFBConfig *Fake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ){   XVisualInfo *visuals, visTemplate;   const long visMask = VisualScreenMask;   int i;   /* Get list of all X visuals */   visTemplate.screen = screen;   visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements);   if (*nelements > 0) {      XMesaVisual *results;      results = (XMesaVisual *) _mesa_malloc(*nelements * sizeof(XMesaVisual));      if (!results) {         *nelements = 0;         return NULL;      }      for (i = 0; i < *nelements; i++) {         results[i] = create_glx_visual(dpy, visuals + i);      }      return (GLXFBConfig *) results;   }   return NULL;}static GLXFBConfig *Fake_glXChooseFBConfig( Display *dpy, int screen,                        const int *attribList, int *nitems ){   XMesaVisual xmvis;   if (!attribList || !attribList[0]) {      /* return list of all configs (per GLX_SGIX_fbconfig spec) */      return Fake_glXGetFBConfigs(dpy, screen, nitems);   }   xmvis = choose_visual(dpy, screen, attribList, GL_TRUE);   if (xmvis) {      GLXFBConfig *config = (GLXFBConfig *) _mesa_malloc(sizeof(XMesaVisual));      if (!config) {         *nitems = 0;         return NULL;      }      *nitems = 1;      config[0] = (GLXFBConfig) xmvis;      return (GLXFBConfig *) config;   }   else {      *nitems = 0;      return NULL;   }}static XVisualInfo *Fake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ){   if (dpy && config) {      XMesaVisual xmvis = (XMesaVisual) config;#if 0            return xmvis->vishandle;#else      /* create a new vishandle - the cached one may be stale */      xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo));      if (xmvis->vishandle) {         _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));      }      return xmvis->vishandle;#endif   }   else {      return NULL;   }}static GLXWindowFake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,                      const int *attribList ){   XMesaVisual xmvis = (XMesaVisual) config;   XMesaBuffer xmbuf;   if (!xmvis)      return 0;   xmbuf = XMesaCreateWindowBuffer2(xmvis, win, NULL);   if (!xmbuf)      return 0;   (void) dpy;   (void) attribList;  /* Ignored in GLX 1.3 */   return win;  /* A hack for now */}static voidFake_glXDestroyWindow( Display *dpy, GLXWindow window ){   XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window);   if (b)      XMesaDestroyBuffer(b);   /* don't destroy X window */}/* XXX untested */static GLXPixmapFake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,                      const int *attribList ){   XMesaVisual v = (XMesaVisual) config;   XMesaBuffer b;   (void) dpy;   (void) config;   (void) pixmap;   (void) attribList;  /* Ignored in GLX 1.3 */   if (!dpy || !config || !pixmap)      return 0;   b = XMesaCreatePixmapBuffer( v, pixmap, 0 );   if (!b) {      return 0;   }   return pixmap;}static voidFake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap ){   XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap);   if (b)      XMesaDestroyBuffer(b);   /* don't destroy X pixmap */}static GLXPbufferFake_glXCreatePbuffer( Display *dpy, GLXFBConfig config,                       const int *attribList ){   XMesaVisual xmvis = (XMesaVisual) config;   XMesaBuffer xmbuf;   const int *attrib;   int width = 0, height = 0;   GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;   (void) dpy;   for (attrib = attribList; *attrib; attrib++) {      switch (*attrib) {         case GLX_PBUFFER_WIDTH:            attrib++;            width = *attrib;            break;         case GLX_PBUFFER_HEIGHT:            attrib++;            height = *attrib;            break;         case GLX_PRESERVED_CONTENTS:            attrib++;            preserveContents = *attrib; /* ignored */            break;         case GLX_LARGEST_PBUFFER:            attrib++;            useLargest = *attrib; /* ignored */            break;         default:            return 0;      }   }   /* not used at this time */   (void) useLargest;   (void) preserveContents;   if (width == 0 || height == 0)      return 0;   xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);   /* A GLXPbuffer handle must be an X Drawable because that's what    * glXMakeCurrent takes.    */   if (xmbuf)      return (GLXPbuffer) xmbuf->frontxrb->pixmap;   else      return 0;}static voidFake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf ){   XMesaBuffer b = XMesaFindBuffer(dpy, pbuf);   if (b) {      XMesaDestroyBuffer(b);   }}static voidFake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,                       unsigned int *value ){   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw);   if (!xmbuf)      return;   switch (attribute) {      case GLX_WIDTH:         *value = xmbuf->mesa_buffer.Width;         break;      case GLX_HEIGHT:         *value = xmbuf->mesa_buffer.Height;         break;      case GLX_PRESERVED_CONTENTS:         *value = True;         break;      case GLX_LARGEST_PBUFFER:         *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height;         break;      case GLX_FBCONFIG_ID:         *value = xmbuf->xm_visual->visinfo->visualid;         return;      default:         return;  /* GLX_BAD_ATTRIBUTE? */   }}static GLXContextFake_glXCreateNewContext( Display *dpy, GLXFBConfig config,                          int renderType, GLXContext shareList, Bool direct ){   struct fake_glx_context *glxCtx;   struct fake_glx_context *shareCtx = (struct fake_glx_context *) shareList;   XMesaVisual xmvis = (XMesaVisual) config;   if (!dpy || !config ||       (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))      return 0;   glxCtx = CALLOC_STRUCT(fake_glx_context);   if (!glxCtx)      return 0;   /* deallocate unused windows/buffers */   XMesaGarbageCollect();   glxCtx->xmesaContext = XMesaCreateContext(xmvis,                                   shareCtx ? shareCtx->xmesaContext : NULL);   if (!glxCtx->xmesaContext) {      FREE(glxCtx);      return NULL;   }   glxCtx->xmesaContext->direct = GL_FALSE;   glxCtx->glxContext.isDirect = GL_FALSE;   glxCtx->glxContext.currentDpy = dpy;   glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */   assert((void *) glxCtx == (void *) &(glxCtx->glxContext));   return (GLXContext) glxCtx;}static intFake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value ){   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;   XMesaContext xmctx = glxCtx->xmesaContext;   (void) dpy;   (void) ctx;   switch (attribute) {   case GLX_FBCONFIG_ID:      *value = xmctx->xm_visual->visinfo->visualid;      break;   case GLX_RENDER_TYPE:      if (xmctx->xm_visual->mesa_visual.rgbMode)         *value = GLX_RGBA_BIT;      else         *value = GLX_COLOR_INDEX_BIT;      break;   case GLX_SCREEN:      *value = 0;      return Success;   default:      return GLX_BAD_ATTRIBUTE;   }   return 0;}static voidFake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask ){   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);   if (xmbuf)      xmbuf->selectedEvents = mask;}static voidFake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,                          unsigned long *mask ){   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);   if (xmbuf)      *mask = xmbuf->selectedEvents;   else      *mask = 0;}/*** GLX_SGI_swap_control ***/static intFake_glXSwapIntervalSGI(int interval){   (void) interval;   return 0;}/*** GLX_SGI_video_sync ***/static intFake_glXGetVideoSyncSGI(unsigned int *count){   (void) count;   return 0;}static intFake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count){   (void) divisor;   (void) remainder;   (void) count;   return 0;}/*** GLX_SGI_make_current_read ***/static BoolFake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx){   return Fake_glXMakeContextCurrent( dpy, draw, read, ctx );}/* not usedstatic GLXDrawableFake_glXGetCurrentReadDrawableSGI(void){   return 0;}*//*** GLX_SGIX_video_source ***/#if defined(_VL_H)static GLXVideoSourceSGIXFake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode){   (void) dpy;   (void) screen;   (void) server;   (void) path;   (void) nodeClass;   (void) drainNode;   return 0;}static voidFake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src){   (void) dpy;   (void) src;}#endif/*** GLX_EXT_import_context ***/static voidFake_glXFreeContextEXT(Display *dpy, GLXContext context){   (void) dpy;   (void) context;}static GLXContextIDFake_glXGetContext

⌨️ 快捷键说明

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