当前位置:Linux教程 - Linux - Linux程式设计入门 - SVGALIB

Linux程式设计入门 - SVGALIB

  SvgaLib是LinuxConsole下的VGA驱动函数库。虽然它的品质还是有点低,支援的萤幕卡种类不算太多,但是有许多的游戏及程式都是用它来做开发,可以算是非官方的标准了。如果您准备要在Console下撰写图形功能的程式,目前来说
SVGALIB是您唯一的选择。目前使用SVGALIB的程式有许多,中文终端机使用SVGALIB的就有a4c.tty/yact/bcs16。

  这里我只讲一些简单的使用方法,如启动vga及mouse的使用。要有效地、高阶的运用,技巧复杂很多,例如a4c.tty就另外往上架一层StarWindowManager,来管理一个小型视窗系统。

vga
vgamouse
intvga_setmode(intmode);
intvga_hasmode(intmode);
intvga_setpalette(intindex,intred,intgreen,intblue);
intvga_getpalette(intindex,int*red,int*green,int*blue);
intvga_setcolor(intcolor);
intvga_drawpixel(intx,inty);
intvga_drawline(intx1,inty1,intx2,inty2);
intvga_getpixel(intx,inty);
vga_modeinfo*vga_getmodeinfo(intmode);
unsignedchar*graph_mem;
unsignedchar*vga_getgraphmem(void);
voidvga_setpage(intp);
voidvga_setreadpage(intp);
voidvga_setreadpage(intp);
voidvga_setwritepage(intp);
voidvga_setdisplaystart(inta);
voidvga_waitretrace(void);
intvga_init(void);
intvga_setrgbcolor(intr,intg,intb);



#defineTEXT0/*CompatiblewithVGAlibv1.2*/
#defineG320x200x161
#defineG640x200x162
#defineG640x350x163
#defineG640x480x164
#defineG320x200x2565
#defineG320x240x2566
#defineG320x400x2567
#defineG360x480x2568
#defineG640x480x29
#defineG640x480x25610
#defineG800x600x25611
#defineG1024x768x25612


#defineG1280x1024x25613/*Additionalmodes.*/
#defineG320x200x32K14
#defineG320x200x64K15
#defineG320x200x16M16
#defineG640x480x32K17
#defineG640x480x64K18
#defineG640x480x16M19
#defineG800x600x32K20
#defineG800x600x64K21
#defineG800x600x16M22
#defineG1024x768x32K23
#defineG1024x768x64K24
#defineG1024x768x16M25
#defineG1280x1024x32K26
#defineG1280x1024x64K27
#defineG1280x1024x16M28
#defineG800x600x1629
#defineG1024x768x1630
#defineG1280x1024x1631
#defineG720x348x232/*Herculesemulationmode*/
#defineG320x200x16M3233/*32-bitperpixelmodes.*/
#defineG640x480x16M3234
#defineG800x600x16M3235
#defineG1024x768x16M3236
#defineG1280x1024x16M3237


/*additionalresolutions*/

#defineG1152x864x1638
#defineG1152x864x25639
#defineG1152x864x32K40
#defineG1152x864x64K41
#defineG1152x864x16M42
#defineG1152x864x16M3243
#defineG1600x1200x1644
#defineG1600x1200x25645
#defineG1600x1200x32K46
#defineG1600x1200x64K47
#defineG1600x1200x16M48
#defineG1600x1200x16M3249


typedefstruct{
intwidth;
intheight;

intbytesperpixel;
intcolors;
intlinewidth;/*scanlinewidthinbytes*/
intmaxlogicalwidth;/*maximumlogicalscanlinewidth*/
intstartaddressrange;/*changeablebitsset*/
intmaxpixels;/*videomemory/bytesperpixel*/
inthaveblit;/*maskofblitfunctionsavailable*/
intflags;/*otherflags*/



/*Extendedfields:*/



intchiptype;/*Chiptypedetected*/
intmemory;/*videomemoryinKB*/
intlinewidth_unit;/*Useonlyamultipleofthisas
parameterforset_displaystart*/
char*linear_aperture;/*pointstommapsecondarymemaperture
ofcar
intaperture_size;/*sizeofapertureinKBif
size>=videomemory.
void(*set_aperture_page)(intpage);

/*ifaperture_size<videomemoryselectamemorypage*/
void*extensions;/*pointstocopyofeepromformach32*/

/*dependsfromactualdriver/chiptype..etc.*/
}vga_modeinfo;