Can't get Freeglut to work with Haskell on Windows
Asked Answered
R

2

8

Here is my source code I'm trying to get to work:

In Main.hs:

import Graphics.Rendering.OpenGL
import Graphics.UI.GLUT
import Bindings
import Data.IORef
main = do
    (progname,_) <- getArgsAndInitialize
    createWindow "Hello World"
    reshapeCallback $= Just reshape
    keyboardMouseCallback $= Just keyboardMouse
    angle <- newIORef 0.0
    displayCallback $= display
    idleCallback $= Just idle
    mouseWheelCallback $= Just mouseWheel
    mainLoop

In Bindings.hs:

module Bindings where
import Graphics.Rendering.OpenGL
import Graphics.UI.GLUT

display :: IO ()
display = return ()

overlayDisplay :: IO ()
overlayDisplay = return ()

visibility :: Visibility -> IO ()
visibility v = return ()

reshape :: Size -> IO ()
reshape s@(Size w h) = do 
    viewport $= (Position 0 0, s)

close :: IO ()
close = return ()

keyboardMouse :: Key -> KeyState -> Modifiers -> Position -> IO ()
keyboardMouse key state modifiers position = return ()

mouseWheel :: WheelNumber -> WheelDirection -> Position -> IO ()
mouseWheel wn wd p = return ()

idle :: IO ()
idle = return ()

It works if I use normal glut32.dll and none of the freeglut extensions in my code, but I want to use the freeglut extensions.

When I use freeglut.dll, rename it to glut32.dll, and put it in the same folder as my .exe, it gives me the error:

main: user error (unknown GLUT entry glutInit)

When I use the normal glut32.dll in the same way I get the error:

main: user error (unknown GLUT entry glutMouseWheelFunc)
Radiochemistry answered 21/1, 2012 at 20:25 Comment(1)
If you've solved your problem, please consider closing the question.Dorren
H
0

You have to use freeglut .lib/.dll from Mingw or compile it yourself.

Herzl answered 27/1, 2012 at 13:34 Comment(0)
A
10
  1. download glut from http://www.transmissionzero.co.uk/software/freeglut-devel/. Be sure to download the MinGW version.

  2. copy the file freeglut-MinGW-3.0.0-1.mp.zip\freeglut\bin\x64\freeglut.dll to C:\Windows\System32. Make sure you get the 64 bit version from the x64 folder.

  3. rename it as glut32.dll

I just solved this problem and hope this could help others.

Anagrammatize answered 27/9, 2015 at 14:17 Comment(1)
Thanks. Nice hack.Stores
H
0

You have to use freeglut .lib/.dll from Mingw or compile it yourself.

Herzl answered 27/1, 2012 at 13:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.