Skip to content

Commit 7f774f1

Browse files
committed
Merge pull request #23 from RyanGlScott/master
Allow building with freeglut on Windows
2 parents 463f0c5 + 547bbf4 commit 7f774f1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

GLUT.cabal

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ extra-source-files:
4646
flag UseNativeWindowsLibraries
4747
description:
4848
When compiling under Windows, use the native libraries instead of e.g. the
49-
ones coming with Cygwin.
49+
ones coming with Cygwin or MSYS.
5050

5151
flag BuildExamples
5252
description: Build various OpenGL/GLUT examples.
@@ -100,7 +100,6 @@ library
100100
else
101101
cpp-options: "-DCALLCONV=ccall"
102102
cc-options: "-DUSE_GETPROCADDRESS"
103-
extra-libraries: glut32
104103
else
105104
cpp-options: "-DCALLCONV=ccall"
106105
cc-options: "-DUSE_DLSYM"

cbits/HsGLUT.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ hs_GLUT_getProcAddress(const char *name)
8686
if (firstTime) {
8787
firstTime = 0;
8888
handle = LoadLibrary(TEXT("glut32"));
89+
90+
// If glut32 isn't present, try freeglut instead
91+
if (!handle) {
92+
handle = LoadLibrary(TEXT("freeglut"));
93+
}
94+
95+
// The MinGW-w64 version of freeglut prefixes "lib" onto the DLL name
96+
if (!handle) {
97+
handle = LoadLibrary(TEXT("libfreeglut"));
98+
}
8999
}
90100

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

0 commit comments

Comments
 (0)