 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> simulations,
I heard Haskell has OpenGL capability, how easy is that to get running -
then we might be talking :-)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> 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.
Yup, OpenGL doesn't ship with GLUT (OpenGL Utility Toolkit). You need to
download it separately.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> myPoints
> flush
>
> Save that lot as Test.hs or something. Then execute
>
> ghc --make Test
I get:
Test.hs:20:0: parse error (possibly incorrect indentation)
I guess something with the indentation is not correct at the end of the .hs
file? What does it need?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
scott wrote:
>> myPoints
>> flush
>>
>> Save that lot as Test.hs or something. Then execute
>>
>> ghc --make Test
>
> I get:
>
> Test.hs:20:0: parse error (possibly incorrect indentation)
>
> I guess something with the indentation is not correct at the end of the
> .hs file? What does it need?
The "myPoints" is supposed to be at the end of the previous line.
Apparently it got wrapped...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Cool it works! (I had to rename freeglut.dll to glut32.dll)
Now to learn Haskell...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
scott wrote:
> Cool it works! (I had to rename freeglut.dll to glut32.dll)
Oh, yeah, I forgot to mention that part. o_O
> Now to learn Haskell...
LOL! Um, yes. ;-)
You'd probably be best learning the pure part of Haskell first, since
this is the primary objective of Haskell. The impure part of Haskell is
just like any other language - but far, far more wordy. Thing is, OpenGL
is all *about* the impure part, so...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
scott wrote:
> You're also quite good a writing tutorials, you should definitely write
> a book. Haskell for Imperative Programmers. :-)
If I write it, will you help review it?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> You're also quite good a writing tutorials, you should definitely write a
>> book. Haskell for Imperative Programmers. :-)
>
> If I write it, will you help review it?
Of course! But I expect 50% of the profits :-D
Also it will be a good excuse to hold off learning Haskell for now, as then
I'll still be a real beginner when you finish the first draft...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
scott wrote:
>>> You're also quite good a writing tutorials, you should definitely
>>> write a book. Haskell for Imperative Programmers. :-)
>>
>> If I write it, will you help review it?
>
> Of course! But I expect 50% of the profits :-D
> Also it will be a good excuse to hold off learning Haskell for now, as
> then I'll still be a real beginner when you finish the first draft...
Hehehe, OK then. :-)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |