Ubuntu 上配置DirectFB环境(亲测可用)
来源:互联网 发布:mac杀毒软件哪个好用 编辑:程序博客网 时间:2024/05/17 03:50
$cd DirectFB-1.6.1
注意:这里的可以只用./configure,但是在后面运行例子的时候要使用X11才能看到运行结果,由于DirectFB默认是关闭X11的,所以在这一步./configure的时候要将x11开启,完整命令如下:
$./configure --enable-x11=yes
注:如果在$./configure --enable-x11=yes这步出现下面的提示:
PNG support is missing - many applications won't work correctly!
JPEG support is missing - many applications won't workcorrectly!
FreeType2 support is missing - many applications won't workcorrectly!
参考解决方法:
$apt-get install libpng12-dev
$apt-get install libjpeg62-dev
$apt-get install libfreetype6-dev
注:安装上述包后还需在再配置 $./configure --enable-x11=yes
$sudo make
$sudo make install
3.安装DirectFB-example-1.6.0 (注意版本问题,如果太早的版本可能会编译时出错,所以要注意DirectFB的版本和例子的版本不要差太远)
A:更新数据库
root@/home/dyf/DirectFB-1.6.1#updatedb
B:找到directfb.pc的路径,让其能找到对应的directfb
root@/home/dyf/DirectFB-1.6.1#locate directfb.pc
/home/dyf/DirectFB-1.6.1/directfb.pc
/home/dyf/DirectFB-1.6.1/directfb.pc.in
/root/DirectFB-1.6.1/directfb.pc.in
/usr/local/lib/pkgconfig/directfb.pc
C:设置环境
将上一步得到的pkgconfig库目录加入环境之中:
$export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
(这样只能在当前终端可以运行,关机后还得自已运行些命令,才能运行dfb程序,如 要永久性加入可这样:
可以$sudo vim /root/.profile中加入:PKG_CONFIG_PATH=/usr/local/lib/pkgconfig )
D:安装
$./configure
$ sudo make
$ sudo make install
E: 指定directfb的库目录
$ sudo vim /etc/ld.so.conf 在最后一行加入:/usr/local/lib,保存退出。
$ldconfig
F:运行测试样例
# cdDirectFB-examples-1.6.0/src
$sudodf_andi
在运行dfb程序的时候,出现如下的提示错误:
(!) DirectFB/FBDev: No supported modes found in /etc/fb.modes and current mode not supported!
(!) DirectFB/FBDev: Current mode's pixelformat: rgba 6/0, 6/0, 6/0, 0/0 (4bit)
(!) DirectFB/Core/layers: Failed to initialize layer 0!
--> A general initialization error occured
(!) DirectFB/Core: Could not initialize 'layer_core' core!
--> A general initialization error occured
(#) DirectFBError [DirectFBCreate() failed]: A general initialization error occured
原因是framebuffer没有开启导致的。
在Ubuntu 10.04当中开启framebuffer的方法如下:
1.获取硬件支持的framebuffer模式,同时设置引导参数
$ sudo hwinfo --framebuffer
Mode 0x0317: 1024x768 (+2048), 16 bits
我这里挑选了一个比较常见的mode,然后追加到kernel的引导参数当中去。
$ vim /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=0x0317"
2.在initrd当中添加对应模块的支持
$ vim /etc/modprobe.d/blacklist-framebuffer.conf
注释这一行
#blacklist vesafb
然后往initrd当中添加对应模块
$ vim /etc/initramfs-tools/modules
加入如下内容
fbcon
vesafb
vga16fb
3.最后更新grub2和initrd,重新引导即可
$ sudo update-grub2
$ sudo update-initramfs -u
配置X11工作环境:
在当前用户的主目录下(如以root身份登录的则是/root/)建立一个文件:.directfbrc,然后将如
下内容添加到该文件中:
最后,保存退出,这下再运行程序就可以看到程序正常运行了!
mode=1024x768
wm=default
depth=32
system=x11
注:
如果没有安装x11则需要安装
$ apt-get install xorg-dev
编译DFB程序的方法类似于:
gcc -I/usr/local/include -I/usr/local/include/directfb-I/usr/local/include/directfb-internal -L/usr/local/lib -ldirectfb -lpthread-ldl -lz test.c -o test
DirectFB的hello world
#include <stdio.h>#include <unistd.h>#include <string.h>#include <stdlib.h>#include <directfb.h> //这是最上层的接口,所有的函数入口均由它(IDirectFB)而来static IDirectFB *dfb = NULL; //主平面,也就是“屏幕”了。在交互层使用DFSCL_FULLSCREEN,它是主层平面。static IDirectFBSurface *primary = NULL; //这里存储主平面的高和宽,从而为其它的操作提供支持static int screen_width = 0;static int screen_height = 0; static IDirectFBFont * font = NULL;//用以检测错误的宏定义,用来检测大部分的函数的返回值是否正常。只适合用在小的测试程序#define DFBCHECK(x...) { DFBResult err = x; if (err != DFB_OK) { fprintf( stderr, "%s <%d>:nt", __FILE__, __LINE__ ); DirectFBErrorFatal( #x, err ); } } int main (int argc, char **argv){ //为了创建一个平面,需要定义一个平面描述子(surface description) DFBSurfaceDescription dsc; DFBFontDescription font_dsc; //初始化 DFBCHECK (DirectFBInit (&argc, &argv)); DFBCHECK (DirectFBCreate (&dfb)); DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN)); //设定dsc的一些属性,现在可以不用关心 dsc.flags = DSDESC_CAPS; dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING; //使用我们设定的dsc创建主平面(primary) DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary )); //得到主平面的宽与高 DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height)); //设置字体的高度是固定的 font_dsc.flags = DFDESC_HEIGHT; font_dsc.height = screen_height/16; //set Font 第二个参数是字体的路径,测试的话可以去下载一个放到指定目录下,然后修改参数二即可 dfb->CreateFont( dfb, "/home/jia/DirectFB-examples-1.6.0/data/decker.ttf", &font_dsc, &font ); primary->SetFont(primary, font); //通过画一个和主平面同等大小的矩形来清空主平面;默认颜色为黑色 primary->FillRectangle (primary, 1, 1, screen_width, screen_height); //为了能显示画出来的线,先设置一下线的颜色,线的位置在屏幕的中间 primary->SetColor (primary, 0x80, 0x80, 0xff, 0xff); primary->DrawLine (primary,0, screen_height / 2,screen_width - 1, screen_height / 2); //写hello 在屏幕上 primary->DrawString(primary, "hello world", -1,0,font_dsc.height*1, DSTF_LEFT); //去刷新屏幕(暂时这么理解) DFBCHECK (primary->Flip (primary, NULL, 0)); //等待5秒后,程序自动退出 sleep (5); primary->Release( primary ); dfb->Release( dfb ); return 0;}
- Ubuntu 上配置DirectFB环境(亲测可用)
- DirectFB 之 环境配置
- Ubuntu 建立DirectFB 模拟环境
- ubuntu搭建LAMP环境,亲测可用
- ubuntu-ngnix安装配置[亲测可用]
- ubuntu上配置android环境
- directFb配置
- Ubuntu上C/C++环境配置
- 在Ubuntu server上配置lamp环境
- 在Ubuntu上配置LAMP环境
- JDK在ubuntu上的环境配置
- linux(ubuntu)上配置java环境
- Ubuntu上安装JDK并配置环境
- 测试phoneme advance(DirectFB)运行环境
- 测试phoneme advance(DirectFB)运行环境
- 测试phoneme advance(DirectFB)运行环境
- 测试phoneme advance(DirectFB)运行环境
- Ubuntu-jdk环境配置 亲测可以
- JSP 9 大内置对象详解
- POJ3974-Manacher算法--O(n)回文子串算法
- 手动删除Oracle
- (VS2012)C++行输入函数的使用(scanf_s,cin.getline,cin.get)
- Java 类修饰符、类成员修饰符
- Ubuntu 上配置DirectFB环境(亲测可用)
- POJ 1185 炮兵阵地(状态压缩DP)
- ecshop优化13-安全设置
- C++ 虚函数表解析
- 短训学习录(五)——天晴了
- vs2010中添加lua
- DB2常用命令
- 两题类似的数位DP
- Quartz 2D编程指南(3) - 路径(Paths)【下】