From: Bernie Pope <bjpop@cs...> - 2004-10-11 09:41:43
Hi wxHaskell people,
I have a little ray-tracer in Haskell. An image is
produced as a stream of pixel intensities.
I want to use wxHaskell to write a display facilty that
will render each pixel as it is generated by the tracer
(so we can see the image being generated pixel by pixel).
My current thoughts are to create a panel and have it
render a bitmap on paint events. The bitmap is implemented
via "varCreate" and so on. The idea is to update the bitmap
and periodically repaint the panel.
Before I commit to this approach I thought it would be wise
to ask for advice in case there is a more idiomatic way
to do it.
From: Bernie Pope <bjpop@cs...> - 2004-10-19 00:31:24
On Mon, Oct 11, 2004 at 07:41:21PM +1000, Bernie Pope wrote:
> Hi wxHaskell people,
> I have a little ray-tracer in Haskell. An image is
> produced as a stream of pixel intensities.
> I want to use wxHaskell to write a display facilty that
> will render each pixel as it is generated by the tracer
> (so we can see the image being generated pixel by pixel).
I've done some more tinkering and here's what I've come up with.
When the user clicks the "render" button a new frame is created
containing a panel. A bitmap is drawn onto the panel on paint raw
At each idle event for the panel, the program requests a chunk of
pixels from the raytracer. It then writes those pixels to their
respective positions in the bitmap pixelbuffer. Then it sends
a repaint event to the panel. When the supply of pixels runs out
(the emtpy list) the panel stops responding to idle events.
You can set the chunk size. Smaller sizes tend to slow the
repaint process down.
The nice thing is we can have multiple simultaneous renderings
going on in different frames.
I'll post a link to the code when I'm done polishing it.
Get latest updates about Open Source Projects, Conferences and News.