Skip to content

Commit 547bbf4

Browse files
committed
Try all of glut32, freeglut, and libfreeglut on Windows
1 parent 2656c92 commit 547bbf4

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

GLUT.cabal

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ extra-source-files:
4343
examples/RedBook8/Chapter01/triangles.frag
4444
examples/RedBook8/Chapter01/triangles.vert
4545

46-
flag freeglut
47-
description:
48-
When compiling under Windows, use the freeglut library.
49-
default: False
50-
manual: True
51-
5246
flag UseNativeWindowsLibraries
5347
description:
5448
When compiling under Windows, use the native libraries instead of e.g. the
@@ -100,17 +94,12 @@ library
10094
ghc-options: -Wall
10195
if impl(ghc > 8)
10296
ghc-options: -Wcompat
103-
if os(windows) && (flag(freeglut) || flag(UseNativeWindowsLibraries))
97+
if os(windows) && flag(UseNativeWindowsLibraries)
10498
if arch(i386)
10599
cpp-options: "-DCALLCONV=stdcall"
106100
else
107101
cpp-options: "-DCALLCONV=ccall"
108102
cc-options: "-DUSE_GETPROCADDRESS"
109-
if flag(freeglut)
110-
cc-options: "-DUSE_FREEGLUT"
111-
extra-libraries: freeglut
112-
else
113-
extra-libraries: glut32
114103
else
115104
cpp-options: "-DCALLCONV=ccall"
116105
cc-options: "-DUSE_DLSYM"

cbits/HsGLUT.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,17 @@ hs_GLUT_getProcAddress(const char *name)
8585

8686
if (firstTime) {
8787
firstTime = 0;
88-
#if defined(USE_FREEGLUT)
89-
handle = LoadLibrary(TEXT("freeglut"));
88+
handle = LoadLibrary(TEXT("glut32"));
89+
90+
// If glut32 isn't present, try freeglut instead
91+
if (!handle) {
92+
handle = LoadLibrary(TEXT("freeglut"));
93+
}
9094

9195
// The MinGW-w64 version of freeglut prefixes "lib" onto the DLL name
9296
if (!handle) {
9397
handle = LoadLibrary(TEXT("libfreeglut"));
9498
}
95-
#else
96-
handle = LoadLibrary(TEXT("glut32"));
97-
#endif
9899
}
99100

100101
return handle ? GetProcAddress(handle, name) : NULL;

0 commit comments

Comments
 (0)