使用svgalib 下載地址:https://launchpad.net/ubuntu/+source/svgalib/1:1.4.3-30svgalib_1.4.3.orig.tar.gzsvgalib_1.4.3-30.debian.tar.gzsvgalib_1.4.3-30.dsc 打補丁t... ...
使用svgalib
下載地址:
https://launchpad.net/ubuntu/+source/svgalib/1:1.4.3-30
svgalib_1.4.3.orig.tar.gz
svgalib_1.4.3-30.debian.tar.gz
svgalib_1.4.3-30.dsc
打補丁
tar xzf svgalib_1.4.3.orig.tar.gz
tar xzf svgalib_1.4.3-30.debian.tar.gz
cd svgalib-1.4.3.orig/
for file in ../debian/patches/*.patch; do patch -p1 < $file; done
執行for迴圈對於上層目錄里的debian/patches/*.patch所有文件 執行 patch -p1 < $file命令
編譯安裝:
sudo make install // 編譯出錯,需要安裝libx86
再 sudo make install
下載地址
http://packages.ubuntu.com/lucid/libx86-1
tar xzf libx86_1.1+ds1.orig.tar.gz
gunzip libx86_1.1+ds1-6.diff.gz
cd libx86-1.1/
patch -p1 < ../libx86_1.1+ds1-6.diff
make // 出錯,修改lrmi.c,添加巨集, 參考561491.patch
make
sudo make install
ctrl+alt+shift+f1
#include <stdlib.h> #include <vga.h> #include <vgagl.h> /* gcc -o svgatest svgatest.c -lvga -lvgagl */ int main(void) { int x, y; vga_init(); vga_setmode(G320x200x256); vga_setcolor(4); for (x = 0; x < 320; x++) for (y = 0; y < 200; y++) vga_drawpixel(x, y); sleep(5); vga_setmode(TEXT); return EXIT_SUCCESS; }
sudo ./svgatest
如果缺少動態鏈接庫
http://www.cnblogs.com/CZM-/p/5342427.html
使用調色板
#include <vgagl.h> gl_setpalettecolor(4, 0xE7>>2, 0xDB>>2, 0xB5>>2); /* 0xE7DBB5 */ /* ·º»ÆµÄÖ½ */
gcc -o svgatest svgatest.c -lvga -lvgagl
開始寫pc電子書顯示程式
修改Makefile
不用交叉編譯
CROSSCOMPILE :=
添加庫
all: $(OBJS)
$(CC) $(LDFLAGS) -o show_file $^ -lvga -lvgagl
指定頭文件目錄
CFLAGS += -I$(PWD)/include -I /usr/include/freetype2/
display/crt.o \
#include <config.h> #include <disp_manager.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <linux/fb.h> #include <string.h> #include <stdlib.h> #include <vga.h> #include <vgagl.h> static int CRTDeviceInit(void); static int CRTShowPixel(int iX, int iY, unsigned int dwColor); static int CRTCleanScreen(unsigned int dwBackColor); static int CRTDeviceExit(void); static T_DispOpr g_tCRTOpr = { /* ÏÔʾÆÁĬÈÏÃû×Ö "crt*/ .name = "crt", .DeviceInit = CRTDeviceInit, .DeviceExit = CRTDeviceExit, .ShowPixel = CRTShowPixel, .CleanScreen = CRTCleanScreen, }; static int CRTDeviceInit(void) { vga_init(); vga_setmode(G320x200x256); g_tCRTOpr.iXres = 320; g_tCRTOpr.iYres = 200; g_tCRTOpr.iBpp = 8; return 0; } static int CRTDeviceExit(void) { vga_setmode(TEXT); return EXIT_SUCCESS; } static int CRTShowPixel(int iX, int iY, unsigned int dwColor) { int iRed,iGreen,iBlue; iRed = (dwColor >> 16) & (0xff); iGreen = (dwColor >> 8) & (0xff); iBlue = (dwColor >> 0) & (0xff); gl_setpalettecolor(5, iRed>>2, iGreen>>2, iBlue>>2); /* 0xE7DBB5 */ /* ·º»ÆµÄÖ½ */ vga_setcolor(5); vga_drawpixel(iX, iY); return 0; } static int CRTCleanScreen(unsigned int dwBackColor) { int iX; int iY; int iRed,iGreen,iBlue; iRed = (dwBackColor >> 16) & (0xff); iGreen = (dwBackColor >> 8) & (0xff); iBlue = (dwBackColor >> 0) & (0xff); gl_setpalettecolor(4, iRed>>2, iGreen>>2, iBlue>>2); /* 0xE7DBB5 */ /* ·º»ÆµÄÖ½ */ vga_setcolor(4); for (iX = 0; iX < 320; iX++) for (iY = 0; iY < 200; iY++) vga_drawpixel(iX, iY); return 0; } int CRTInit(void) { return RegisterDispOpr(&g_tCRTOpr); }
./show_file -s 16 -d crt -h HZK16 -f ./MSYH.TTF daomubiji.txt