Go to the previous, next section.

Parsing of command line options

AA-lib works at many different output devices so it can be initialized with many different options. Somebody might want to change the defaults. This can be done using command line options. This is done using function aa_parseoptions that uses argc/argv variables and parses options for AA-lib. The options for AA-lib are removed during parsing from argc/argv. aa_help variable contains help about options parsed by aa_parseoptions.

int aa_parseoptions(aa_hardwareparams *p, 
                    aa_renderparams *r, 
                    int *argc, char **argv);

First parameter is used for AA-lib initialization. (aa_defparams in previous example). It should contain information about screen size, attributes etc@dots{} You may also pass NULL to use defaults (aa_defparams variable). The second argument is set of parameters for rendering. Both of this variables will be explained later. Use NULL to force defaults (aa_defrenderparams). Fuction returns: 1 if OK or 0 on error.

#include <stdio.h>
#include <aalib.h>
aa_context *context;
void main(int argc, char **argv)
  if(!aa_parseoptions(NULL, NULL, &argc, argv) || argc!=1) {
    printf("Usage: %s [options]\n"
           "%s", argv[0], aa_help);
  context = aa_autoinit(&aa_defparams);
  if(context == NULL) {
    fprintf(stderr,"Cannot initialize AA-lib. Sorry\n");

Note that options are parsed from command line and also from AAOPTS enviroment variable. This makes possible to set parameters for all AA-Lib programs. If you pass NULL as argc/argv only the enviroment variable is parsed.

Variable aa_help contains help string similiar to this one:

  -driver        select driver
                  available drivers:linux slang X11
  -kbddriver     select keyboard driver
                  available drivers:slang X11
  -kbddriver     select mouse driver
                  available drivers:X11 gpm
Size options:
  -width         set width
  -height        set height
  -minwidth      set minimal width
  -minheight     set minimal height
  -maxwidth      set maximal width
  -maxheight     set maximal height
  -recwidth      set recomended width
  -recheight     set recomended height
  -dim           enable usage of dim (half bright) attribute
  -bold          enable usage of bold (double bright) attribute
  -reverse       enable usage of reverse attribute
  -normal        enable usage of normal attribute
  -boldfont      enable usage of boldfont attrubute
  -no<attr>      disable (i.e -nobold)

Font rendering options:
  -extended      use all 256 characters
  -eight         use eight bit ascii
  -font <font>   select font(This option have effect just on hardwares
                 where aalib is unable to determine current font
                  available fonts:vga8 vga9 mda14 vga14 X8x13 X8x16
                  X8x13bold vgagl8 line

Rendering options:
  -inverse       enable inverse rendering
  -noinverse     disable inverse rendering
  -bright <val>  set bright (0-255)
  -contrast <val>set contrast (0-255)
  -gamma <val>   set gamma correction value(0-1)

Ditherng options:
  -nodither      disable dithering
  -floyd_steinberg floyd steinberg dithering
  -error_distribution error distribution dithering
  -random <val>  set random dithering value(0-inf)

Go to the previous, next section.