DirectFB教程无效参数

时间:2013-09-12 07:34:31

标签: c linux framebuffer directfb

我似乎无法启动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 Switcher'(3285)[CRITICAL OTHER / OTHER 0/0]&lt; 8388608&gt; ...

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

(*)Direct / Modules:抑制模块'keyboard'

(*)直接/线程:启动'Linux输入'( - 1)[INPUT OTHER / OTHER 0/0]&lt; 8388608&gt; ...

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

(*)直接/线程:启动'Linux输入'( - 1)[INPUT OTHER / OTHER 0/0]&lt; 8388608&gt; ...

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

(*)直接/线程:启动'Linux输入'( - 1)[INPUT OTHER / OTHER 0/0]&lt; 8388608&gt; ...

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

(*)直接/线程:启动'Linux输入'( - 1)[INPUT OTHER / OTHER 0/0]&lt; 8388608&gt; ...

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

(*)直接/线程:启动'Linux输入'( - 1)[INPUT OTHER / OTHER 0/0]&lt; 8388608&gt; ...

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

(*)直接/线程:启动'Linux输入'( - 1)[INPUT OTHER / OTHER 0/0]&lt; 8388608&gt; ...

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

(*)直接/线程:启动'Linux输入'( - 1)[INPUT OTHER / OTHER 0/0]&lt; 8388608&gt; ...

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

(*)直接/线程:启动'Linux输入'( - 1)[INPUT OTHER / OTHER 0/0]&lt; 8388608&gt; ...

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

(*)直接/线程:启动'Linux输入'( - 1)[INPUT OTHER / OTHER 0/0]&lt; 8388608&gt; ...

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

(*)直接/线程:启动'Linux输入'( - 1)[INPUT OTHER / OTHER 0/0]&lt; 8388608&gt; ...

(*)DirectFB /输入:HDA英特尔SPDIF输入(10)0.1(directfb.org)

(*)直接/线程:启动'Linux输入'( - 1)[INPUT OTHER / OTHER 0/0]&lt; 8388608&gt; ...

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

(*)直接/线程:启动'Linux输入'( - 1)[INPUT OTHER / OTHER 0/0]&lt; 8388608&gt; ...

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

(*)直接/线程:已启动'PS / 2输入'( - 1)[输入其他/其他0/0]&lt; 8388608&gt; ...

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

(*)直接/线程:已启动'PS / 2输入'( - 1)[输入其他/其他0/0]&lt; 8388608&gt; ...

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

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

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

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

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

(*)FBDev / Mode:设置640x480 LUT8

(*)FBDev / Mode:以8位(LUT8)切换到640x480(虚拟640x480),音高5888 dfbtest.c&lt; 30&gt;:

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

(!!!) *警告[申请退出时未取消DirectFB的初始化!] * [../../../src/core/core.c:859 in dfb_core_deinit_check() ]

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

1 个答案:

答案 0 :(得分:0)

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