Recently I wrote a 3D graphics viewer using Gtk2hs and Cairo, and it works ok, aside from the fact that it got quite slow when it got to displaying about 1000 polygons. It works something like this: The three-dimensional coordinates of polygons are given, and the program sorts the polygons using a BSP Tree (following the Painter's Algorithm), then it projects the polygons onto the plane of vision and renders each polygon to the screen using Cairo. After some investigation, I realised that my bottleneck was the rendering of polygons, but I could not speed up the rendering using parallel programming since the rendering order is crucial in the Painter's Algorithm. Even if I switched to an algorithm based on Hidden Surface Removal so I could render all my "obscured" polygons at once, Gtk2hs "is single threaded and its functions cannot be called from other threads".
Then I heard about FieldTrip, which uses the GPU to process rendering efficiently. I decided to switch to using FieldTrip in conjunction with Gtk2hs to write applications, but it doesn't seem that easy because (i) there doesn't seem to be any version of GHC where Gtk2hs, Glade and Fieldtrip can work together on Windows and (ii) unlike Cairo, there is no Gtk2hs support for Fieldtrip in the sense that there are no Gtk2hs functions that render FieldTrip output to a Gtk2hs widget, like the DrawWindow. The latter would mean that Gtk2hs can't interact easily with FieldTrip.
I really like Gtk2hs because it is very comprehensive and its interface can be designed using Glade. Does anyone know if there is a project linking Gtk2hs and FieldTrip? Otherwise, does anyone know if user interfaces can be written using Reactive (since it's linked to FieldTrip) with the usual functionality (e.g. menus, buttons, FieldTrip display reacting to mouseclicks etc)? If that is possible then I might have to switch to Reactive, but I'd miss Glade a lot :)
regards,
Herng Yi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100808/bce48fe2/attachment-0001.html