我似乎无法启动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/directfbdfbtest.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)关键其他/其他0/0 <8388608>。
(*)直接/模块:抑制模块“操纵杆”
(*)直接/模块:抑制模块‘键盘’
(*)直接/线程:启动'Linux输入‘(-1)输入其他/其他0/0 <8388608>.
(*) DirectFB/Input: Lid开关(1) 0.1 (directfb.org)
(*)直接/线程:启动'Linux输入‘(-1)输入其他/其他0/0 <8388608>.
(*) DirectFB/Input: Power Button (2) 0.1 (directfb.org)
(*)直接/线程:启动'Linux输入‘(-1)输入其他/其他0/0 <8388608>.
(*) DirectFB/Input:睡眠按钮(3) 0.1 (directfb.org)
(*)直接/线程:启动'Linux输入‘(-1)输入其他/其他0/0 <8388608>.
(*) DirectFB/Input: Power Button (4) 0.1 (directfb.org)
(*)直接/线程:启动'Linux输入‘(-1)输入其他/其他0/0 <8388608>.
(*) DirectFB/Input: Apple Computer Apple (5) 0.1 (directfb.org)
(*)直接/线程:启动'Linux输入‘(-1)输入其他/其他0/0 <8388608>.
(*) DirectFB/Input: Apple Computer Apple (6) 0.1 (directfb.org)
(*)直接/线程:启动'Linux输入‘(-1)输入其他/其他0/0 <8388608>.
(*) DirectFB/Input: Logitech USB/2光电鼠标(7) 0.1 (directfb.org)
(*)直接/线程:启动'Linux输入‘(-1)输入其他/其他0/0 <8388608>.
(*) DirectFB/Input: appletouch (8) 0.1 (directfb.org)
(*)直接/线程:启动'Linux输入‘(-1)输入其他/其他0/0 <8388608>.
(*) DirectFB/Input: applesmc (9) 0.1 (directfb.org)
(*)直接/线程:启动'Linux输入‘(-1)输入其他/其他0/0 <8388608>.
(*) DirectFB/Input: HDA Intel SPDIF In (10) 0.1 (directfb.org)
(*)直接/线程:启动'Linux输入‘(-1)输入其他/其他0/0 <8388608>.
(*) DirectFB/Input: HDA Intel Line (11) 0.1 (directfb.org)
(*)直接/线程:启动'Linux输入‘(-1)输入其他/其他0/0 <8388608>.
(*) DirectFB/Input: HDA Intel耳机(12) 0.1 (directfb.org)
(*)直接/线程:启动'PS/2输入‘(-1)输入其他/其他0/0 <8388608>.
(*) DirectFB/Input: IMPS/2鼠标(1) 1.0 (directfb.org)
(*)直接/线程:启动'PS/2输入‘(-1)输入其他/其他0/0 <8388608>.
(*) DirectFB/Input: IMPS/2鼠标(2) 1.0 (directfb.org)
(*) DirectFB/Genefx:检测并启用MMX
(*) DirectFB/Graphics: MMX软件分析仪0.6 (directfb.org)
(*) DirectFB/Core/WM:默认0.3 (directfb.org)
(*) FBDev/Surface:在偏移量0和间距5888处分配640x480 32位LUT8缓冲区(索引0)。
(*) FBDev/模式:设置640x480 LUT8
(*) FBDev/模式:在8位(LUT8)切换到640x480 (虚拟640x480),螺距5888 dfbtest.c <30>:
(#) DirectFBError [dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN)]: Invalid argument!(!!) *未重新初始化DirectFB!* ./src/core/core.c:859在dfb_core_deinit_check()中退出警告应用程序
任何如何进一步调试的想法将不胜感激。我是在Ubuntu12上运行的。一些与旧的MacBook Pro,有Radeon芯片。如果我在控制台或X11下运行这个程序,结果是相同的。屏幕闪烁,以使帧缓冲区启动,但它崩溃在这个setcooperativelevel调用。
发布于 2013-09-12 16:01:55
所以这是版本兼容性问题。头包含在比链接库更晚的DirectFB版本中。链接到DirectFB库的正确版本消除了这个问题。
https://stackoverflow.com/questions/18758188
复制相似问题