.TH libvga "" "" "Library"
.PC "Library of VGA graphics routines"
.PP
.II "VGA graphics"
.II "graphics^VGA"
.II "library^VGA graphics"
Archive
.B libvga.a
holds a set of routines with which you can perform graphics operations
on a VGA terminal under \*(CO.
It consists of the following routines:
.sp \n(pDu
.nf
.ie t .ta 1.5i
.el   .ta 2.5i
.tc . 0.1i
\fBvga_clear()\fR	Clear the graphics screen
\fBvga_drawline()\fR	Draw a line in the current color
\fBvga_drawpixel()\fR	Draw a pixel in the current color
\fBvga_drawscanline()\fR	Draw a single horizontal line of pixels
\fBvga_filled_circle()\fR	Draw a filled circle
\fBvga_filled_rectangle()\fR	Draw a filled rectangle
\fBvga_flip()\fR	Flip between graphics and text mode
\fBvga_getch()\fR	Wait for a character to be typed
\fBvga_getcolors()\fR	Get the number of colors in current mode
\fBvga_getpalette()\fR	Get a color from the current palette
\fBvga_getpalvec()\fR	Get multiple colors from the current palette
\fBvga_getxdim()\fR	Return X dimension of the VGA screen
\fBvga_getydim()\fR	Return Y dimension of the VGA screen
\fBvga_screenoff()\fR	Turn off screen refresh
\fBvga_screenon()\fR	Turn on screen refresh
\fBvga_setcolor()\fR	Set the color for calls to drawing functions
\fBvga_setflipchar()\fR	Set the character that flips between modes
\fBvga_setmode()\fR	Select graphics mode
\fBvga_setpalette()\fR	Set a color in the current palette
\fBvga_setpalvec()\fR	Set a range of colors in the current palette
.fi
.PP
These routines use the following header files:
.sp \n(pDu
.nf
.ie t .ta 1.5i
.el   .ta 2.5i
.tc . 0.1i
\fB80x25.h\fR	Contents of VGA registers 80\(mu25 mode
\fBemulib.h\fR	Emulate graphics functions
\fBvga.h\fR	Declare/define objects used in libvga
.fi
.SH Example
The following example demonstrates many of the functions in
.BR libvga .
It draws a stylized image on the screen in the different graphics modes that
.B libvga
supports.
It was written by Tommy Frandsen (frandsen@diku.dk).
.DM
#include "emulib.h"
#include <vga.h>
.DE
.DM
static char line[1024];
.DE
.DM
static void testmode(mode)
int mode;
{
	int xmax, ymax, colors, i, x, y;
.DE
.DM
	vga_setmode(mode);
	vga_screenoff();
.DE
.DM
	xmax = vga_getxdim()-1;
	ymax = vga_getydim()-1;
.DE
.DM
	vga_drawline(   0,    0, xmax,    0);
	vga_drawline(xmax,    0, xmax, ymax);
	vga_drawline(xmax, ymax,    0, ymax);
	vga_drawline(   0, ymax,    0,    0);
.DE
.DM   
	for (i = 0; i <= 15; i++) {
		vga_setcolor(i);
		vga_drawline(10+i*5, 10, 100+i*5, 90);
	}
.DE
.DM
	for (i = 0; i <= 15; i++) {
		vga_setcolor(i);
		vga_drawline(100+i*5, 10, 10+i*5, 90);
	}
.DE
.DM
	if (vga_getcolors() == 256) {
		for(i = 0; i < 64; i++)
			vga_setpalette(i+128, i, i, i);
		for(i = 0; i <= xmax; i++)
			line[i] = 128 + i%64;
	} else
		for(i = 0; i <= xmax; i++)
			line[i] = i%16;
.DE
.DM
	for (i = 100; i < 190; i++)
		vga_drawscanline(i, line);
.DE
.DM
	vga_screenon(); 
	printf("Test%d\n", mode);
	vga_getch();
}
.DE
.DM
main()
{
	testmode(G320x200x16);
	testmode(G640x200x16);
	testmode(G640x350x16);
	testmode(G640x480x16);
	testmode(G320x200x256);
	testmode(G320x240x256);
	testmode(G320x400x256);
	testmode(G360x480x256);
	vga_setmode(TEXT);
}
.DE
.SH "See Also"
.B
console,
kaleidoscope,
libraries
.R
.SH Notes
.II "Frandsen, Tommy"
.II "Pulley, Harry"
.II Linux
.II mgr
.B libvga
was written by Tommy Frandsen (frandsen@diku.dk)
for the Linux operating system.
It was ported to \*(CO by Harry C. Pulley, IV.
