> Are you still having problems with your window and with drawing to that
> window?
> If so, could you include the current version of your code in your next mail?
>
> Is your code compiling?
> If so, you should be able to see the window(s) you create on screen. (If not,
> try to draw
> a rectangle in some color around that window. This is what is done in the
> df_window example,
> I assume you started with df_window and modified it?! If not, and if
> df_window compiles and runs,
> you should start with df_window and remove the code that you don't need step
> by step).
df_window is working on my embedded system, but if i try to start df_window on
my computer, it shows
me the "caught 11" error. I have already to remove the code step by step, so
that just only the basics
codes and it is still showing me the the error. : (
> Drawing to a window consists of the following steps
> o Create the window
> o Get an interface to the windows' surface via
> win->GetSurface(IDirectFBWindow *thiz, IDirectFBSurface **ret_surface);
> (assuming that win is the IDirectFBWindow interface you created in the
> first step)
> o Set your desired drawing color via
> win_surface->SetColor(IDirectFBSurface *thiz, u8 r, u8 g, u8 b, u8 a);
> (assuming that win_surface is the IDirectFBSurface interface you got in
> the second step)
> o Draw the rectangle via win_surface->DrawRectangle(IDirectFBSurface
> *thiz, int x, int y, int w, int h);
> o Call Flip on the windows' surface: win_surface->Flip(IDirectFBSurface
> *thiz, const DFBRegion *region, DFBSurfaceFlipFlags flags);
> You can pass NULL for the DFBRegion pointer, this way the whole window
> surface will be flipped.
Hm, my code is pretty the same like in your advice.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <time.h>
#include <directfb.h>
static IDirectFB *dfb;
static IDirectFBDisplayLayer *layer;
static IDirectFBImageProvider *provider;
static IDirectFBSurface *primary;
static IDirectFBWindow *window;
static IDirectFBSurface *window_surface;
/* macro for a safe call to DirectFB functions */
#define DFBCHECK(x...) \
{ \
err = x; \
if (err != DFB_OK) { \
fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
DirectFBErrorFatal( #x, err ); \
} \
}
int main( int argc, char *argv[] )
{
DFBDisplayLayerConfig layer_config;
int err;
DFBCHECK(DirectFBInit( &argc, &argv ));
DFBCHECK(DirectFBCreate( &dfb ));
DFBCHECK(dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer ));
layer->SetCooperativeLevel( layer, DLSCL_ADMINISTRATIVE );
layer->GetConfiguration( layer, &layer_config );
layer->EnableCursor ( layer, 1 );
DFBSurfaceDescription dsc;
DFBCHECK(dfb->CreateImageProvider( dfb,"desktop.png",&provider ));
dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_CAPS;
dsc.width = layer_config.width;
dsc.height = layer_config.height;
dsc.caps = DSCAPS_SHARED;
DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary ) );
provider->RenderTo( provider, primary, NULL );
layer->SetBackgroundImage( layer, primary );
layer->SetBackgroundMode( layer, DLBM_IMAGE );
DFBSurfaceDescription sdsc;
DFBWindowDescription desc;
sdsc.flags = (DSDESC_WIDTH | DSDESC_HEIGHT );
sdsc.width = 300;
sdsc.height = 200;
desc.flags = ( DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT
| DWDESC_CAPS);
desc.posx = 200;
desc.posy = 200;
desc.width = sdsc.width;
desc.height = sdsc.height;
desc.caps = DWCAPS_ALPHACHANNEL;
DFBCHECK(layer->CreateWindow( layer, &desc, &window ) );
DFBCHECK(window->GetSurface( window, &window_surface)) ; // PROBLEM
DFBCHECK(window_surface->SetColor( window_surface,0x00, 0x30, 0x10,
0xc0 ));
DFBCHECK(window_surface->DrawRectangle( window_surface,0, 0,
desc.width, desc.height ));
DFBCHECK(window_surface->Flip( window_surface, NULL, 0 ));
sleep (100);
window_surface->Release( window_surface );
window->Release( window );
layer->Release( layer );
primary->Release( primary );
dfb->Release( dfb );
return 42;
}
This code is compiling without errors/warnings. If i try to start the program,
it shows me
(*) DirectFB/Core: Single Application Core. (2009-03-23 12:55)
(*) Direct/Memcpy: Using Generic 64bit memcpy()
(*) Direct/Thread: Started 'X11 Input' (-1) [INPUT OTHER/OTHER 0/0]
<10485760>...
(*) DirectFB/Input: X11 Input 0.1 (directfb.org)
(*) DirectFB/Genefx: MMX detected and enabled
(*) DirectFB/Graphics: MMX Software Rasterizer 0.6 (directfb.org)
(*) DirectFB/Core/WM: Default 0.3 (directfb.org)
(*) X11/Window: Creating 640x 480 RGB32 window...
(*) X11/Display: Using XShm.
(*) Direct/Interface: Loaded 'PNG' implementation of 'IDirectFBImageProvider'.
wint.c <54>:
(#) DirectFBError [window->GetSurface( window, &window_surface)]:
Interface was released!
(!!!) *** WARNING [Application exited without deinitialization of DirectFB!]
*** [core.c:859 in dfb_core_deinit_check()]
(!!!) *** WARNING [still objects in 'Window Pool'] *** [object.c:241 in
fusion_object_pool_destroy()]
(!!!) *** WARNING [still objects in 'Layer Region Pool'] *** [object.c:241 in
fusion_object_pool_destroy()]
(!!!) *** WARNING [still objects in 'Layer Context Pool'] *** [object.c:241
in fusion_object_pool_destroy()]
(!!!) *** WARNING [still objects in 'Surface Pool'] *** [object.c:241 in
fusion_object_pool_destroy()]
> If you want to have two buttons for your imageviewer, use LiTE. LiTE is a
> very basic native toolkit for DirectFB.
> It _does_ have good good button widgets ;-) Get LiTE from the git repository
> and use one of the examples as a starting
> point. The benefit is, that you get a complete resizeable LiTE window with
> window bar etc. You just have to add two LiTE
> buttons then.
>
> Hope this helps,
Yes, i will try LiTE, but first at all i want to understand, why my program is
not starting. : )
Greetings from Dresden : )
____________________________________________________________________
Psssst! Schon vom neuen WEB.DE MultiMessenger gehört?
Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123
_______________________________________________
directfb-users mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users