通过Opengl和GLUT在Haskell中编程 [英] Programming in Haskell via Opengl and GLUT

查看:121
本文介绍了通过Opengl和GLUT在Haskell中编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我尝试编译并运行我找到的教程时,都会收到一条消息无法找到模块GL或无法找到模块GLUT。我尝试用import Graphics.Rendering.OpenGL和import Graphics.UI.GLUT替换import GLUT,但这只会导致更多错误。应该导入GLUT做某事,还是仅仅是我误解的伪代码?

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?

推荐答案

GLUT OpenGL 是运行OpenGL应用程序所需的 。这不是C,其中导入一个将导入另一个。

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

下面的代码将创建一个简单的OpenGL窗口,只需刷新每个渲染上的命令缓冲区,检查程序是否有效:

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

用以下程序编译程序:

ghc --make program.hs

如果这不成功,则意味着您没有正确安装Haskell平台,并且您需要检查OpenGL软件包是否已正确安装。

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.

这篇关于通过Opengl和GLUT在Haskell中编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆