|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
clear [ColorBuffer]Hello,
The program: import Graphics.Rendering.OpenGL import Graphics.UI.GLUT main = do _ <- getArgsAndInitialize createWindow "Hello World" displayCallback $= clear [ ColorBuffer ] mainLoop and the problem: The ColorBuffer is not cleared, the window shows what was there before it was created. Creating windows, drawing points,... works all well, but "clear [ ColorBuffer ]" seems not to work. (I'm using the ghc 6.6 on Windows) Thanks in advance for your help. _______________________________________________ HOpenGL mailing list HOpenGL@... http://www.haskell.org/mailman/listinfo/hopengl |
|
|
Re: clear [ColorBuffer]Looks like you need to flush the graphics commands.
try this: // displayCallback $= clear [ ColorBuffer ] displayCallback $= display display = do clear [ ColorBuffer ] flush Did that work? Jamin --- "h." <h._h._h._@...> wrote: > Hello, > > The program: > > import Graphics.Rendering.OpenGL > import Graphics.UI.GLUT > > main = do > _ <- getArgsAndInitialize > createWindow "Hello World" > displayCallback $= clear [ ColorBuffer ] > mainLoop > > and the problem: > The ColorBuffer is not cleared, the window shows > what was there before it was > created. > Creating windows, drawing points,... works all well, > but "clear [ > ColorBuffer ]" seems not to work. > (I'm using the ghc 6.6 on Windows) > > Thanks in advance for your help. > > > _______________________________________________ > HOpenGL mailing list > HOpenGL@... > http://www.haskell.org/mailman/listinfo/hopengl > ____________________________________________________________________________________ Bored stiff? Loosen up... Download and play hundreds of games for free on Yahoo! Games. http://games.yahoo.com/games/front _______________________________________________ HOpenGL mailing list HOpenGL@... http://www.haskell.org/mailman/listinfo/hopengl |
|
|
Re: clear [ColorBuffer]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. _______________________________________________ HOpenGL mailing list HOpenGL@... http://www.haskell.org/mailman/listinfo/hopengl |
|
|
hopengl linksRegarding Chris' post - I ran into a lot of problems too since there are old versions of HOpenGL and corresponding examples floating around out there with differing advice, such as at http://www.haskell.org/HOpenGL/. I'm not sure why it hasn't been updated since it's off of the main haskell.org. There are some sites that include a lot of Red Book examples that should just compile and work with the method I gave (such as ghc --make Planet.hs). Anyone know a reason why some tutorials use the -package GLUT option? Try some of these links: This should have the newer examples (can anyone tell me if there are any better sites than this?) http://cvs.haskell.org/cgi-bin/cvsweb.cgi/~checkout~/fptools/libraries/GLUT/examples/RedBook/ This is a newer tutorial (blog): http://blog.mikael.johanssons.org/archive/2006/09/opengl-programming-in-haskell-a-tutorial-part-2/ This is older: http://www.haskell.org/~pairwise/HOpenGL/HOpenGL.html -Jamin ____________________________________________________________________________________ 8:00? 8:25? 8:40? Find a flick in no time with the Yahoo! Search movie showtime shortcut. http://tools.search.yahoo.com/shortcuts/#news _______________________________________________ HOpenGL mailing list HOpenGL@... http://www.haskell.org/mailman/listinfo/hopengl |
|
|
Re: hopengl linksOn Thursday 22 February 2007 13:02, Jamin A. Ohmoto-Frederick wrote:
> Regarding Chris' post - > > I ran into a lot of problems too since there are old > versions of HOpenGL and corresponding examples > floating around out there with differing advice, such > as at http://www.haskell.org/HOpenGL/. I'm not sure > why it hasn't been updated since it's off of the main > haskell.org. I admit being guilty here of not upating that site for a very long time. My amount of time I can work on HOpenGL varies quite a bit depending on my Real Life (tm) ;-), I think it might be a good idea to move the stuff to the Haskell Wiki, so it is easier to keep things up-to-date, integrate more examples/tutorials/etc. I'll think about that... > There are some sites that include a lot of Red Book > examples that should just compile and work with the > method I gave (such as ghc --make Planet.hs). Anyone > know a reason why some tutorials use the -package GLUT > option? The OpenGL/GLUT packages are exposed by default, so there is no need to specify them explicitly, unless you are manually compiling and linking. This is explained in detail at: http://www.haskell.org/ghc/docs/latest/html/users_guide/packages.html#using-packages So the easiest way to use all OpenGL/GLUT stuff is importing Graphics.UI.GLUT and using "ghc --make". A single import, no special options... > Try some of these links: > > This should have the newer examples (can anyone tell > me if there are any better sites than this?) > http://cvs.haskell.org/cgi-bin/cvsweb.cgi/~checkout~/fptools/libraries/GLUT >/examples/RedBook/ [...] The OpenGL/GLUT packages are now under darcs control instead of CVS, so the latest and greatest examples are available at: http://darcs.haskell.org/packages/GLUT/examples/ If you use Hugs, it may already ship with all the examples, e.g. at: /usr/lib/hugs/demos/GLUT Cheers, S. _______________________________________________ HOpenGL mailing list HOpenGL@... http://www.haskell.org/mailman/listinfo/hopengl |
|
|
Re: clear [ColorBuffer]Thanks a lot, it does work!
I just read a hOpenGL tutorial, and nowhere was used the flush command in connection to clear the ColorBuffer _______________________________________________ HOpenGL mailing list HOpenGL@... http://www.haskell.org/mailman/listinfo/hopengl |
|
|
Re: hopengl linksThanks Alot! I found the new updated redbook in the source code for GHC 6.6 with tons of examples. I have finally gotten the samples to compile and run, looks like clear sailing from here.
On 2/22/07, Sven Panne <sven.panne@...> wrote:
On Thursday 22 February 2007 13:02, Jamin A. Ohmoto-Frederick wrote: -- Without Wax, Chris _______________________________________________ HOpenGL mailing list HOpenGL@... http://www.haskell.org/mailman/listinfo/hopengl |
|
|
Re: Re: clear [ColorBuffer]On Thursday 22 February 2007 16:38, h. wrote:
> Thanks a lot, it does work! > > I just read a hOpenGL tutorial, and nowhere was used the flush command in > connection to clear the ColorBuffer The reason that leaving out 'flush' seems to work sometimes is that some OpenGL implementations (e.g. Mesa in SW rendering mode) do not have the highly asynchronous behaviour allowed by the OpenGL spec. OTOH, e.g. NVIDIA's driver definitely needs a 'flush'/'swapBuffers'. So as a general rule, use one of these functions at the end of your display callback. Cheers, S. _______________________________________________ HOpenGL mailing list HOpenGL@... http://www.haskell.org/mailman/listinfo/hopengl |
| Free Forum Powered by Nabble | Forum Help |