Hi,

I'm working with Canmore's (CE3100) DirectFB, studying the provided sample
apps and all the other sample tutorials at (
http://directfb.org/docs/DirectFB_Tutorials/).
I've now tried to create my own application (pretty basic UI for now) but
somehow, my created windows do not appear on screen, even after blitting /
flipping the window surface.
I used the image tutorial the included df_window as references. df_window
works perfectly.

My code is attached below and for a much more reader-friendly version at :
http://pastebin.com/X6si6g6t

Anything I'm missing?


============= CODE START ====================
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <directfb.h>

#define RESOURCES    "/usr/local/bin/resources"

#define DFBCHECK(x...) \
     {                                                                \
          err = x;                                                    \
          if (err != DFB_OK) {                                        \
               fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
               DirectFBErrorFatal( #x, err );                         \
          }                                                           \
     }

/**************************************
               Statics
**************************************/

static IDirectFB                   *dfb      = NULL;
static IDirectFBDisplayLayer       *tv       = NULL;
static IDirectFBDisplayLayer       *app      = NULL;
static IDirectFBDisplayLayer       *menu     = NULL;
static IDirectFBDisplayLayer       *events     = NULL;

static int screen_height = 0;
static int screen_width  = 0;


int main (int argc, char *argv[])
{
     int err = 0;

     IDirectFBImageProvider        *music_icon    = NULL;
     IDirectFBImageProvider        *media_icon    = NULL;
     IDirectFBImageProvider        *videos_icon   = NULL;
     IDirectFBImageProvider        *photos_icon   = NULL;

     IDirectFBWindow               *music         = NULL;

     IDirectFBSurface              *music_surface = NULL;

     DFBDisplayLayerConfig         temp_layerconfig;

     // Initialize DirectFB
     DFBCHECK ( DirectFBInit (&argc, &argv) );
     DFBCHECK ( DirectFBCreate (&dfb) );


     //DFBCHECK ( dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN) );

     DFBCHECK ( dfb->GetDisplayLayer(dfb, DLID_UPP_A, &tv ) );
     DFBCHECK ( dfb->GetDisplayLayer(dfb, DLID_UPP_B, &app ) );
     DFBCHECK ( dfb->GetDisplayLayer(dfb, DLID_UPP_C, &menu ) );
     DFBCHECK ( dfb->GetDisplayLayer(dfb, DLID_UPP_D, &events ) );

     DFBCHECK ( tv->GetConfiguration( tv, &temp_layerconfig ) );
     screen_height = temp_layerconfig.height;
     screen_width = temp_layerconfig.width;

     printf("\nScreen set at %dx%d \n",screen_width,screen_height);

     DFBCHECK ( tv->SetCooperativeLevel(tv, DLSCL_EXCLUSIVE) );
     DFBCHECK ( app->SetCooperativeLevel(app, DLSCL_ADMINISTRATIVE) );
     DFBCHECK ( menu->SetCooperativeLevel(menu, DLSCL_ADMINISTRATIVE) );
     DFBCHECK ( events->SetCooperativeLevel(events, DLSCL_ADMINISTRATIVE) );

     DFBCHECK ( dfb->CreateImageProvider ( dfb, RESOURCES"/music.png",
&music_icon) );
     DFBCHECK ( dfb->CreateImageProvider ( dfb,
RESOURCES"/externalMedia.png", &media_icon) );
     DFBCHECK ( dfb->CreateImageProvider ( dfb, RESOURCES"/videos.png",
&videos_icon) );
     DFBCHECK ( dfb->CreateImageProvider ( dfb, RESOURCES"/photos.png",
&photos_icon) );

     {
          DFBWindowDescription windesc;
          int posx = 0,posy = 0;
          int temp_posx, temp_posy, temp_height, temp_width;

          windesc.flags = DWDESC_HEIGHT | DWDESC_WIDTH | DWDESC_CAPS;
          windesc.caps = DWCAPS_ALPHACHANNEL;
          windesc.height = 96;
          windesc.width = 96;

          posx = (int) (screen_width/2);
          posy = (int) (screen_height/2);

          //DFBCHECK (  );
          // create the window
          DFBCHECK ( menu->CreateWindow( menu, &windesc, &music ) );

          // move to middle of screen and make opaque
          DFBCHECK ( music->MoveTo( music, posx, posy ) );
          DFBCHECK ( music->SetOpacity( music, 0xFF ) );

          // check window properties
          DFBCHECK ( music->GetPosition( music, &temp_posx, &temp_posy ) );
          DFBCHECK ( music->GetSize( music, &temp_width, &temp_height ) );

          printf("%dx%d Window created at (%d,%d) on %dx%d screen\n", \
                    temp_width,
temp_height,temp_posx,temp_posy,screen_width, screen_height);

          // get surface of music window
          DFBCHECK ( music->GetSurface( music, &music_surface ) );

          // fill area with red
          DFBCHECK ( music_surface->SetColor( music_surface, 0xff, 0x0, 0x0,
0xff) );
          DFBCHECK ( music_surface->DrawRectangle( music_surface, 0, 0,
windesc.width, windesc.height) );

          // render image onto the surface
          // DFBCHECK ( music_icon->RenderTo( music_icon, music_surface,
NULL ) );

          // then flip
          DFBCHECK ( music_surface->SetBlittingFlags (music_surface,
DSBLIT_BLEND_ALPHACHANNEL));
          DFBCHECK ( music_surface->Flip (music_surface, NULL, 0x0) );
          DFBCHECK ( music_surface->Blit (music_surface, music_surface,
NULL, 0, 0) );

     }

     //DFBCHECK ( imageprovider->Release (imageprovider) );
     //DFBCHECK ( imageprovider->Release (second) );
     //DFBCHECK ( primary->Release (primary) );

     sleep(5);

     DFBCHECK ( events->Release (events) );
     DFBCHECK ( menu->Release (menu) );
     DFBCHECK ( app->Release (app) );
     DFBCHECK ( tv->Release (tv) );

     DFBCHECK ( dfb->Release (dfb) );
     return 0;
}

-- 
Rystraum Fabe Gamonez
Registered Linux User #484635
http://rystraum.com
_______________________________________________
directfb-users mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users

Reply via email to