Re: GDK vs. ImLib vs. Gdk/ImLib




Square Avenue <dfinton@d.umn.edu> writes:

> Thanks to those who've replied to my earlier message; they were a great
> help.
> 
> I've got two questions now:  One is that I'm trying to create a fractal
> widget inherited from the drawing_area widget, but someone mentioned to me
> about the pitfalls of color allocation.  Is there something more robust
> than the drawing_area widget (like something from ImLib) that will easily
> let me say "Okay I want to put color ###### here at this point"?  I looked
> at ImLib's documentation a little bit and my impression is that 1)
> everything is 24 bit and 2) you don't have to worry about color allocation
> because ImLib takes care of that for you.  Would that be a good solution
> for true-color fractal rendering?  And would a GTK/ImLib mix in my code be
> detrimental?

Imlib might be one solution. I think it has mostly been used with
static images - but it may work well for dynamic images as well.
Another option is the GtkPreview widget - which is a bit higher
level. It is what GIMP plugins use for that kind of task. (Including
my own IfsCompose)

> My second question has to deal with threads.  Fractals are tricky to
> implement in a window manager environment because you have to set aside
> some time for the widgets to draw them selves as the image is rendering
> (which can take anywhere from a few seconds to several months (years if
> you're a real fractal enthusiast :) ).  This led me to threads, which is
> another thing that is tricky to implement in a window manager environment.
> Damned if you do, damned if you don't.  Has anybody had any success
> combining operations that take a long time in a GTK program with GTK
> itself?

There are quite a few different ways of attacking the problem.

- If the rendering can easily be split into chunks. (If you want
  to render for several years, it better be anyways, so you
  can checkpoint the rendering :-) then you can put your
  rendering in an idle callback. This is what IfsCompose does.

- You can periodically process the event loop while rendering
  your fractal. The idiom for this is:

   while (gtk_events_pending())
     gtk_main_iteration();

  (This has problems with 0.99.3, which have since been fixed)

- You can use threads. Either you can simply confine all interaction
  with GTK to one thread, or you can do more careful locking.
  If the search engine for the list archives is working again,
  you should be able to find a description for a nice approach
  to locking by searching on Rob Browning's name and, say, 
  "threads".

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]