这个相同的示例在我的带有 DirectFB 1.4.11 的旧 Ubuntu 10.10 中运行没有问题,并在黑屏中心显示一条黄线:
#include <iostream>
#include <stdio.h>
#include <unistd.h>
#include <directfb.h>
using namespace std;
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) {
DFBSurfaceDescription dsc;
DFBCHECK(DirectFBInit (&argc, &argv));
DFBCHECK(DirectFBCreate (&dfb));
DFBCHECK(dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
dsc.flags = DSDESC_CAPS;
dsc.caps = DFBSurfaceCapabilities(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, 0xFF, 0xFF, 0x00, 0xff));
DFBCHECK(primary->SetSrcColorKey(primary, 0xFF, 0xFF, 0x00));
DFBCHECK(primary->SetBlittingFlags(primary, (DFBSurfaceBlittingFlags) ( DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_SRC_COLORKEY)));
DFBCHECK(primary->DrawLine (primary, 0, screen_height / 2, screen_width - 1, screen_height / 2));
primary->Flip(primary, NULL, DFBSurfaceFlipFlags(0));
sleep(3);
primary->Release(primary);
dfb->Release(dfb);
cout << "DONE!\n";
return 23;
}
但是这个相同的例子只会在 Ubuntu 12.04 中使用 DirectFB 6.3 显示黑屏,没有线条。
控制台输出为:
# ./a.out
~~~~~~~~~~~~~~~~~~~~~~~~~~| DirectFB 1.6.3 |~~~~~~~~~~~~~~~~~~~~~~~~~~
(c) 2012-2013 DirectFB integrated media GmbH
(c) 2001-2013 The world wide DirectFB Open Source Community
(c) 2000-2004 Convergence (integrated media) GmbH
----------------------------------------------------------------
(*) DirectFB/Core: Single Application Core. (2013-02-07 11:05)
(*) Direct/Memcpy: Using libc memcpy()
(*) Direct/Thread: Started 'Fusion Dispatch' (-1) [MESSAGING OTHER/OTHER 0/0] <8388608>...
(*) Direct/Thread: Started 'VT Switcher' (-1) [CRITICAL OTHER/OTHER 0/0] <8388608>...
(*) Direct/Thread: Started 'VT Flusher' (-1) [DEFAULT OTHER/OTHER 0/0] <8388608>...
(*) DirectFB/FBDev: Found 'svgadrmfb' (ID 0) with frame buffer at 0x00000000, 15360k (MMIO 0x00000000, 0k)
(*) Direct/Thread: Started 'PS/2 Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...
(*) DirectFB/Input: IMPS/2 Mouse (1) 1.0 (directfb.org)
(*) Direct/Thread: Started 'PS/2 Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...
(*) DirectFB/Input: IMPS/2 Mouse (2) 1.0 (directfb.org)
(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...
(*) DirectFB/Input: Power Button (1) 0.1 (directfb.org)
(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...
(*) DirectFB/Input: AT Translated Set 2 keyboard (2) 0.1 (directfb.org)
(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...
(*) DirectFB/Input: VMware VMware Virtual USB Mouse (3) 0.1 (directfb.org)
(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...
(*) DirectFB/Input: VMware VMware Virtual USB Mouse (4) 0.1 (directfb.org)
(*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...
(*) DirectFB/Input: ImPS/2 Generic Wheel Mouse (5) 0.1 (directfb.org)
(*) Direct/Thread: Started 'Hotplug with Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...
(*) DirectFB/Input: Hot-plug detection enabled with Linux Input Driver
(*) Direct/Thread: Started 'Joystick Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...
(*) DirectFB/Input: Joystick 0.9 (directfb.org)
(*) DirectFB/Input: Hot-plug detection enabled with Input Hub Driver
(*) Direct/Thread: Started 'Keyboard Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...
(!!!) *** ONCE [Joystick sends JS_EVENT_INIT events, make sure it has been calibrated using 'jscal -c'
] *** [joystick.c:99 in joystick_handle_event()]
(*) DirectFB/Input: Keyboard 0.9 (directfb.org)
(*) DirectFB/Genefx: MMX detected and enabled
(*) DirectFB/Graphics: MMX Software Rasterizer 0.7 (directfb.org)
(*) DirectFB/Core/WM: Default 0.3 (directfb.org)
(*) FBDev/Mode: Setting 800x600 RGB32
(*) FBDev/Mode: Switched to 800x600 (virtual 800x600) at 32 bit (RGB32), pitch 8192
(*) FBDev/Mode: Setting 800x600 RGB32
(*) FBDev/Mode: Switched to 800x600 (virtual 800x600) at 32 bit (RGB32), pitch 8192
(*) FBDev/Mode: Setting 800x600 RGB32
(*) FBDev/Mode: Switched to 800x600 (virtual 800x1200) at 32 bit (RGB32), pitch 8192
(*) FBDev/Mode: Setting 800x600 RGB32
(*) FBDev/Mode: Switched to 800x600 (virtual 800x600) at 32 bit (RGB32), pitch 8192
DONE!
知道为什么不画线吗?不知道是不是64位系统的问题?