Every time I try to compile and run a tutorial that I have found, I get a message saying either "Could not find module GL" or "Could not find module GLUT." I have tried replacing "import GLUT" with "import Graphics.Rendering.OpenGL" and "import Graphics.UI.GLUT", but this just causes even more errors. Should "import GLUT" do something, or is it just pseudo code that I'm misinterpreting?
Asked
Active
Viewed 2,348 times
3
-
1Have you run `cabal install opengl` and `cabal install glut`? – Jon Purdy Mar 03 '12 at 18:49
1 Answers
4
GLUT
and OpenGL
are both needed to run an OpenGL application. This isn't C where importing one will import the other.
So, you need to import the libraries like this:
import Graphics.Rendering.OpenGL
import Graphics.UI.GLUT
The following code will then create a simple OpenGL window that simply flushes the command buffer on each render, to check if the program works:
main :: IO ()
main = do
(progname, _) <- getArgsAndInitialize
createWindow "Hello World"
displayCallback $= flush
mainLoop
Compile the program with:
ghc --make program.hs
If this doesn't succeed, it means that you didn't install the Haskell Platform correctly, and you need to check that the OpenGL packages are correctly installed.

dflemstr
- 25,947
- 5
- 70
- 105
-
So if a tutorial program has improt GLUT as the first line, I should put both import Graphics.Rendering.OpenGL and import Graphics.UI.GLUT instead? – lewdsterthumbs Mar 04 '12 at 21:29