zenilib: zenilib/jni/external/glew/auto/src/glew_utils.c Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
glew_utils.c
Go to the documentation of this file.
1 /*
2 ** The OpenGL Extension Wrangler Library
3 ** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
4 ** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
5 ** Copyright (C) 2002, Lev Povalahev
6 ** All rights reserved.
7 **
8 ** Redistribution and use in source and binary forms, with or without
9 ** modification, are permitted provided that the following conditions are met:
10 **
11 ** * Redistributions of source code must retain the above copyright notice,
12 ** this list of conditions and the following disclaimer.
13 ** * Redistributions in binary form must reproduce the above copyright notice,
14 ** this list of conditions and the following disclaimer in the documentation
15 ** and/or other materials provided with the distribution.
16 ** * The name of the author may be used to endorse or promote products
17 ** derived from this software without specific prior written permission.
18 **
19 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29 ** THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <GL/glew.h>
33 #if defined(_WIN32)
34 # include <GL/wglew.h>
35 #elif !defined(__ANDROID__) && !defined(__native_client__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX))
36 # include <GL/glxew.h>
37 #endif
38
39 #include "glew_utils.h"
40
41 #if defined(__APPLE__)
42 #include <mach-o/dyld.h>
43 #include <stdlib.h>
44 #include <string.h>
45
46 void* NSGLGetProcAddress (const GLubyte *name)
47 {
48 NSSymbol symbol;
49 char* symbolName;
50 /* prepend a '_' for the Unix C symbol mangling convention */
51 symbolName = malloc(strlen((const char*)name) + 2);
52 strcpy(symbolName+1, (const char*)name);
53 symbolName[0] = '_';
54 symbol = NULL;
55 if (NSIsSymbolNameDefined(symbolName))
56 symbol = NSLookupAndBindSymbol(symbolName);
57 free(symbolName);
58 return symbol ? NSAddressOfSymbol(symbol) : NULL;
59 }
60 #endif /* __APPLE__ */
61
62 #if defined(__sgi) || defined (__sun)
63 #include <dlfcn.h>
64 #include <stdio.h>
65 #include <stdlib.h>
66
67 void* dlGetProcAddress (const GLubyte* name)
68 {
69 static void* h = NULL;
70 static void* gpa;
71
72 if (h == NULL)
73 {
74 if ((h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL)) == NULL) return NULL;
75 gpa = dlsym(h, "glXGetProcAddress");
76 }
77
78 if (gpa != NULL)
79 return ((void*(*)(const GLubyte*))gpa)(name);
80 else
81 return dlsym(h, (const char*)name);
82 }
83 #endif /* __sgi || __sun */
84
85 /*
86 * GLEW, just like OpenGL or GLU, does not rely on the standard C library.
87 * These functions implement the functionality required in this file.
88 */
89
90 GLuint _glewStrLen (const GLubyte* s)
91 {
92 GLuint i=0;
93 while (s+i != NULL && s[i] != '\0') i++;
94 return i;
95 }
96
97 GLuint _glewStrCLen (const GLubyte* s, GLubyte c)
98 {
99 GLuint i=0;
100 while (s+i != NULL && s[i] != '\0' && s[i] != c) i++;
101 return i;
102 }
103
104 GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n)
105 {
106 GLuint i=0;
107 while (i < n && a+i != NULL && b+i != NULL && a[i] == b[i]) i++;
108 return i == n ? GL_TRUE : GL_FALSE;
109 }
110
111 GLboolean _glewStrSame1 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb)
112 {
113 while (*na > 0 && (**a == ' ' || **a == '\n' || **a == '\r' || **a == '\t'))
114 {
115 *a++;
116 *na--;
117 }
118 if(*na >= nb)
119 {
120 GLuint i=0;
121 while (i < nb && *a+i != NULL && b+i != NULL && *a[i] == b[i]) i++;
122 if(i == nb)
123 {
124 *a = *a + nb;
125 *na = *na - nb;
126 return GL_TRUE;
127 }
128 }
129 return GL_FALSE;
130 }
131
132 GLboolean _glewStrSame2 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb)
133 {
134 if(*na >= nb)
135 {
136 GLuint i=0;
137 while (i < nb && *a+i != NULL && b+i != NULL && *a[i] == b[i]) i++;
138 if(i == nb)
139 {
140 *a = *a + nb;
141 *na = *na - nb;
142 return GL_TRUE;
143 }
144 }
145 return GL_FALSE;
146 }
147
148 GLboolean _glewStrSame3 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb)
149 {
150 if(*na >= nb)
151 {
152 GLuint i=0;
153 while (i < nb && *a+i != NULL && b+i != NULL && *a[i] == b[i]) i++;
154 if (i == nb && (*na == nb || *a[i] == ' ' || *a[i] == '\n' || *a[i] == '\r' || *a[i] == '\t'))
155 {
156 *a = *a + nb;
157 *na = *na - nb;
158 return GL_TRUE;
159 }
160 }
161 return GL_FALSE;
162 }
GL_TRUE
#define GL_TRUE
Definition: gl2.h:51
s
GLdouble s
Definition: glew.h:1376
GL_FALSE
#define GL_FALSE
Definition: gl2.h:50
h
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:7294
NULL
#define NULL
Definition: ftobjs.h:61
GLboolean
unsigned char GLboolean
Definition: gl2.h:24
n
GLclampd n
Definition: glew.h:7287
free
SDL_EventEntry * free
Definition: SDL_events.c:80
a
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:8736
name
EGLImageKHR EGLint * name
Definition: eglext.h:284
_glewStrCLen
static GLuint _glewStrCLen(const GLubyte *s, GLubyte c)
Definition: glew_head.c:161
glew_utils.h
_glewStrSame
static GLboolean _glewStrSame(const GLubyte *a, const GLubyte *b, GLuint n)
Definition: glew_head.c:169
GLubyte
khronos_uint8_t GLubyte
Definition: gl2.h:30
c
const GLfloat * c
Definition: glew.h:14913
_glewStrSame1
static GLboolean _glewStrSame1(GLubyte **a, GLuint *na, const GLubyte *b, GLuint nb)
Definition: glew_head.c:178
_glewStrLen
static GLuint _glewStrLen(const GLubyte *s)
Definition: glew_head.c:153
_glewStrSame2
static GLboolean _glewStrSame2(GLubyte **a, GLuint *na, const GLubyte *b, GLuint nb)
Definition: glew_head.c:199
malloc
#define malloc
Definition: SDL_malloc.c:635
GLuint
unsigned int GLuint
Definition: gl2.h:32
String.h
b
GLdouble GLdouble GLdouble b
Definition: glew.h:8383
i
int i
Definition: pngrutil.c:1377
_glewStrSame3
GLboolean _glewStrSame3(GLubyte **a, GLuint *na, const GLubyte *b, GLuint nb)
Definition: glew_utils.c:148