~ubuntu-branches/ubuntu/saucy/sage/saucy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// This file may be redistributed and modified only under the terms of
// the GNU Lesser General Public License (See COPYING for details).
// Copyright (C) 2003 - 2006 Simon Goodall

#define __glext_h_ 1
#include "GL.h"
#undef __glext_h_
#include <string.h>

#include <sage/utility.h>

/*
 * function Taken from OpenGL FAQ
 */

int isExtensionSupported(const char *extension, const GLubyte *extensions) {
//  const GLubyte *extensions = NULL;
  const GLubyte *start;
  GLubyte *where, *terminator;

  /* Extension names should not have spaces. */
  where = (GLubyte *) strchr(extension, ' ');
  if ((where != NULL) || *extension == '\0')
    return 0;
  
//  if (extensions == NULL) extensions = (GLubyte*)glGetString(GL_EXTENSIONS);
  
  if (extensions == NULL) return 0;
  
  /* It takes a bit of care to be fool-proof about parsing the
     OpenGL extensions string. Don't be fooled by sub-strings,
     etc. */
  start = extensions;
  for (;;) {
    where = (GLubyte*) strstr((const char *) start, extension);
    if (!where)
      break;
    terminator = where + strlen(extension);
    if (where == start || *(where - 1) == (GLubyte)' ')
      if (*terminator == (GLubyte)' ' || *terminator == (GLubyte)'\0')
        return 1;
    start = terminator;
  }
  return 0;
}