I got the following directFB example code form the tutorials:
#include <stdio.h>
#include <unistd.h>
#include <directfb/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) {
DFBSurfaceDescription dsc;
DFBCHECK(DirectFBInit (&argc, &argv));
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;
}
And I'm trying to compile and got the error (from a gnome-terminal):
$ g++ Test01HorizontalLine.cpp -I /usr/local/include/directfb/
Test01HorizontalLine.cpp: In function ‘int main(int, char**)’:
Test01HorizontalLine.cpp:27: error: invalid conversion from ‘int’ to ‘DFBSurfaceCapabilities’
Test01HorizontalLine.cpp:33: error: invalid conversion from ‘int’ to ‘DFBSurfaceFlipFlags’
I'm using DFB 1.4.11 (I can't update for my current project). How can I make this sample run? (newbie)
--update
After update the lines (as stated by @jclin):
dsc.caps = DFBSurfaceCapabilities(DSCAPS_PRIMARY | DSCAPS_FLIPPING);
...
primary->Flip(primary, NULL, DFBSurfaceFlipFlags(0));
the result is:
$ g++ Test01HorizontalLine.cpp -I /usr/local/include/directfb/
/tmp/cc6iUS1W.o: In function `main':
Test01HorizontalLine.cpp:(.text+0x1c): undefined reference to `DirectFBInit'
Test01HorizontalLine.cpp:(.text+0x61): undefined reference to `DirectFBErrorFatal'
Test01HorizontalLine.cpp:(.text+0x6d): undefined reference to `DirectFBCreate'
Test01HorizontalLine.cpp:(.text+0xb2): undefined reference to `DirectFBErrorFatal'
Test01HorizontalLine.cpp:(.text+0x111): undefined reference to `DirectFBErrorFatal'
Test01HorizontalLine.cpp:(.text+0x188): undefined reference to `DirectFBErrorFatal'
Test01HorizontalLine.cpp:(.text+0x1ef): undefined reference to `DirectFBErrorFatal'
Test01HorizontalLine.cpp:(.text+0x26d): undefined reference to `DirectFBErrorFatal'
/tmp/cc6iUS1W.o:Test01HorizontalLine.cpp:(.text+0x2e4): more undefined references to `DirectFBErrorFatal' follow
collect2: ld returned 1 exit status
Can you try this because I have no such version right now.
dsc.caps = DFBSurfaceCapabilities(DSCAPS_PRIMARY | DSCAPS_FLIPPING);
...
primary->Flip(primary, NULL, DFBSurfaceFlipFlags(0));