See below.
Greets,
Niels

tomaszdro...@interia.eu wrote:
Code:

---------------------------------------------------
...

IDirectFBSurface * primary_surface = NULL;
DFBSurfaceDescription primary_surface_description;
primary_surface_description.flags = DSDESC_CAPS;
primary_surface_description.caps  = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
if( (dfberr = main_interface->CreateSurface( main_interface, &primary_surface_description, &primary_surface )) != DFB_OK ) { DirectFBErrorFatal( "CreateSurface( main_interface, &primary_surface_description, &primary_surface )", dfberr); } if( (dfberr = primary_surface->GetSize( primary_surface, &(screen.width), &(screen.height) )) != DFB_OK ) { DirectFBErrorFatal( "GetSize( primary_surface, &screen_width, &screen_height )", dfberr); }

IDirectFBSurface * willow_surface = NULL;
DFBSurfaceDescription willow_surface_description;
willow_surface_description.flags = DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT; willow_surface_description.caps = /*DSCAPS_PRIMARY (1) |*/ DSCAPS_FLIPPING; /*| DSCAPS_SUBSURFACE; (2) */
willow_surface_description.width = screen.width/4;
willow_surface_description.height = screen.height/4;
if( (dfberr = main_interface->CreateSurface( main_interface, &willow_surface_description, &willow_surface )) != DFB_OK ) { DirectFBErrorFatal( "CreateSurface( main_interface, &willow_surface_description, &willow_surface )", dfberr); }

if( (dfberr = primary_surface->SetColor( primary_surface, 0xf0, 0x00, 0x00, 0xa0 )) != DFB_OK ) { DirectFBErrorFatal( "SetColor( primary_surface, 0xf0, 0x00, 0x00 0xa0 )", dfberr); } if( (dfberr = willow_surface->SetColor( willow_surface, 0x00, 0xf0, 0x00, 0xa0 )) != DFB_OK ) { DirectFBErrorFatal( "SetColor( primary_surface, 0x00, 0xf0, 0x00 0xa0 )", dfberr); }

if( (dfberr = primary_surface->FillRectangle( primary_surface, 0, 0, screen.width, screen.height )) != DFB_OK ) { DirectFBErrorFatal( "FillRectangle( primary_surface, 0, 0, screen.width, screen.height )", dfberr); } if( (dfberr = willow_surface->FillRectangle( willow_surface, 0, 0, willow_surface_description.width, willow_surface_description.height )) != DFB_OK ) { DirectFBErrorFatal( "FillRectangle( willow_surface, 0, 0, willow_surface_description.width, willow_surface_description.height )", dfberr); }

if( (dfberr = primary_surface->Flip( primary_surface, NULL, 0 )) != DFB_OK ) /* (3) */
{ DirectFBErrorFatal( "Flip( primary_surface, NULL, 0 )", dfberr); }
if( (dfberr = willow_surface->Flip( willow_surface, NULL, 0 )) != DFB_OK )
{ DirectFBErrorFatal( "Flip( willow_surface, NULL, 0 )", dfberr); }

sleep(5);
...

---------------------------------------------------
All code compile and run withought errors, warnings.

Questions:
I) If I use only primary_surface (comment out everything willow_surface), screen flash red - OK.
Exactly :)

II) When I comment out (3) then screen is black. Why ? I thought there should be green rectangle in left up corner.
no. A surface is just a piece of canvas. It is off-screen by default. What you see instead is the "screen" (IDirectFBScreen) which consists of 1 or more "layers" (IDirectFBDisplayLayer). So either you must "link" a surface to a layer (normally by IDirectFBDisplayLayer::GetSurface, or by creating it with DSCAPS_PRIMARY).

III) If code is as you see, then all screen flash red, no green rectangle appears. Why?
Because the green rectangle is drawn on a surface, which is off-screen by default.

IV) If I uncomment (1) then no error while program running, but screen is black. Is it ok to have two primary surfaces for one super interface? If not then why no error occure during program execution, when creating willow_surface ?
It will simply replace. Your old surface is now not shown anymore. It is a bit strange that you do not see the green rectangle then, though.

V) If I uncomment (2) I still see only red screen withought green rectangle.
DSCAPS_SUBSURFACE only makes sense if you call it from a IDirectFBSurface. We might put in a check to disallow what you do there, to avoid misunderstandings in the future. Subsurfaces are little helper surfaces which handle things like clipping, these make sense if you want to e.g. layout UI-elements in a surface.

To what purposes are subsurfaces?
What I do wrong that I can not see green rectangle ?

The easiest solution is to use Windows, check IDirectFBDisplayLayer::CreateWindow. This will do surfaces and linking for you. If you want to do it yourself, either put your surfaces on different layers (if you have more than 1, check IDirectFB::EnumDisplayLayers) or use IDirectFBSurface::Blit to copy your red and green rectangle together.


----------------------------------------------------------------------
Szukasz pracy? Sprawdź nasze oferty!
http://link.interia.pl/f22b8

_______________________________________________
directfb-users mailing list
directfb-users@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users



--

.------------------------------------------.
| DirectFB - Hardware accelerated graphics |
| http://www.directfb.org/                 |
"------------------------------------------"
_______________________________________________
directfb-users mailing list
directfb-users@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users

Reply via email to