|
 |
scott wrote:
> I heard Haskell has OpenGL capability, how easy is that to get running -
> then we might be talking :-)
Heh, OK, it's just taken me the entire morning to figure this out.
(Documented? What do you mean documented? Why would it be documented??)
First: The Haskell Platform includes OpenGL out-of-the-box, so it should
Just Work(tm).
Second: The documentation for OpenGL is missing, which made me spend 20
minutes trying to figure out why it wasn't there. Querying the package
list confirms that OpenGL actually *is* there, it's only the
documentation that's missing. (Thanks, guys...)
Third: I compiled a simple OpenGL program, and it crashed with "cannot
find glut32.dll". I don't know if that's because I don't have a 3D card
on this machine or what. Anyway, it took a while to fix it! YMMV.
Start with this:
module Main where
import Graphics.Rendering.OpenGL
import Graphics.UI.GLUT
myPoints :: [(GLfloat,GLfloat,GLfloat)]
myPoints = map (\k -> (sin(2*pi*k/12),cos(2*pi*k/12),0.0)) [1..12]
main = do
(progname, _) <- getArgsAndInitialize
createWindow "Hello World"
displayCallback $= display
mainLoop
display = do
clear [ColorBuffer]
renderPrimitive Points $ mapM_ (\(x, y, z)->vertex$Vertex3 x y z)
myPoints
flush
Save that lot as Test.hs or something. Then execute
ghc --make Test
That should generate Test.exe. Now run it.
If it whines about not finding glut32.dll, go here:
http://www.transmissionzero.co.uk/software/freeglut-devel/
Download the "FreeGLUT MinGW" package, and unpack glut32.dll from it.
(You can ignore all the other files; you only need the DLL.) Drop the
DLL into your search path or just into the same folder as Test.exe, and
then try and run it.
If it works, you should get a black window with some white dots.
Assuming all of that works, you now just need to learn the whole Haskell
programming language, including how to do I/O, and learn the OpenGL
binding, and then you can do stuff. ;-)
And now if you'll excuse me, I'm going to go file a bunch of tickets
with the bugtracker. :-P
Post a reply to this message
|
 |