home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / exampleCode / opengl / GLUT / lib / fglut / glut_ext.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-11  |  2.3 KB  |  89 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1994. */
  3.  
  4. /* This program is freely distributable without licensing fees
  5.    and is provided without guarantee or warrantee expressed or
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #include <string.h>
  9.  
  10. #include <GL/glut.h>
  11. #include "glutint.h"
  12.  
  13. /* CENTRY */
  14. int
  15. glutExtensionSupported(char *extension)
  16. {
  17.   static const GLubyte *extensions = NULL;
  18.   const GLubyte *start;
  19.   GLubyte *where, *terminator;
  20.  
  21.   /* Extension names should not have spaces. */
  22.   where = (GLubyte *) strchr(extension, ' ');
  23.   if (where || *extension == '\0')
  24.     return 0;
  25.  
  26.   if (!extensions)
  27.     extensions = glGetString(GL_EXTENSIONS);
  28.   /* It takes a bit of care to be fool-proof about parsing the
  29.      OpenGL extensions string.  Don't be fooled by sub-strings, 
  30.      etc. */
  31.   start = extensions;
  32.   for (;;) {
  33.     where = (GLubyte *) strstr((const char *)start, extension);
  34.     if (!where)
  35.       break;
  36.     terminator = where + strlen(extension);
  37.     if (where == start || *(where - 1) == ' ') {
  38.       if (*terminator == ' ' || *terminator == '\0') {
  39.         return 1;
  40.       }
  41.     }
  42.     start = terminator;
  43.   }
  44.   return 0;
  45. }
  46.  
  47. /* ENDCENTRY */
  48.  
  49. int
  50. __glutIsSupportedByGLX(char *extension)
  51. {
  52. #if defined(GLX_VERSION_1_1)
  53.   static const char *extensions = NULL;
  54.   const char *start;
  55.   char *where, *terminator;
  56.   int major, minor;
  57.  
  58.   glXQueryVersion(__glutDisplay, &major, &minor);
  59.   /* Be careful not to call glXQueryExtensionsString if it
  60.      looks like the server doesn't support GLX 1.1.
  61.      Unfortunately, the original GLX 1.0 didn't have the notion 
  62.      of GLX extensions. */
  63.   if ((major == 1 && minor >= 1) || (major > 1)) {
  64.     if (!extensions)
  65.       extensions = glXQueryExtensionsString(__glutDisplay, __glutScreen);
  66.     /* It takes a bit of care to be fool-proof about parsing
  67.        the GLX extensions string.  Don't be fooled by
  68.        sub-strings,  etc. */
  69.     start = extensions;
  70.     for (;;) {
  71.       where = strstr(start, extension);
  72.       if (!where)
  73.         return 0;
  74.       terminator = where + strlen(extension);
  75.       if (where == start || *(where - 1) == ' ') {
  76.         if (*terminator == ' ' || *terminator == '\0') {
  77.           return 1;
  78.         }
  79.       }
  80.       start = terminator;
  81.     }
  82.   }
  83. #else
  84.   /* No GLX extensions before GLX 1.1 */
  85. #endif
  86.   return 0;
  87. }
  88.  
  89.