Index: [thread] [date] [subject] [author]
  From: Marcus Sundberg <mackan@stacken.kth.se>
  To  : ggi-develop@eskimo.com
  Date: Sun, 18 Apr 1999 16:11:48 +0200

Re: GGI usage question

Steven Engelhardt wrote:
> 
> Hello,
> 
> I've been following GGI for quite a while now, and I would like to say
> that I think you guys are doing great work.  Keep it up!
> 
> Anyways, to try and learn GGI, I decided to rewrite acidwarp,
> especially to get it to work in non-paletted graphics modes.
> Currently I have:
> 
> ggi_visual_t vis;
> ggi_pixel palette[256];  /* This contains the current palette */
> ggi_color color[256];    /* The color information from the palette */
> int memory[x][y];        /* The current image which contains indexes
>                             into palette[] -- for simplicity, treat x and y
>                                                                                                                 as being 640 and 480 */
> 
> To draw the current image, I used the (highly suboptimal) method of:
>   int i, j;
> 
>   for (i = 0; i < graphics->x; i++) {
>     for (j = 0; j < graphics->y; j++) {
>             ggiPutPixel(graphics->vis, i, j,
>                   graphics->palette[graphics->memory[i][j]]);
>     }
>   }
> 
>         ggiFlush(graphics->vis);
> 
> While this method gives acceptable performance on my computer in
> asynchronous modes (such as windowed X), it is horribly slow in SVGAlib.

What mode are you using on SVGAlib? PutPixel will be slow on ModeX
modes. For other modes it should be as fast (or faster than) X.
But in any case PutPixel is not recommended for drawing an entire
frame.

> Could someone suggest a better method of doing this?

Have a look at my Doom/Heretic GGI code at 
http://www.stacken.kth.se/~mackan/ggi/files/i_ggi.c
It contains highly optimized code for blitting an 8bpp paletted
offscreen image to a LibGGI visual, using DirectBuffer when available,
and with optional 2x scaling.

//Marcus
-- 
-------------------------------+------------------------------------
        Marcus Sundberg        | http://www.stacken.kth.se/~mackan
 Royal Institute of Technology |       Phone: +46 707 295404
       Stockholm, Sweden       |   E-Mail: mackan@stacken.kth.se

Index: [thread] [date] [subject] [author]