[HOpenGL] Black Screen with GHC&HOpenGL

Daniel cornicis at googlemail.com
Sun Feb 7 08:15:44 EST 2010


I've played a bit around and tried to use DoubleBuffered display mode 
instead of single and everything works fine (as I read using 
DoubleBuffered is important to avoid animation flicker, so I would have 
to use it anyway) . Thanks for helping, know I can start using OpenGL 
with Haskell, I hope there won't be any big problems in the future.

If anybody has the same problems, here's my Main.hs:
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=17220

Daniel

Balazs Komuves schrieb:
>
> Hi Daniel,
>
> Your program works fine here (OSX + GHC 6.10.1), so I can only guess:
>  - you either have some installation program (are you on a 64 bit 
> system by any chance?)
>  - or the GLUT implementation is a bit different, and needs some more 
> initialization.
>
> In particular, I would try setting `initialDisplayMode' before calling 
> `createWindow', eg.
>
>     initialDisplayMode $= [ RGBAMode ]
>
>
> and possibly also `initialWindowSize'.
>
> Also, there is no clean way to exit the program; you should set up a 
> keyboard handler
> and exit on pressing ESC or something like that, but this is not 
> really important.
>
> Balazs
>
> On Sun, Feb 7, 2010 at 2:06 AM, Daniel <cornicis at googlemail.com 
> <mailto:cornicis at googlemail.com>> wrote:
>
>     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! :)
>     _______________________________________________
>     HOpenGL mailing list
>     HOpenGL at haskell.org <mailto:HOpenGL at haskell.org>
>     http://www.haskell.org/mailman/listinfo/hopengl
>
>



More information about the HOpenGL mailing list