On Tue, Jul 15, 2008 at 12:18:50PM +0200, Robert Lindebaum wrote:
> 2) X11 updates
> a) Update for speed. For true colour displays do not call XAllocColor to
> get the pixel value, rather just calculate it using the masks in the Visual
> structure. Have tested on 15.16 and 24 bit displays on Linux. Would like
> feedback on any problems on other platforms other than linux. For non true
> colour displays, use the same technique as before.
> Also for draw pixel operations I have made the flush command only update the
> individual pixel, rather than the whole screen. This can easily be extended
> to speed up the other commands, but have not done so yet.
> All in all for autoflushing draw_pixel operations I get a speed improvement of
> to 100x (depending on computer) on colour intensive pixel operations.
> With Auto_flushing off the speed improvement on draw_pixel is 20 to 30 times.
> b) added a new command g2_keypress command to all the appropriate files. I
> have only created the X11 driver, not the windows driver for this command.
Those are great news. I am using g2 for teaching C to beginners, and the
low speed was always a problem. Using the default (auto_flush on) was not
an option, and using g2_set_auto_flush(g,0); with some g2_flush(g); at
well chosen locations was always difficult to explain. (Hey, my goal is
that the students understand what a loop is, basically. Graphics is for
making nice and motivating programs.)
So, if the default mode (auto_flush on) can be made fast enough, that's
great. An idea that I had, which I didn't take time to write down, would
be to have a new mode which would not flush graphics after each
operation, but which would automatically flush it every X milliseconds,
with X tipically between 20 and 100. I think that would make things
significatively faster than auto_flush on but as easy to use as
auto_flush off, and that it would therefore be an acceptable default
mode. Does this idea has any merit ?
Another wish from me would ge a g2_printf() function... Explaining
sprintf()+g2_string to my students, with all the difficulties associated
with having a buffer large enough, etc., is hard.