Complete.Org: Mailing Lists: Archives: freeciv-dev: March 1999:
Re: [Freeciv-Dev] Patch: Displaying the map as a grid
Home

Re: [Freeciv-Dev] Patch: Displaying the map as a grid

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: xyzzy@xxxxxxxxxxxxxxxx (Trent Piepho)
Cc: rizos@xxxxxxxxxxx, freeciv-dev@xxxxxxxxxxx
Subject: Re: [Freeciv-Dev] Patch: Displaying the map as a grid
From: Rizos Sakellariou <rizos@xxxxxxxxxxx>
Date: Wed, 10 Mar 1999 10:31:38 -0600 (CST)

> 
> On Tue, 9 Mar 1999, Rizos Sakellariou wrote:
> >    for(y=tile_y; y<tile_y+height; y++)
> > -    for(x=tile_x; x<tile_x+width; x++)
> > +    for(x=tile_x; x<tile_x+width; x++) {
> >        pixmap_put_tile(map_canvas_store, x, y, 
> >                       (map_view_x0+x)%map.xsize, map_view_y0+y, 0);
> > +      if (map_draw_grid) {
> > +         XSetForeground(display, fill_bg_gc, 
> > colors_standard[COLOR_STD_BLACK]);
> > +         XDrawRectangle(display, map_canvas_store, fill_bg_gc, 
> > +                        x*NORMAL_TILE_WIDTH, y*NORMAL_TILE_HEIGHT, 
> > +                        NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
> > +      }
> > +  }
> 
> This is a terribly inefficient way of drawing the grid.  Changing GC
> attributes is an expensive X operation.  You should just set the GC once
> before drawing, and then not change it.  It would also be more efficient to
> just draw x + y lines instead of x*y rectangles (= 4*x*y lines).
> 

Sure - this could be improved. However, i feel it would be better that someone
with access to Xaw documentation adds the last bit to it. Isolating the 
draw_grid
part from the rest of the loop may be better to be safe in doing XSetForeground
only once. Then, black lines can be drawn, and then an extra loop can draw 
rectangles (say red) around unknown tiles to allow a grid for the full map.
Could someone take over?

--rizos


[Prev in Thread] Current Thread [Next in Thread]