使用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); /* 0xE