POV-Ray : Newsgroups : povray.off-topic : Try Haskell Server Time
4 Sep 2024 13:21:21 EDT (-0400)
  Try Haskell (Message 53 to 62 of 62)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: scott
Subject: Re: Try Haskell
Date: 16 Mar 2010 03:43:38
Message: <4b9f36aa$1@news.povray.org>
> 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

From: Invisible
Subject: Re: Try OpenGL
Date: 16 Mar 2010 06:48:32
Message: <4b9f6200$1@news.povray.org>
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

From: Roman Reiner
Subject: Re: Try OpenGL
Date: 16 Mar 2010 07:05:01
Message: <web.4b9f64b5e7b75d5a1c2a3d200@news.povray.org>
Invisible <voi### [at] devnull> 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

From: scott
Subject: Re: Try OpenGL
Date: 16 Mar 2010 07:29:05
Message: <4b9f6b81@news.povray.org>
> 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

From: Invisible
Subject: Re: Try OpenGL
Date: 16 Mar 2010 07:31:49
Message: <4b9f6c25$1@news.povray.org>
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

From: scott
Subject: Re: Try OpenGL
Date: 16 Mar 2010 07:44:26
Message: <4b9f6f1a$1@news.povray.org>
Cool it works!  (I had to rename freeglut.dll to glut32.dll)

Now to learn Haskell...


Post a reply to this message

From: Invisible
Subject: Re: Try OpenGL
Date: 16 Mar 2010 07:58:28
Message: <4b9f7264$1@news.povray.org>
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

From: Invisible
Subject: Re: Try Haskell
Date: 19 Mar 2010 05:53:56
Message: <4ba349b4@news.povray.org>
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

From: scott
Subject: Re: Try Haskell
Date: 19 Mar 2010 06:05:24
Message: <4ba34c64$1@news.povray.org>
>> 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

From: Invisible
Subject: Re: Try Haskell
Date: 19 Mar 2010 06:12:23
Message: <4ba34e07$1@news.povray.org>
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

<<< Previous 10 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.