DirectFB programming, directfb

Source: Internet
Author: User

DirectFB programming, directfb

I. Introduction

DirectFB is a lightweight graphics library that provides hardware graphics acceleration, input device processing, and abstraction. It integrates a translucent windows system and multi-layer display on the LinuxFramebuffer driver. It is a layer that uses software to encapsulate graphics algorithms that cannot be supported by the current hardware for hardware acceleration. DirectFB is designed for embedded systems. It achieves the highest hardware acceleration performance with minimal resource overhead.

 

Important Terms in DirectFB

1. Blitting
Blitting is referenced in the Process of copying image data. The simplest example is to Blitting one Surface to another when two surfaces have the same big, color depth and pixel format. In this process, the memory is copied but not processed (just like copying any other type of data ). Transmission of alpha channels, or transmission from one pixel format to another. Many graphics cards contain a hardware Blitting for transmission in multiple formats.

2. Surface
Surface is a reserved area of an image stored in memory in a specific pixel format. A Surface can be located in the video and/or system memory. You can draw a picture on one Surface or Blitting one Surface to another. (For details, see section 1.21)
In full screen mode, the visible area in the screen is displayed as "main Surface", so you can perform graphic operations directly in the visible area of the screen.
You can select double buffering for each Surface. The graphic operation will be executed in the secondary buffer and then become legal after Flip () is called. In many cases, we recommend that you use dual Buffering in the primary Surface to prevent flickering.

3. SubSurface
SubSurface uses the same interface as regular Surface. It represents a part of the parent Surface and does not allocate any system or video storage space for itself.

4. Layer
The graphic hardware can have one or more display layers. A standard PC video card has only one layer, but, just like a set-top box, it may support two or more layers. Different layers occupy different regions in the video memory. They are usually combined by alpha mixing, which is automatically completed by the display hardware. If the underlying content changes, it will not be repainted, And the content on the previous layer will remain unchanged. Today, many PC graphics cards also support additional layers (Video layers) that can be scaled from YUV to RGB ). This layer cannot be mixed and set to completely opaque. The variosDirectFB graphic driver supports the video layer.

5. Window/Windowstack
Generally, the content of a layer surface is controlled by the integrated form system, which means that the form of this layer is in a configurable background. Each form has its own surface, which is used by the form system to generate an image that forms overlapping forms.

 

Ii. Compilation and Installation

1. Download Resources

Download the following resources:

DirectFB:DirectFB-1.6.1.tar.gz,Fusion:   linux-fusion-8.10.2.tar.gz Example:  DirectFB-examples-1.6.0.tar.gz

DirectFB provides three download Methods: git, cvs, and compressed packages.

Address: http://directfb.org/
Or: git clone git: // git.directfb.org/git/directfb/core/DirectFB.git
     git clone git://git.directfb.org/git/directfb/core/linux-fusion.git

 

2. Compile and install Fusion

# tar zxf linux-fusion-8.10.2.tar.gz# cd linux-fusion-8.10.2# make# make install

Note:

1) Run 'make' and 'make install'. It builds and installs the module   for the running kernel version as reported by 'uname -r'.   If you want to build for another kernel, edit the Makefile.2) Either run 'modprobe fusion' manually or add "fusion" to "/etc/modules".3) Create the fusion device(s) if not using devfs or udev:        mkdir /dev/fusion        mknod /dev/fusion/0 c 250 0        ...if you need more than one session        mknod /dev/fusion/1 c 250 1        mknod /dev/fusion/2 c 250 2        ...and so on (currently limited to eight sessions)4) Add udev rules to /etc/udev/rules.d/40-fusion.rules if using udev:        KERNEL=="fusion[0-9]*", NAME="fusion/%n", GROUP="video", MODE="0660"        ...customize to suit your needs

 

3. Compile and install DirectFB

# tar zxf DirectFB-1.6.1.tar.gz# cd DirectFB-1.6.1# ./configure --enable-x11 --enable-multi --enable-debug --enable-trace# make# make install

 

Note: To enable pkg-config to find DirectFB, you need to add the search path:/usr/local/lib/. There are two methods:

 

Method 1:

First Run: vi/etc/ld. so. conf. d/qt-i386.conf and add the following content

/usr/local/lib/

Then execute:

ldconfig

 

Method 2:

First, execute:

cd DirectFB-1.6.1find . -name "*.pc"

Copy the "*. pc" file to the/usr/lib/pkgconfig directory and run the following command:

 

4. Compile and install Example

# tar -zxvf DirectFB-examples-1.6.0.tar.gz# cd DirectFB-examples-1.6.0# ./configure --enable-debug# make# make install

 

Iii. Running example

# Depmod-a # modprobe fusion # Install the fusion kernel module # cd/usr/local/bin #./df_window

The following error is reported:

~~~~~~~~~~~~~~~~~~~~~~~~~~| DirectFB 1.6.1 |~~~~~~~~~~~~~~~~~~~~~~~~~~        (c) 2001-2012  The world wide DirectFB Open Source Community        (c) 2000-2004  Convergence (integrated media) GmbH      ----------------------------------------------------------------(*) DirectFB/Core: Multi Application Core. (2015-03-22 11:51) [ DEBUG ][ TRACE ](*) Fusion/SHM: Using MADV_REMOVE (2.6.32.0 >= 2.6.19.2)(*) Direct/Thread: Started 'Fusion Dispatch' (-1) [MESSAGING OTHER/OTHER 0/0] <10485760>...(*) Direct/Thread: Started 'Fusion Deferred' (-1) [MESSAGING OTHER/OTHER 0/0] <10485760>...(!) Direct/Util: Opening '/dev/fb0' failed!    --> The requested operation or an argument is (currently) not supported(-) [ 3047: -STACK- ]  #0  0x00e431c3 in direct_try_open () from /usr/local/lib/libdirect-1.6.so.0 [0xe19000]  #1  0x0044aa61 in dfb_fbdev_open () from /usr/local/lib/directfb-1.6-0/systems/libdirectfb_fbdev.so [0x447000]  #2  0x0044b2e7 in system_initialize () from /usr/local/lib/directfb-1.6-0/systems/libdirectfb_fbdev.so [0x447000]  #3  0x007a6178 in dfb_system_core_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #4  0x00737d5c in dfb_core_part_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #5  0x00734987 in dfb_core_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #6  0x006f41aa in DirectFB::ICore_Real::Initialize() () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #7  0x006f106e in CoreDFB_Initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #8  0x007351ea in dfb_core_arena_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #9  0x0072e303 in dfb_core_create () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #10 0x006efb00 in DirectFBCreate () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000](!) DirectFB/FBDev: Error opening framebuffer device!(-) [ 3047: -STACK- ]  #0  0x0044aa61 in dfb_fbdev_open () from /usr/local/lib/directfb-1.6-0/systems/libdirectfb_fbdev.so [0x447000]  #1  0x0044b2e7 in system_initialize () from /usr/local/lib/directfb-1.6-0/systems/libdirectfb_fbdev.so [0x447000]  #2  0x007a6178 in dfb_system_core_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #3  0x00737d5c in dfb_core_part_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #4  0x00734987 in dfb_core_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #5  0x006f41aa in DirectFB::ICore_Real::Initialize() () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #6  0x006f106e in CoreDFB_Initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #7  0x007351ea in dfb_core_arena_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #8  0x0072e303 in dfb_core_create () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #9  0x006efb00 in DirectFBCreate () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000](!) DirectFB/FBDev: Use 'fbdev' option or set FRAMEBUFFER environment variable.(-) [ 3047: -STACK- ]  #0  0x0044aa61 in dfb_fbdev_open () from /usr/local/lib/directfb-1.6-0/systems/libdirectfb_fbdev.so [0x447000]  #1  0x0044b2e7 in system_initialize () from /usr/local/lib/directfb-1.6-0/systems/libdirectfb_fbdev.so [0x447000]  #2  0x007a6178 in dfb_system_core_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #3  0x00737d5c in dfb_core_part_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #4  0x00734987 in dfb_core_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #5  0x006f41aa in DirectFB::ICore_Real::Initialize() () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #6  0x006f106e in CoreDFB_Initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #7  0x007351ea in dfb_core_arena_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #8  0x0072e303 in dfb_core_create () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #9  0x006efb00 in DirectFBCreate () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000](!) DirectFB/Core: Could not initialize 'system_core' core!    --> A general initialization error occured(-) [ 3047: -STACK- ]  #0  0x00737d5c in dfb_core_part_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #1  0x00734987 in dfb_core_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #2  0x006f41aa in DirectFB::ICore_Real::Initialize() () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #3  0x006f106e in CoreDFB_Initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #4  0x007351ea in dfb_core_arena_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #5  0x0072e303 in dfb_core_create () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]  #6  0x006efb00 in DirectFBCreate () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000]df_window.c <136>:    (#) DirectFBError [DirectFBCreate( &dfb )]: A general initialization error occured

Solution:

Run: vi/etc/grub. conf

Change kernel/vmlinuz-2.6.15-1.2054_FC5 ro root = LABEL =/rhgb quiet to: kernel/vmlinuz-2.6.15-1.2054_FC5 ro root = LABEL =/rhgb quiet vga = 788

Run again:

# ./df_window

The effect is as follows:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.