The only thing that your code does is to set the color to the same color
over and over..
You don't mean primary->SetColor (primary, 0xff, 0xff, 0xff, k); ?
Not sure but I think you might also need to specify ..._ALPHACHANNEL for
your surface.
You can also try an implementation with windows;
try this:
#include <directfb.h>
IDirectFB *dfb;
IDirectFBDisplayLayer *layer;
IDirectFBWindow *window;
DFBWindowDescription desc;
int k = 255;
int main()
{
DirectFBInit(0,0);
DirectFBCreate(&dfb);
dfb->GetDisplayLayer(dfb,DLID_PRIMARY,&layer);
desc.flags = DWDESC_CAPS;
desc.caps = DWCAPS_ALPHACHANNEL | DWCAPS_COLOR;
layer->CreateWindow(layer,&desc,&window);
window->SetColor(window,255,255,255,255);
window->SetOpacity(window,255);
while(k)
window->SetOpacity(window, k--);
}
on X11 the default background color is not black so you may need to
start with --dfb:layer-bg-color=0.
greets
Niels
Jérémy Morel wrote:
Hi !
I'd like to implement a fade out effect on the entire screen. My
application is pretty simple, and is made of only one surface, called
primary (the basic code is taken from the simple.c example). Here are
the parameters I use to create the surface :
dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
dsc.pixelformat = DSPF_ARGB;
To implement the fade out effect, I thought of doing this :
void fadeout() {
int k = 0;
while(k++ <= 255) {
primary->SetColor (primary, 0xff, 0xff, 0xff, 0x01);
primary->FillRectangle (primary, 0, 0, screen_width,
screen_height);
primary->Flip(primary, NULL, DSFLIP_NONE);
sleep(0.1);
}
}
This should apply 255 times a very light and almost transparent white
layer on the surface, and thus should be a fading to white effect.
However, it looks like no matter what the value of the alpha component
is, the layer is totally opaque (except for alpha = 0x00, in which
case it looks like the layer is solid black). What am I doing wrong ?
And is there already an implementation of such an effect ?
Thanks.
--
Jérémy
_______________________________________________
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