本文介绍了无法让 Freeglut 在 Windows 上与 Haskell 一起工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我要开始工作的源代码:

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

在 Main.hs 中:

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

在 Bindings.hs 中:

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 ()

如果我在我的代码中使用普通的 glut32.dll 并且没有任何 freeglut 扩展,它就可以工作,但我想使用 freeglut 扩展.

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.

当我使用 freeglut.dll 时,将其重命名为 glut32.dll,并将其与我的 .exe 放在同一文件夹中,它给了我错误:

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)

当我以同样的方式使用普通的 glut32.dll 时出现错误:

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

main: user error (unknown GLUT entry glutMouseWheelFunc)

推荐答案

必须使用 Mingw 的 freeglut .lib/.dll 或自己编译.

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

这篇关于无法让 Freeglut 在 Windows 上与 Haskell 一起工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-21 22:01