1

我似乎无法启动 DirectFB,以便它可以毫无问题地启动。当我尝试在 DFBCHECK (DirectFBCreate (&dfb)) 之后访问函数时,我得到“无效参数”;我尝试从教程中运行简单的示例。代码如下:

 #include <stdio.h>
#include <unistd.h>
#include <directfb.h>

static IDirectFB *dfb = NULL;
static IDirectFBSurface *primary = NULL;
static int screen_width  = 0;
static int screen_height = 0;

#define DFBCHECK(x...)                                         \
  {                                                            \
    DFBResult err = x;                                         \
                                                               \
    if (err != DFB_OK)                                         \
      {                                                        \
        fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
        DirectFBErrorFatal( #x, err );                         \
      }                                                        \
  }

int main (int argc, char **argv)
{
   int argx = 2;
   char *argData[] = {"self","--dfb:system=fbdev,disable-module=keyboard,disable-module=joystick,no-hardware",0};
   char **argPointer = argData;

   DFBSurfaceDescription dsc;
   DFBCHECK (DirectFBInit (&argx,&argPointer));
   DFBCHECK (DirectFBCreate (&dfb));
   DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
   dsc.flags = DSDESC_CAPS;
   dsc.caps  = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
   DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
   DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height));
   DFBCHECK (primary->FillRectangle (primary, 0, 0, screen_width, screen_height));
   DFBCHECK (primary->SetColor (primary, 0x80, 0x80, 0xff, 0xff));
   DFBCHECK (primary->DrawLine (primary,
                                  0, screen_height / 2,
                   screen_width - 1, screen_height / 2));

   DFBCHECK (primary->Flip (primary, NULL, 0));
   sleep (5);
   primary->Release( primary );
   dfb->Release( dfb );
   return 23;
}

如您所见,我以硬编码的 char* 提供参数。这是因为我计划从不是从命令行启动的代码中使用 DirectFB。代码使用命令“gcc -I/usr/local/include/directfb dfbtest.c -o dfbtest -ldirectfb”编译

这会产生一个错误:

   ~~~~~~~~~~~~~~~~~~~~~~~~~~| DirectFB 1.2.10 |~~~~~~~~~~~~~~~~~~~~~~~~~~
    (c) 2001-2008  The world wide DirectFB Open Source Community
    (c) 2000-2004  Convergence (integrated media) GmbH
  ----------------------------------------------------------------

(*) DirectFB/Core:单一应用核心。(2012-05-21 06:43)

(*) 直接/线程:已启动“VT 切换器”(3285) [CRITICAL OTHER/OTHER 0/0] <8388608>...

(*) 直接/模块:抑制模块“操纵杆”

(*) 直接/模块:抑制模块“键盘”

(*) 直接/线程:已启动“Linux 输入”(-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/输入:盖子开关 (1) 0.1 (directfb.org)

(*) 直接/线程:已启动“Linux 输入”(-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/输入:电源按钮 (2) 0.1 (directfb.org)

(*) 直接/线程:已启动“Linux 输入”(-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/输入:睡眠按钮 (3) 0.1 (directfb.org)

(*) 直接/线程:已启动“Linux 输入”(-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/输入:电源按钮 (4) 0.1 (directfb.org)

(*) 直接/线程:已启动“Linux 输入”(-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/输入:Apple Computer Apple Internal K (5) 0.1 (directfb.org)

(*) 直接/线程:已启动“Linux 输入”(-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/输入:Apple Computer Apple Internal K (6) 0.1 (directfb.org)

(*) 直接/线程:已启动“Linux 输入”(-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/输入:罗技 USB-PS/2 光电鼠标 (7) 0.1 (directfb.org)

(*) 直接/线程:已启动“Linux 输入”(-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/输入:appletouch (8) 0.1 (directfb.org)

(*) 直接/线程:已启动“Linux 输入”(-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/输入:applesmc (9) 0.1 (directfb.org)

(*) 直接/线程:已启动“Linux 输入”(-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/输入:HDA Intel SPDIF In (10) 0.1 (directfb.org)

(*) 直接/线程:已启动“Linux 输入”(-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/输入:HDA Intel Line (11) 0.1 (directfb.org)

(*) 直接/线程:已启动“Linux 输入”(-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/输入:HDA 英特尔耳机 (12) 0.1 (directfb.org)

(*) 直接/线程:开始“PS/2 输入”(-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/输入:IMPS/2 鼠标 (1) 1.0 (directfb.org)

(*) 直接/线程:开始“PS/2 输入”(-1) [INPUT OTHER/OTHER 0/0] <8388608>...

(*) DirectFB/输入:IMPS/2 鼠标 (2) 1.0 (directfb.org)

(*) DirectFB/Genefx:检测到并启用 MMX

(*) DirectFB/图形:MMX Software Rasterizer 0.6 (directfb.org)

(*) DirectFB/Core/WM:默认 0.3 (directfb.org)

(*) FBDev/Surface:在偏移量 0 和间距 5888 处分配了 640x480 32 位 LUT8 缓冲区(索引 0)。

(*) FBDev/模式:设置 640x480 LUT8

(*) FBDev/Mode:在 8 位 (LUT8) 时切换到 640x480(虚拟 640x480),间距 5888 dfbtest.c <30>:

(#) DirectFBError [dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN)]: Invalid argument!

(!!!) * 警告 [应用程序在 DirectFB 未初始化的情况下退出!] * [../../../src/core/core.c:859 in dfb_core_deinit_check()]

任何如何进一步调试的想法将不胜感激。我在 Ubuntu 12 上运行它。带有 Radeon 芯片的旧 MacBook Pro 的东西。如果我在控制台或 X11 下运行它,结果是一样的。屏幕闪烁,以便帧缓冲区启动,但它在此 setcooperativelevel 调用时崩溃。

4

1 回答 1

0

所以这是版本兼容性问题。标头是从更高版本的 DirectFB 中包含的,而不是链接的库。链接到 DirectFB 库的正确版本消除了该问题。

于 2013-09-12T16:01:55.497 回答