[HOpenGL] HOpenGL postRedisplay in Mac

Francisco Listas francisco.listas at gmail.com
Mon Mar 21 17:43:46 CET 2011


Thanks for your answer! It was, in fact, a problem between the
keyboard and the seat, my scene scaled out of screen in one frame that
was my problem.

On Mon, Mar 21, 2011 at 12:28 PM, Balazs Komuves <bkomuves at gmail.com> wrote:
>
> Hi,
>
> It's not easy to answer these type of questions without looking at the code,
> but I guess that you forgot "swapBuffers"; also "postRedisplay" is at the
> wrong place.
> Idle callback shouldn't be used in normal circumstances.
>
> In double-buffering mode, by default OpenGL draws on the back plane, and you
> see the
> front page. After you finish the drawing, you swap the two using
> "swapBuffers".
>
> "postRedisplay Nothing" tells GLUT that the screen is needing a refresh
> (normal
> applications do not render continuously, just when something happens on the
> screen).
> If you want continuous animation, I recommend the following code structure,
> where
> swapBuffers and postRedisplay are at the end of the display callback:
>
>> -- This is the display callback. You do the drawing here.
>> -- Idle callback shouldn't be used at all. Animation should be depend
>
>    -- only on time, not on frames.
>>
>> display = do
>>
>>   matrixMode $= Projection
>>   loadIdentity
>>   -- set projection matrix here, for example:
>>   ortho (-1) 1 (-1) 1 (-1) 1
>>
>>   matrixMode $= Modelview 0
>>   loadIdentity
>>
>      t1 <- get elapsedTime
>      let t = fromIntegral t1 * 0.001 :: Double        -- elapsed time in
> seconds
>
>>   -- do some drawing here, depending on "t"
>>   renderPrimitive Lines $ do
>>     vertex (Vertex2 ....)
>>     -- etc
>>
>>   swapBuffers                  -- this is for correct double buffer
>>   postRedisplay Nothing   -- this is to ensure that the next frame will be
>> rendered, too
>
>
> Hope this helps,
> Balazs
>
>
> On Tue, Mar 15, 2011 at 11:19 PM, Francisco Listas
> <francisco.listas at gmail.com> wrote:
>>
>> Hello all,
>>
>> I am following the tutorial on
>> http://www.haskell.org/haskellwiki/OpenGLTutorial2 everything works
>> ok, but the moment I  add "postRedisplay Nothing" to the idle function
>> nothing is displayed.
>> I've tried passing the current window to postRedisplay, adding double
>> buffering (it is supposed to be done internally on mac) but no image.
>> If I comment out postRedisplay then I can see the image but no animation
>>
>> I am using Snow Leopard 10.6 and GHC from the 32bit Haskell Platform
>> 2010.2.0.0
>>
>> Any clue to what's happening?
>>
>> Thx,
>> Francisco
>>
>> _______________________________________________
>> HOpenGL mailing list
>> HOpenGL at haskell.org
>> http://www.haskell.org/mailman/listinfo/hopengl
>
>



More information about the HOpenGL mailing list