home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 5 / MA_Cover_5.iso / ppc / mesa / src-glut / glut_ext.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-31  |  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 <stdlib.h>
  9. #include <string.h>
  10.  
  11. #include <GL/glut.h>
  12. #include "glutint.h"
  13.  
  14. /* CENTRY */
  15. int APIENTRY 
  16. glutExtensionSupported(const char *extension)
  17. {
  18.   static const GLubyte *extensions = NULL;
  19.   const GLubyte *start;
  20.   GLubyte *where, *terminator;
  21.  
  22.   /* Extension names should not have spaces. */
  23.   where = (GLubyte *) strchr(extension, ' ');
  24.   if (where || *extension == '\0')
  25.     return 0;
  26.  
  27.   if (!extensions)
  28.     extensions = glGetString(GL_EXTENSIONS);
  29.   /* It takes a bit of care to be fool-proof about parsing the
  30.      OpenGL extensions string.  Don't be fooled by sub-strings,
  31.      etc. */
  32.   start = extensions;
  33.   for (;;) {
  34.     where = (GLubyte *) strstr((const char *) start, extension);
  35.     if (!where)
  36.       break;
  37.     terminator = where + strlen(extension);
  38.     if (where == start || *(where - 1) == ' ') {
  39.       if (*terminator == ' ' || *terminator == '\0') {
  40.         return 1;
  41.       }
  42.     }
  43.     start = terminator;
  44.   }
  45.   return 0;
  46. }
  47.  
  48. /* ENDCENTRY */
  49.  
  50. int
  51. __glutIsSupportedByGLX(char *extension)
  52. {
  53. #if defined(GLX_VERSION_1_1)
  54.   static const char *extensions = NULL;
  55.   const char *start;
  56.   char *where, *terminator;
  57.   int major, minor;
  58.  
  59.   glXQueryVersion(__glutDisplay, &major, &minor);
  60.   /* Be careful not to call glXQueryExtensionsString if it
  61.      looks like the server doesn't support GLX 1.1.
  62.      Unfortunately, the original GLX 1.0 didn't have the notion
  63.      of GLX extensions. */
  64.   if ((major == 1 && minor >= 1) || (major > 1)) {
  65.     if (!extensions)
  66.       extensions = glXQueryExtensionsString(__glutDisplay, __glutScreen);
  67.     /* It takes a bit of care to be fool-proof about parsing
  68.        the GLX extensions string.  Don't be fooled by
  69.        sub-strings,  etc. */
  70.     start = extensions;
  71.     for (;;) {
  72.       where = strstr(start, extension);
  73.       if (!where)
  74.         return 0;
  75.       terminator = where + strlen(extension);
  76.       if (where == start || *(where - 1) == ' ') {
  77.         if (*terminator == ' ' || *terminator == '\0') {
  78.           return 1;
  79.         }
  80.       }
  81.       start = terminator;
  82.     }
  83.   }
  84. #else
  85.   /* No GLX extensions before GLX 1.1 */
  86. #endif
  87.   return 0;
  88. }
  89.