1 /* ------------------------------------------------------------------------ */
2 
glewGetErrorString(GLenum error)3 const GLubyte * GLEWAPIENTRY glewGetErrorString (GLenum error)
4 {
5   static const GLubyte* _glewErrorString[] =
6   {
7     (const GLubyte*)"No error",
8     (const GLubyte*)"Missing GL version",
9     (const GLubyte*)"GL 1.1 and up are not supported",
10     (const GLubyte*)"GLX 1.2 and up are not supported",
11     (const GLubyte*)"Unknown error"
12   };
13   const size_t max_error = sizeof(_glewErrorString)/sizeof(*_glewErrorString) - 1;
14   return _glewErrorString[(size_t)error > max_error ? max_error : (size_t)error];
15 }
16 
glewGetString(GLenum name)17 const GLubyte * GLEWAPIENTRY glewGetString (GLenum name)
18 {
19   static const GLubyte* _glewString[] =
20   {
21     (const GLubyte*)NULL,
22     (const GLubyte*)"GLEW_VERSION_STRING",
23     (const GLubyte*)"GLEW_VERSION_MAJOR_STRING",
24     (const GLubyte*)"GLEW_VERSION_MINOR_STRING",
25     (const GLubyte*)"GLEW_VERSION_MICRO_STRING"
26   };
27   const size_t max_string = sizeof(_glewString)/sizeof(*_glewString) - 1;
28   return _glewString[(size_t)name > max_string ? 0 : (size_t)name];
29 }
30 
31 /* ------------------------------------------------------------------------ */
32 
33 GLboolean glewExperimental = GL_FALSE;
34 
glewInit(void)35 GLenum GLEWAPIENTRY glewInit (void)
36 {
37   GLenum r;
38 #if defined(GLEW_EGL)
39   PFNEGLGETCURRENTDISPLAYPROC getCurrentDisplay = NULL;
40 #endif
41   r = glewContextInit();
42   if ( r != 0 ) return r;
43 #if defined(GLEW_EGL)
44   getCurrentDisplay = (PFNEGLGETCURRENTDISPLAYPROC) glewGetProcAddress("eglGetCurrentDisplay");
45   return eglewInit(getCurrentDisplay());
46 #elif defined(GLEW_OSMESA) || defined(__ANDROID__) || defined(__native_client__) || defined(__HAIKU__)
47   return r;
48 #elif defined(_WIN32)
49   return wglewInit();
50 #elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */
51   return glxewInit();
52 #else
53   return r;
54 #endif /* _WIN32 */
55 }
56 
57 #if defined(_WIN32) && defined(GLEW_BUILD) && defined(__GNUC__)
58 /* GCC requires a DLL entry point even without any standard library included. */
59 /* Types extracted from windows.h to avoid polluting the rest of the file. */
DllMainCRTStartup(void * instance,unsigned reason,void * reserved)60 int __stdcall DllMainCRTStartup(void* instance, unsigned reason, void* reserved)
61 {
62   (void) instance;
63   (void) reason;
64   (void) reserved;
65   return 1;
66 }
67 #endif
68