
Hi, If anyone knows how to get HOpenGL to draw coloured lines, I'd like to know. Currently I can draw coloured objects like planes cylinders or spheres, but not lines. Lines always seem to appear black. Regards, Ruben

On 6/6/07, Ruben Zilibowitz
If anyone knows how to get HOpenGL to draw coloured lines, I'd like...
See http://cvs.haskell.org/cgi-bin/cvsweb.cgi/~checkout~/fptools/libraries/GLUT/... Note the color line which in this example uses white. For debugging purposes play with clearColor because you can use that to test whether you're rendering the infamous black-on-black image or simply rendering nothing :-) (Disclaimer: For some reason, today I can't test any of the redbook examples because Graphics.UI.GLUT is missing from my current installation. I'm guessing that if you have a non-broken installation they will mostly work fine. I certainly had no problem rendering lines based on these examples when I last had a non-broken installation.) -- Dan

Hi, Thanks for the reply. The Lines.hs example program seems to work just right. Unfortunately I still can't get colored lines to work in my 3d program. Maybe it has something to do with the fact my one is 3d and the example program is in 2d. Any other ideas? I would post some source code but there's quite a lot of code. Ruben On 08/06/2007, at 3:15 AM, Dan Piponi wrote:
On 6/6/07, Ruben Zilibowitz
wrote: If anyone knows how to get HOpenGL to draw coloured lines, I'd like...
See http://cvs.haskell.org/cgi-bin/cvsweb.cgi/~checkout~/fptools/ libraries/GLUT/examples/RedBook/Lines.hs
Note the color line which in this example uses white.
For debugging purposes play with clearColor because you can use that to test whether you're rendering the infamous black-on-black image or simply rendering nothing :-)
(Disclaimer: For some reason, today I can't test any of the redbook examples because Graphics.UI.GLUT is missing from my current installation. I'm guessing that if you have a non-broken installation they will mostly work fine. I certainly had no problem rendering lines based on these examples when I last had a non-broken installation.) -- Dan

On 6/7/07, Ruben Zilibowitz
Hi,
Thanks for the reply. The Lines.hs example program seems to work just right. Unfortunately I still can't get colored lines to work in my 3d program.
Maybe it has something to do with the fact my one is 3d and the example program is in 2d.
This is unlikely because of the way OpenGL does 3d vs. 2d. In OpenGL, 2d is just a special case of 3d where 0 is used for the z coordinate. More likely than 3d vs. 2d is that you're not drawing in the correct part of coordinate space, the view volume is incorrect or something like that. I would try to work Lines.hs into your current example or start borrowing code from it and putting them into your example until you either break Lines.hs in the same way or your example starts to work. Does Lines.hs still work when you switch it over to 3d? It should, but that could be a nice test to help you debug things. Did you remember to do all the double buffering operations? Did you setup the clear color first? One thing that you have to be careful about with OpenGL is that you correctly manage the state of the opengl machine. Haskell should have a purely functional scene graph built on top of HOpenGL -- it's something I would like to work on -- but no one seems to be doing it. For me at least, it's a matter of time and priority. Maybe in a few months to a year I'll get some time for it, but don't hold your breath :) Jason

Hi, Thanks. I eventually figured it out by doing pretty much what you suggested with Lines.hs. I discovered that the thing that made lines come out only in black was: lighting $= Enabled So disabling lighting before drawing lines and re-enabling it afterwards allows me to draw colored lines now. Thanks for the suggestions. Ruben On 08/06/2007, at 10:19 AM, Jason Dagit wrote:
On 6/7/07, Ruben Zilibowitz
wrote: Hi,
Thanks for the reply. The Lines.hs example program seems to work just right. Unfortunately I still can't get colored lines to work in my 3d program.
Maybe it has something to do with the fact my one is 3d and the example program is in 2d.
This is unlikely because of the way OpenGL does 3d vs. 2d. In OpenGL, 2d is just a special case of 3d where 0 is used for the z coordinate.
More likely than 3d vs. 2d is that you're not drawing in the correct part of coordinate space, the view volume is incorrect or something like that.
I would try to work Lines.hs into your current example or start borrowing code from it and putting them into your example until you either break Lines.hs in the same way or your example starts to work. Does Lines.hs still work when you switch it over to 3d? It should, but that could be a nice test to help you debug things.
Did you remember to do all the double buffering operations? Did you setup the clear color first? One thing that you have to be careful about with OpenGL is that you correctly manage the state of the opengl machine. Haskell should have a purely functional scene graph built on top of HOpenGL -- it's something I would like to work on -- but no one seems to be doing it. For me at least, it's a matter of time and priority. Maybe in a few months to a year I'll get some time for it, but don't hold your breath :)
Jason

On Friday 08 June 2007 01:19:02 Jason Dagit wrote:
Did you remember to do all the double buffering operations? Did you setup the clear color first? One thing that you have to be careful about with OpenGL is that you correctly manage the state of the opengl machine. Haskell should have a purely functional scene graph built on top of HOpenGL -- it's something I would like to work on -- but no one seems to be doing it.
I would very much like to do something similar, having implemented purely functional scene graphs on top of OpenGL in OCaml and DirectX in F#: http://www.ffconsultancy.com/products/smoke_vector_graphics/ http://www.ffconsultancy.com/products/fsharp_for_visualization/ Immutability is very useful in this area and, in particular, it makes a scene graph implementation in a functional language much more accessible than something like Windows Presentation Foundation. I am now working on a cross-platform GUI based upon our vector graphics work (Smoke). This can be similarly elegant by referencing purely functional scene graphs from nodes in the GUI description tree. I would be very interested to see how this is done in Haskell so, if anyone does attempt this, please keep me in the loop. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists/?e
participants (4)
-
Dan Piponi
-
Jason Dagit
-
Jon Harrop
-
Ruben Zilibowitz