[go: up one dir, main page]

File: check_extension.c

package info (click to toggle)
sage 0.1.2-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,464 kB
  • ctags: 8,618
  • sloc: ansic: 16,588; sh: 8,331; perl: 115; makefile: 109
file content (47 lines) | stat: -rw-r--r-- 1,243 bytes parent folder | download
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
46
47
// 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-2005 Simon Goodall

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

#include <sage/utility.h>

/*
 * function Taken from OpenGL FAQ
 */

static GLubyte *extensions = NULL;

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

  /* Extension names should not have spaces. */
  where = (GLubyte *) strchr(extension, ' ');
  if (where || *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) == ' ')
      if (*terminator == ' ' || * terminator == '\0')
        return 1;
    start = terminator;
  }
  return 0;
}