[HOpenGL] clear [ColorBuffer]
Sven Panne
sven.panne at aedion.de
Mon Feb 19 09:24:49 EST 2007
On Friday 16 February 2007 19:35, h. wrote:
> [...] and the problem:
> The ColorBuffer is not cleared, the window shows what was there before it
> was created. [...]
Just a small addition: As was already pointed out, rendering in OpenGL is not
synchronous, which is a very good design decision given the capabilities and
architectures of today's graphic cards. If you use single-buffering (as in
your example), a 'flush' or 'finish' is needed, see:
http://www.haskell.org/ghc/docs/latest/html/libraries/OpenGL/Graphics-Rendering-OpenGL-GL-FlushFinish.html
If double-buffering is used, GLUT's 'swapBuffers' is your friend:
http://www.haskell.org/ghc/docs/latest/html/libraries/GLUT/Graphics-UI-GLUT-Window.html#v%3AswapBuffers
Example:
--------------------------------------------------------------------------
import Graphics.UI.GLUT
main :: IO ()
main = do
_ <- getArgsAndInitialize
initialDisplayMode $= [ DoubleBuffered ]
createWindow "Hello World"
displayCallback $= do clear [ ColorBuffer ]; swapBuffers
mainLoop
--------------------------------------------------------------------------
Other UI toolkits with an OpenGL canvas will have something similar
to 'swapBuffers', e.g. 'glDrawableSwapBuffers' in Gtk2Hs, IIRC.
Cheers,
S.
More information about the HOpenGL
mailing list