Linux程式設計入門 - SVGALIB(轉)

BSDLite發表於2007-08-12
Linux程式設計入門 - SVGALIB(轉)[@more@]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;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10617542/viewspace-948844/,如需轉載,請註明出處,否則將追究法律責任。

相關文章