コード例 #1
0
void IDirectFBSurface::SetColor (DFBColor &color)
{
     DFBCHECK( iface->SetColor (iface, color.r, color.g, color.b, color.a) );
}
コード例 #2
0
void IDirectFBScreen::GetMixerConfiguration (int                   mixer,
                                             DFBScreenMixerConfig *config)
{
     DFBCHECK( iface->GetMixerConfiguration (iface, mixer, config) );
}
コード例 #3
0
void IDirectFBScreen::SetMixerConfiguration (int                         mixer,
                                             const DFBScreenMixerConfig &config)
{
     DFBCHECK( iface->SetMixerConfiguration (iface, mixer, &config) );
}
コード例 #4
0
void IDirectFBScreen::GetSize (int *width,
                               int *height)
{
     DFBCHECK( iface->GetSize (iface, width, height) );
}
コード例 #5
0
void IDirectFBScreen::WaitForSync()
{
     DFBCHECK( iface->WaitForSync (iface) );
}
コード例 #6
0
void IDirectFBScreen::GetOutputDescriptions (DFBScreenOutputDescription *descriptions)
{
     DFBCHECK( iface->GetOutputDescriptions (iface, descriptions) );
}
コード例 #7
0
void IDirectFBScreen::TestOutputConfiguration (int                          output,
                                               const DFBScreenOutputConfig &config,
                                               DFBScreenOutputConfigFlags  *failed)
{
     DFBCHECK( iface->TestOutputConfiguration (iface, output, &config, failed) );
}
コード例 #8
0
void IDirectFBInputDevice::GetXY (int *x, int *y)
{
     DFBCHECK( iface->GetXY (iface, x, y) );
}
コード例 #9
0
void IDirectFBInputDevice::GetDescription (DFBInputDeviceDescription *desc)
{
     DFBCHECK( iface->GetDescription (iface, desc) );
}
コード例 #10
0
void IDirectFBSurface::GetVisibleRectangle (DFBRectangle *rect)
{
     DFBCHECK( iface->GetVisibleRectangle (iface, rect) );
}
コード例 #11
0
ファイル: evas_directfb_window.c プロジェクト: Limsik/e17
int main( int argc, char *argv[] )
{
     IDirectFB              *dfb;
     IDirectFBDisplayLayer  *layer;

     IDirectFBSurface       *bgsurface;
     IDirectFBImageProvider *provider;

     IDirectFBWindow        *window1;
     IDirectFBWindow        *window2;
     IDirectFBSurface       *window_surface1;
     IDirectFBSurface       *window_surface2;

     IDirectFBEventBuffer   *buffer;

     DFBDisplayLayerConfig  layer_config;

#if ((DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23))
     DFBCardCapabilities    caps;
#else
     DFBGraphicsDeviceDescription caps;
#endif
     IDirectFBWindow*       upper;
     DFBWindowID            id1;

     IDirectFBFont          *font;
     int fontheight;
     int err;
     int quit = 0;


     DFBCHECK(DirectFBInit( &argc, &argv ));
     DFBCHECK(DirectFBCreate( &dfb ));

#if ((DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23))
     dfb->GetCardCapabilities( dfb, &caps );
#else
     dfb->GetDeviceDescription( dfb, &caps );
#endif

     dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );

     if (!((caps.blitting_flags & DSBLIT_BLEND_ALPHACHANNEL) &&
           (caps.blitting_flags & DSBLIT_BLEND_COLORALPHA  )))
     {
          layer_config.flags = DLCONF_BUFFERMODE;
          layer_config.buffermode = DLBM_BACKSYSTEM;

          layer->SetConfiguration( layer, &layer_config );
     }

     layer->GetConfiguration( layer, &layer_config );
     layer->EnableCursor ( layer, 1 );

     {
          DFBFontDescription desc;

          desc.flags = DFDESC_HEIGHT;
          desc.height = layer_config.width/50;

          DFBCHECK(dfb->CreateFont( dfb, PACKAGE_DATA_DIR"/grunge.ttf", &desc, &font ));
          font->GetHeight( font, &fontheight );
     }

     {
          DFBSurfaceDescription desc;

          DFBCHECK(dfb->CreateImageProvider( dfb,
                                             PACKAGE_DATA_DIR"/bg.png",
                                             &provider ));

          desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT;
          desc.width = layer_config.width;
          desc.height = layer_config.height;

          DFBCHECK(dfb->CreateSurface( dfb, &desc, &bgsurface ) );


          provider->RenderTo( provider, bgsurface, NULL );
          provider->Release( provider );

	  DFBCHECK(bgsurface->SetFont( bgsurface, font ));

          bgsurface->SetColor( bgsurface, 0xCF, 0xCF, 0xFF, 0xFF );
          bgsurface->DrawString( bgsurface,
                                 "Move the mouse over a window to activate it.",
                                 -1, 10, 0, DSTF_LEFT | DSTF_TOP );

          bgsurface->SetColor( bgsurface, 0xFF, 0xCF, 0xFF, 0xFF );
          bgsurface->DrawString( bgsurface,
                    "You can drag them around, too, if you want.",
                                 -1, 10 , 40, DSTF_LEFT | DSTF_TOP );

          bgsurface->SetColor( bgsurface, 0xCF, 0xCF, 0xFF, 0xFF );
	  bgsurface->DrawString( bgsurface,
                    "The one with funky stuff happening and things flying around is an evas.",
                                 -1, 10, 80, DSTF_LEFT | DSTF_TOP );




          layer->SetBackgroundImage( layer, bgsurface );
          layer->SetBackgroundMode( layer, DLBM_IMAGE );
     }
     {
	  DFBWindowDescription desc;
	  desc.flags = ( DWDESC_POSX | DWDESC_POSY |
                         DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS );

	  desc.posx = 20;
          desc.posy = 120;
          desc.width = 200;
          desc.height = 200;
	  desc.caps = DWCAPS_ALPHACHANNEL;

          DFBCHECK( layer->CreateWindow( layer, &desc, &window2 ) );
          window2->GetSurface( window2, &window_surface2 );

          window2->SetOpacity( window2, 0xFF );

          window2->CreateEventBuffer( window2, &buffer );

	  {
	     window_surface2->SetColor( window_surface2,
		   0x00, 0x30, 0x10, 0xc0 );
	     window_surface2->DrawRectangle( window_surface2, 0, 0,
		   desc.width, desc.height );
	     window_surface2->SetColor( window_surface2,
		   0x80, 0xa0, 0x00, 0x90 );
	     window_surface2->FillRectangle( window_surface2, 1, 1,
		   desc.width-2, desc.height-2 );


	     DFBCHECK(window_surface2->SetFont(window_surface2, font ));
	     window_surface2->SetColor( window_surface2, 0xCF, 0xFF, 0xCF, 0xFF );

	     window_surface2->DrawString( window_surface2,
		   "Pants!",
		   -1,10, fontheight + 5, DSTF_LEFT | DSTF_TOP );

	  }

          window_surface2->Flip( window_surface2, NULL, 0 );
     }

     {
          DFBWindowDescription desc;

          desc.flags = ( DWDESC_POSX | DWDESC_POSY |
                         DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS );
          desc.posx = 200;
          desc.posy = 200;
          desc.width = 240;
          desc.height = 320;
          desc.caps = DWCAPS_ALPHACHANNEL;

          DFBCHECK(layer->CreateWindow( layer, &desc, &window1 ) );
          window1->GetSurface( window1, &window_surface1 );

          window_surface1->SetColor( window_surface1, 0xFF, 0x20, 0x20, 0x90 );
          window_surface1->DrawRectangle( window_surface1, 0, 0,
                                          desc.width, desc.height );

          window_surface1->Flip( window_surface1, NULL, 0 );

          window1->SetOpacity( window1, 0xFF );

          window1->GetID( window1, &id1 );

          window1->AttachEventBuffer( window1, buffer );
     }

     window1->RequestFocus( window1 );
     window1->RaiseToTop( window1 );
     upper = window1;
     {
	evas_init();
	evas = evas_new();
	evas_output_method_set(evas, evas_render_method_lookup("directfb"));
	evas_output_size_set(evas, 240, 320);
	evas_output_viewport_set(evas, 0, 0, 240, 320);
	{
	   Evas_Engine_Info_DirectFB *einfo;

	   einfo = (Evas_Engine_Info_DirectFB *) evas_engine_info_get(evas);

	   einfo->info.dfb = dfb;
	   einfo->info.surface = window_surface1;
	   einfo->info.flags = DSDRAW_BLEND;
	   evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
	}
	setup();
	evas_render(evas);
	start_time = get_time();
     }

     while (!quit) {
          static IDirectFBWindow* active = NULL;
          static int grabbed = 0;
          static int startx = 0;
          static int starty = 0;
          static int endx = 0;
          static int endy = 0;
          DFBWindowEvent evt;

          buffer->WaitForEventWithTimeout( buffer, 0, 10 );

          while (buffer->GetEvent( buffer, DFB_EVENT(&evt) ) == DFB_OK) {
               IDirectFBWindow* window;

               if (evt.window_id == id1)
                    window = window1;
               else
                    window = window2;

               if (active) {
                    switch (evt.type) {

                    case DWET_BUTTONDOWN:
                         if (!grabbed && evt.button == DIBI_LEFT) {
                              grabbed = 1;
                              layer->GetCursorPosition( layer,
                                                        &startx, &starty );
                              window->GrabPointer( window );
                         }
                         break;

                    case DWET_BUTTONUP:
                         switch (evt.button) {
                              case DIBI_LEFT:
                                   if (grabbed) {
                                        window->UngrabPointer( window );
                                        grabbed = 0;
                                   }
                                   break;
                              case DIBI_MIDDLE:
                                   upper->LowerToBottom( upper );
                                   upper = (upper == window1) ? window2 : window1;
                                   break;
                              case DIBI_RIGHT:
                                   quit = DIKS_DOWN;
                                   break;
                              default:
                                   break;
                         }
                         break;

                    case DWET_KEYDOWN:
                         if (grabbed)
                              break;
                         switch (evt.key_id) {
                              case DIKI_RIGHT:
                                   active->Move (active, 1, 0);
                                   break;
                              case DIKI_LEFT:
                                   active->Move (active, -1, 0);
                                   break;
                              case DIKI_UP:
                                   active->Move (active, 0, -1);
                                   break;
                              case DIKI_DOWN:
                                   active->Move (active, 0, 1);
                                   break;
                              default:
                                   break;
                         }
                         break;

                    case DWET_LOSTFOCUS:
                         if (!grabbed)
                              active = NULL;
                         break;

                    default:
                         break;

                    }
               }
               else if (evt.type == DWET_GOTFOCUS)
                    active = window;

               switch (evt.type) {

               case DWET_MOTION:
                    endx = evt.cx;
                    endy = evt.cy;
                    break;

               case DWET_KEYDOWN:
                    switch (evt.key_symbol) {
                    case DIKS_ESCAPE:
                    case DIKS_SMALL_Q:
                    case DIKS_CAPITAL_Q:
                    case DIKS_BACK:
                    case DIKS_STOP:
                         quit = 1;
                         break;
                    default:
                         break;
                    }
                    break;

               default:
                    break;
               }
          }

          if (active) {
               if (grabbed) {
                    active->Move( active, endx - startx, endy - starty);
                    startx = endx;
                    starty = endy;
               }
               active->SetOpacity( active,
                                   (sin( myclock()/300.0 ) * 85) + 170 );
          }
	  loop();
	  {
	     Eina_List *updates;

	     updates = evas_render_updates(evas);
	     /* efficient update.. only flip the rectangle regions that changed! */
	     if (updates)
	       {
		  DFBRegion region;
		  Eina_List *l;

		  for (l = updates; l; l = l->next)
		    {
		       Evas_Rectangle *rect;

		       rect = l->data;
		       region.x1 = rect->x;
		       region.y1 = rect->y;
		       region.x2 = rect->x + rect->w - 1;
		       region.y2 = rect->y + rect->h - 1;
		       window_surface1->Flip(window_surface1, &region,
					     DSFLIP_BLIT);
		    }
		  evas_render_updates_free(updates);
	       }
	  }
     }

     buffer->Release( buffer );
     window_surface2->Release( window_surface2 );
     window_surface1->Release( window_surface1 );
     window2->Release( window2 );
     window1->Release( window1 );
     layer->Release( layer );
     bgsurface->Release( bgsurface );
     dfb->Release( dfb );

   evas_shutdown();
   return 0;
}
コード例 #12
0
void IDirectFBSurface::Dump (const char *directory,
                              const char *prefix)
{
     DFBCHECK( iface->Dump (iface, directory, prefix) );
}
コード例 #13
0
void IDirectFBSurface::DrawLine (const DFBRegion &line)
{
     DFBCHECK( iface->DrawLine (iface, line.x1, line.y1, line.x2, line.y2) );
}
コード例 #14
0
void IDirectFBSurface::DrawRectangle (const DFBRectangle &rect)
{
     DFBCHECK( iface->DrawRectangle (iface, rect.x, rect.y, rect.w, rect.h) );
}
コード例 #15
0
void IDirectFBScreen::TestEncoderConfiguration (int                           encoder,
                                                const DFBScreenEncoderConfig &config,
                                                DFBScreenEncoderConfigFlags  *failed)
{
     DFBCHECK( iface->TestEncoderConfiguration (iface, encoder, &config, failed) );
}
コード例 #16
0
void IDirectFBInputDevice::GetKeymapEntry (int                        code,
                                           DFBInputDeviceKeymapEntry *entry)
{
     DFBCHECK( iface->GetKeymapEntry (iface, code, entry) );
}
コード例 #17
0
void IDirectFBScreen::SetEncoderConfiguration (int                           encoder,
                                               const DFBScreenEncoderConfig &config)
{
     DFBCHECK( iface->SetEncoderConfiguration (iface, encoder, &config) );
}
コード例 #18
0
void IDirectFBInputDevice::DetachEventBuffer (IDirectFBEventBuffer *buffer)
{
     DFBCHECK( iface->DetachEventBuffer (iface, buffer->get_iface()) );
}
コード例 #19
0
void IDirectFBScreen::GetOutputConfiguration (int                    output,
                                              DFBScreenOutputConfig *config)
{
     DFBCHECK( iface->GetOutputConfiguration (iface, output, config) );
}
コード例 #20
0
	int DFBFontProvider::getMaxAdvance() {
		int maxAdvance = 0;

		DFBCHECK(font->GetMaxAdvance(font, &maxAdvance));
		return maxAdvance;
	}
コード例 #21
0
void IDirectFBScreen::SetOutputConfiguration (int                          output,
                                              const DFBScreenOutputConfig &config)
{
     DFBCHECK( iface->SetOutputConfiguration (iface, output, &config) );
}
コード例 #22
0
	int DFBFontProvider::getHeight() {
		int fontHeight = 0;

		DFBCHECK(font->GetHeight(font, &fontHeight));
		return fontHeight;
	}
コード例 #23
0
void IDirectFBScreen::EnumDisplayLayers (DFBDisplayLayerCallback  callback,
                                         void                    *callbackdata)
{
     DFBCHECK( iface->EnumDisplayLayers (iface, callback, callbackdata) );
}
コード例 #24
0
ファイル: lesson2.c プロジェクト: mcdoh/dfglesNeHe
int main(int argc, char *argv[])
{
	int quit = 0;
	DFBResult err;
	DFBSurfaceDescription dsc;

	DFBCHECK(DirectFBInit(&argc, &argv));

	// create the super interface
	DFBCHECK(DirectFBCreate(&dfb));

	// create an event buffer for all devices with these caps
	DFBCHECK(dfb->CreateInputEventBuffer(dfb, DICAPS_KEYS | DICAPS_AXES, DFB_FALSE, &events));

	// set our cooperative level to DFSCL_FULLSCREEN for exclusive access to the primary layer
	dfb->SetCooperativeLevel(dfb, DFSCL_FULLSCREEN);

	// get the primary surface, i.e. the surface of the primary layer we have exclusive access to
	dsc.flags = DSDESC_CAPS;
	dsc.caps  = DSCAPS_PRIMARY | DSCAPS_DOUBLE | DSCAPS_OPENGL_HINT;

	DFBCHECK(dfb->CreateSurface(dfb, &dsc, &primary));

	// get the size of the surface and fill it
	DFBCHECK(primary->GetSize(primary, &screen_width, &screen_height));
	DFBCHECK(primary->FillRectangle(primary, 0, 0, screen_width, screen_height));
	primary->Flip(primary, NULL, 0);

	// create the default font and set it
	DFBCHECK(dfb->CreateFont(dfb, NULL, NULL, &font));
	DFBCHECK(primary->SetFont(primary, font));

	// get the GL context
	DFBCHECK(primary->GetGL(primary, &primary_gl));

	DFBCHECK(primary_gl->Lock(primary_gl));

	init(argc, argv);
	reshape(screen_width, screen_height);

	DFBCHECK(primary_gl->Unlock(primary_gl));

	T0 = get_millis();

	while (!quit)
	{
		DFBInputEvent evt;
		unsigned long t;

		DFBCHECK(primary_gl->Lock(primary_gl));

		draw();

		DFBCHECK(primary_gl->Unlock(primary_gl));

		if (fps)
		{
			char buf[64];

			snprintf(buf, 64, "%4.1f FPS\n", fps);

			primary->SetColor(primary, 0xff, 0, 0, 0xff);
			primary->DrawString(primary, buf, -1, screen_width - 5, 5, DSTF_TOPRIGHT);
		}

		primary->Flip(primary, NULL, 0);
		Frames++;


		t = get_millis();
		if (t - T0 >= 2000)
		{
			GLfloat seconds = (t - T0) / 1000.0;

			fps = Frames / seconds;

			T0 = t;
			Frames = 0;
		}


		while (events->GetEvent(events, DFB_EVENT(&evt)) == DFB_OK)
		{
			switch (evt.type)
			{
				case DIET_KEYPRESS:
					switch (evt.key_symbol)
					{
						case DIKS_ESCAPE:
							quit = 1;
							break;
						case DIKS_CURSOR_UP:
 							inc_y = 0.1;
							break;
						case DIKS_CURSOR_DOWN:
							inc_y = -0.1;
							break;
						case DIKS_CURSOR_LEFT:
							inc_x = -0.1;
							break;
						case DIKS_CURSOR_RIGHT:
							inc_x = 0.1;
							break;
						case DIKS_PAGE_UP:
							inc_z = 0.01;
							break;
						case DIKS_PAGE_DOWN:
							inc_z = -0.01;
							break;
						default:
							;
					}
					break;
				case DIET_KEYRELEASE:
					switch (evt.key_symbol)
					{
						case DIKS_CURSOR_UP:
							inc_y = 0;
							break;
						case DIKS_CURSOR_DOWN:
							inc_y = 0;
							break;
						case DIKS_CURSOR_LEFT:
							inc_x = 0;
							break;
						case DIKS_CURSOR_RIGHT:
							inc_x = 0;
							break;
						case DIKS_PAGE_UP:
							inc_z = 0;
							break;
						case DIKS_PAGE_DOWN:
							inc_z = 0;
							break;
						default:
							;
					}
					break;
				case DIET_AXISMOTION:
					if (evt.flags & DIEF_AXISREL)
					{
						switch (evt.axis)
						{
							case DIAI_X:
								view_x += evt.axisrel / 2.0;
								break;
							case DIAI_Y:
								view_y -= evt.axisrel / 2.0;
								break;
							case DIAI_Z:
								view_z += evt.axisrel / 2.0;
								break;
							default:
								;
						}
					}
					break;
				default:
					;
			}
		}

		view_x += inc_x;
		view_y += inc_y;
		view_z += inc_z;
	}

	// release our interfaces to shutdown DirectFB
	primary_gl->Release(primary_gl);
	primary->Release(primary);
	font->Release(font);
	events->Release(events);
	dfb->Release(dfb);

	return 0;
}
コード例 #25
0
void IDirectFBScreen::SetPowerMode (DFBScreenPowerMode mode)
{
     DFBCHECK( iface->SetPowerMode (iface, mode) );
}
コード例 #26
0
ファイル: pss.c プロジェクト: edwardshao/DFB_Testing
int main( int argc, char *argv[] )
{
     char *filename = NULL;
     pthread_t demo_loop_thread = (pthread_t) -1;
     DFBResult err;
     int quit = 0;

     if (argc > 1) {
        filename = argv[1];
     } else {
        filename = "./smokey_light.jpg";
     }

     DFBSurfaceDescription dsc;

     srand((long)time(0));

     DFBCHECK(DirectFBInit( &argc, &argv ));

     /* create the super interface */
     DFBCHECK(DirectFBCreate( &dfb ));


     /* get an interface to the primary keyboard and create an
        input buffer for it */
//     DFBCHECK(dfb->GetInputDevice( dfb, DIDID_KEYBOARD, &keyboard ));
  //   DFBCHECK(keyboard->CreateEventBuffer( keyboard, &keybuffer ));

     /* set our cooperative level to DFSCL_FULLSCREEN for exclusive access to
        the primary layer */
     err = dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
     if (err)
          DirectFBError( "Failed to get exclusive access", err );

     /* get the primary surface, i.e. the surface of the primary layer we have
        exclusive access to */
     dsc.flags = DSDESC_CAPS;
     dsc.caps = DSCAPS_PRIMARY | DSCAPS_DOUBLE | DSCAPS_VIDEOONLY;

     DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary ));

     /* set our desired video mode */
     DFBCHECK(primary->GetSize( primary, &xres, &yres ));

     /* load font */
     {
          DFBFontDescription desc;

          desc.flags = DFDESC_HEIGHT;
          desc.height = yres/10;

          DFBCHECK(dfb->CreateFont( dfb, "./decker.ttf", &desc, &font ));
          DFBCHECK(primary->SetFont( primary, font ));
     }

     /* load smokey_light */
     DFBCHECK(dfb->CreateImageProvider( dfb, filename,
                                        &provider ));

     DFBCHECK(provider->GetSurfaceDescription (provider, &dsc));
     DFBCHECK(dfb->CreateSurface( dfb, &dsc, &smokey_light ));

     DFBCHECK(provider->RenderTo( provider, smokey_light, NULL ));
     provider->Release( provider );


     /* main loop */
     while (1) {
          DFBInputEvent evt;

          if ((int)demo_loop_thread == -1)
               pthread_create( &demo_loop_thread, NULL, demo_loop, NULL );

	sleep(5);
#if (0)
          keybuffer->WaitForEvent( keybuffer );

          /* process keybuffer */
          while (keybuffer->GetEvent( keybuffer, DFB_EVENT(&evt)) == DFB_OK) {
               if (evt.type == DIET_KEYPRESS) {
                    switch (evt.key_id) {
                         case DIKI_ESCAPE:
                              /* quit main loop */
                              quit = 1;
                              pthread_cancel( demo_loop_thread );
                              pthread_join( demo_loop_thread, NULL );
                              break;

                         default:
                              break;
                    }
               }
          }
#endif
     }

     smokey_light->Release( smokey_light );
     keybuffer->Release( keybuffer );
     keyboard->Release( keyboard );
     primary->Release( primary );
     dfb->Release( dfb );

     return 0;
}
コード例 #27
0
void IDirectFBScreen::TestMixerConfiguration (int                         mixer,
                                              const DFBScreenMixerConfig &config,
                                              DFBScreenMixerConfigFlags  *failed)
{
     DFBCHECK( iface->TestMixerConfiguration (iface, mixer, &config, failed) );
}
コード例 #28
0
void IDirectFBScreen::GetEncoderConfiguration (int                     encoder,
                                               DFBScreenEncoderConfig *config)
{
     DFBCHECK( iface->GetEncoderConfiguration (iface, encoder, config) );
}
コード例 #29
0
void IDirectFBScreen::GetEncoderDescriptions (DFBScreenEncoderDescription *descriptions)
{
     DFBCHECK( iface->GetEncoderDescriptions (iface, descriptions) );
}
コード例 #30
0
void IDirectFBSurface::SetFont (IDirectFBFont *font)
{
     DFBCHECK( iface->SetFont (iface, font->get_iface()) );
}