15
15
#define WIN32_LEAN_AND_MEAN
16
16
#include <windows.h>
17
17
18
+ static LPCTSTR libNames [] = {
19
+ /* Try to load freeglut first, it has a few extra features compared to classic
20
+ GLUT. */
21
+ TEXT ("freeglut" ),
22
+ /* The MinGW-w64 version of freeglut prefixes "lib" onto the DLL name. */
23
+ TEXT ("libfreeglut" ),
24
+ /* If no freeglut version is found, try plain old glut32 instead. */
25
+ TEXT ("glut32" )
26
+ };
27
+
18
28
void *
19
29
hs_GLUT_getProcAddress (const char * name )
20
30
{
21
31
static int firstTime = 1 ;
22
32
static HMODULE handle = NULL ;
23
33
24
34
if (firstTime ) {
35
+ int i , numNames = (int )(sizeof (libNames ) / sizeof (libNames [0 ]));
25
36
firstTime = 0 ;
26
-
27
- /* Try to load freeglut first, it has a few extra features compared to
28
- classic GLUT. */
29
- handle = LoadLibrary (TEXT ("freeglut" ));
30
-
31
- /* The MinGW-w64 version of freeglut prefixes "lib" onto the DLL name. */
32
- if (!handle ) {
33
- handle = LoadLibrary (TEXT ("libfreeglut" ));
34
- }
35
-
36
- /* If no freeglut version is found, try plain old glut32 instead. */
37
- if (!handle ) {
38
- handle = LoadLibrary (TEXT ("glut32" ));
37
+ for (i = 0 ; (!handle ) && (i < numNames ); ++ i ) {
38
+ handle = LoadLibrary (libNames [i ]);
39
39
}
40
40
}
41
41
@@ -48,26 +48,29 @@ hs_GLUT_getProcAddress(const char *name)
48
48
#include <stdlib.h>
49
49
#include <dlfcn.h>
50
50
51
+ static const char * libNames [] = {
52
+ #ifdef __APPLE__
53
+ /* Try public framework path first. */
54
+ "/Library/Frameworks/GLUT.framework/GLUT" ,
55
+ /* If the public path failed, try the system framework path. */
56
+ "/System/Library/Frameworks/GLUT.framework/GLUT"
57
+ #else
58
+ "libglut.so" , "libglut.so.3"
59
+ #endif
60
+ };
61
+
51
62
void *
52
63
hs_GLUT_getProcAddress (const char * name )
53
64
{
54
65
static int firstTime = 1 ;
55
66
static void * handle = NULL ;
56
67
57
68
if (firstTime ) {
69
+ int i , numNames = (int )(sizeof (libNames ) / sizeof (libNames [0 ]));
58
70
firstTime = 0 ;
59
-
60
- #ifdef __APPLE__
61
- /* Try public framework path first. */
62
- handle = dlopen ("/Library/Frameworks/GLUT.framework/GLUT" , RTLD_LAZY | RTLD_GLOBAL );
63
-
64
- /* If the public path failed, try the system framework path. */
65
- if (!handle ) {
66
- handle = dlopen ("/System/Library/Frameworks/GLUT.framework/GLUT" , RTLD_LAZY | RTLD_GLOBAL );
71
+ for (i = 0 ; (!handle ) && (i < numNames ); ++ i ) {
72
+ handle = dlopen (libNames [i ], RTLD_LAZY | RTLD_GLOBAL );
67
73
}
68
- #else
69
- handle = dlopen ("libglut.so" , RTLD_LAZY | RTLD_GLOBAL );
70
- #endif
71
74
}
72
75
73
76
return handle ? dlsym (handle , name ) : NULL ;
0 commit comments