红联Linux门户
Linux帮助

Linux程序设计入门 - SVGALIB

发布时间:2006-07-24 18:12:56来源:红联作者:bear10214
Linux程序设计入门 - SVGALIB

SvgaLib是Linux Console下的VGA驱动函数库。虽然它的品质还是有点低,支援

的萤幕卡种类不算太多,但是有许多的游戏及程序都是用它来做开发,可以算

是非官方的标准了。如果您准备要在Console下撰写图形功能的程序,目前来说

SVGALIB是您唯一的选择。目前使用SVGALIB的程序有许多,中文终端机使用

SVGALIB的就有a4c.tty/yact/bcs16。


这里我只讲一些简单的使用方法,如启动vga及mouse的使用。要有效地、高阶

的运用,技巧复杂很多,例如a4c.tty就另外往上架一层Star Window

Manager,来管理一个小型视窗系统。



vga




vgamouse






int vga_setmode(int mode);

int vga_hasmode(int mode);

int vga_setpalette(int index, int red, int green, int blue);

int vga_getpalette(int index, int *red, int *green, int *blue);

int vga_setcolor(int color);

int vga_drawpixel(int x, int y);

int vga_drawline(int x1, int y1, int x2, int y2);

int vga_getpixel(int x, int y);

vga_modeinfo *vga_getmodeinfo(int mode);


unsigned char *graph_mem;

unsigned char *vga_getgraphmem(void);


void vga_setpage(int p);

void vga_setreadpage(int p);

void vga_setreadpage(int p);

void vga_setwritepage(int p);

void vga_setdisplaystart(int a);

void vga_waitretrace(void);

int vga_init(void);

int vga_setrgbcolor(int r, int g, int b);








#define TEXT 0 /* Compatible with VGAlib v1.2 */

#define G320x200x16 1

#define G640x200x16 2

#define G640x350x16 3

#define G640x480x16 4

#define G320x200x256 5

#define G320x240x256 6

#define G320x400x256 7

#define G360x480x256 8

#define G640x480x2 9


#define G640x480x256 10

#define G800x600x256 11

#define G1024x768x256 12


#define G1280x1024x256 13 /* Additional modes. */


#define G320x200x32K 14

#define G320x200x64K 15

#define G320x200x16M 16

#define G640x480x32K 17

#define G640x480x64K 18

#define G640x480x16M 19

#define G800x600x32K 20

#define G800x600x64K 21

#define G800x600x16M 22

#define G1024x768x32K 23

#define G1024x768x64K 24

#define G1024x768x16M 25

#define G1280x1024x32K 26

#define G1280x1024x64K 27

#define G1280x1024x16M 28


#define G800x600x16 29

#define G1024x768x16 30

#define G1280x1024x16 31


#define G720x348x2 32 /* Hercules emulation mode */


#define G320x200x16M32 33 /* 32-bit per pixel modes. */

#define G640x480x16M32 34

#define G800x600x16M32 35

#define G1024x768x16M32 36

#define G1280x1024x16M32 37


/* additional resolutions */

#define G1152x864x16 38

#define G1152x864x256 39

#define G1152x864x32K 40

#define G1152x864x64K 41

#define G1152x864x16M 42

#define G1152x864x16M32 43


#define G1600x1200x16 44

#define G1600x1200x256 45

#define G1600x1200x32K 46

#define G1600x1200x64K 47

#define G1600x1200x16M 48

#define G1600x1200x16M32 49


typedef struct {

int width;

int height;

int bytesperpixel;

int colors;

int linewidth; /* scanline width in bytes */

int maxlogicalwidth; /* maximum logical scanline width */

int startaddressrange; /* changeable bits set */

int maxpixels; /* video memory / bytesperpixel */

int haveblit; /* mask of blit functions available */

int flags; /* other flags */



/* Extended fields: */



int chiptype; /* Chiptype detected */

int memory; /* videomemory in KB */

int linewidth_unit; /* Use only a multiple of this as

parameter for set_displaystart */

char *linear_aperture; /* points to mmap secondary mem aperture

of car

int aperture_size; /* size of aperture in KB if

size>=videomemory.

void (*set_aperture_page) (int page);

/* if aperture_size
void *extensions; /* points to copy of eeprom for mach32 */

/* depends from actual driver/chiptype.. etc. */

} vga_modeinfo;
文章评论

共有 0 条评论