Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

glut_ext.c

Go to the documentation of this file.
00001 
00002 /* Copyright (c) Mark J. Kilgard, 1994. */
00003 
00004 /* This program is freely distributable without licensing fees
00005    and is provided without guarantee or warrantee expressed or
00006    implied. This program is -not- in the public domain. */
00007 
00008 #include <string.h>
00009 
00010 #include <GL/glut.h>
00011 #include "glutint.h"
00012 
00013 int
00014 glutExtensionSupported(char *extension)
00015 {
00016   static const GLubyte *extensions = NULL;
00017   const GLubyte *start;
00018   GLubyte *where, *terminator;
00019 
00020   /* Extension names should not have spaces. */
00021   where = (GLubyte *) strchr(extension, ' ');
00022   if (where || *extension == '\0')
00023     return 0;
00024 
00025   if (!extensions)
00026     extensions = glGetString(GL_EXTENSIONS);
00027   /* It takes a bit of care to be fool-proof about parsing the
00028      OpenGL extensions string.  Don't be fooled by sub-strings, 
00029      etc. */
00030   start = extensions;
00031   for (;;) {
00032     where = (GLubyte *) strstr((const char *)start, extension);
00033     if (!where)
00034       break;
00035     terminator = where + strlen(extension);
00036     if (where == start || *(where - 1) == ' ') {
00037       if (*terminator == ' ' || *terminator == '\0') {
00038         return 1;
00039       }
00040     }
00041     start = terminator;
00042   }
00043   return 0;
00044 }
00045 
00046 int
00047 __glutIsSupportedByGLX(char *extension)
00048 {
00049 #if defined(GLX_VERSION_1_1)
00050   static const char *extensions = NULL;
00051   const char *start;
00052   char *where, *terminator;
00053   int major, minor;
00054 
00055   glXQueryVersion(__glutDisplay, &major, &minor);
00056   /* Be careful not to call glXQueryExtensionsString if it
00057      looks like the server doesn't support GLX 1.1.
00058      Unfortunately, the original GLX 1.0 didn't have the notion 
00059      of GLX extensions. */
00060   if ((major == 1 && minor >= 1) || (major > 1)) {
00061     if (!extensions)
00062       extensions = glXQueryExtensionsString(__glutDisplay, __glutScreen);
00063     /* It takes a bit of care to be fool-proof about parsing
00064        the GLX extensions string.  Don't be fooled by
00065        sub-strings,  etc. */
00066     start = extensions;
00067     for (;;) {
00068       where = strstr(start, extension);
00069       if (!where)
00070         return 0;
00071       terminator = where + strlen(extension);
00072       if (where == start || *(where - 1) == ' ') {
00073         if (*terminator == ' ' || *terminator == '\0') {
00074           return 1;
00075         }
00076       }
00077       start = terminator;
00078     }
00079   }
00080 #else
00081   /* No GLX extensions before GLX 1.1 */
00082 #endif
00083   return 0;
00084 }
00085 
 

Powered by Plone

This site conforms to the following standards: