Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 3D Graphics with Haskell
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
wtd




PostPosted: Sat Mar 05, 2005 2:11 pm   Post subject: 3D Graphics with Haskell

I know a lot of people here are primarily concerned with graphics, so a quick screenshot, then the code.

Posted Image, might have been reduced in size. Click Image to view fullscreen.

Quote:
module Main where

import Graphics.UI.GLUT
import Graphics.Rendering.OpenGL

main = do
(progName,_) <-getArgsAndInitialize
createAWindow progName
mainLoop

createAWindow windowName = do
createWindow windowName
displayCallback $= displayPoints

displayPoints = do
clear [ColorBuffer]
renderPrimitive Polygon
$ mapM_ (\(x, y, z) -> vertex $ Vertex3 x y z) myPoints

myPoints :: [(GLfloat,GLfloat,GLfloat)]
myPoints =
[(-0.25, 0.25, 0.0)
,(0.75, 0.35, 0.0)
,(0.75, -0.15, 0.0)
,((-0.75), -0.25, 0.0)]


And now, the command required to compile it (Main.hs) using GHC (Glasgow Haskell Compiler) 6.4:

code:
$ ghc --make Main
Chasing modules from: Main
Skipping  Main             ( Main.hs, Main.o )
Linking ...
$ ./a.out


A tutorial is available at:

http://www.tfh-berlin.de/~panitz/hopengl/skript.html#tth_chAp1
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: