[HOpenGL] Black Screen with GHC&HOpenGL

Daniel cornicis at googlemail.com
Sat Feb 6 20:06:55 EST 2010


Hello!
So, my problem is this: I can compile my "Main.hs" without errors, but 
when I'm executing the application a black screen appears and my cursour 
is still visible. After klicking somewhere on the screen my normal 
Desktop reappears with "Hello World" in my task bar. I can minimize all 
other windows to have only "Hello World" visible, but the black screen 
appears again when I'm trying to activate the window. Do you know what I 
am doing wrong?

Ubuntu is my OS, all libraries are installed, I have the same problem 
using Hugs.

Here's my Main.hs:

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

main = do
  (progname, _) <- getArgsAndInitialize
  createWindow "Hello World"
  displayCallback $= display
  reshapeCallback $= Just reshape
  mainLoop

reshape s@(Size w h) = do
  viewport $= (Position 0 0, s)
  postRedisplay Nothing

myPoints :: [(GLfloat, GLfloat, GLfloat)]
myPoints = map (\k -> (sin(2*pi*k/12),cos(2*pi*k/12),0.0)) [1..12]

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

Thanks for helping! :)


More information about the HOpenGL mailing list