![]() | DirectFB Tutorials |
Keybuffer and simple alphachannel example |
#include <stdlib.h> | |
#include <directfb.h> | |
static IDirectFB *dfb = NULL; |
(Globals) |
static IDirectFBEventBuffer *buffer = NULL; |
A buffer for input events. |
int main (int argc, char **argv) | |
DFBSurfaceDescription dsc; |
(Locals) |
int quit = 0; |
Set this to non-null to quit. |
DFBCHECK (DirectFBInit (&argc, &argv)); |
(Initialize) |
DFBCHECK (primary->FillRectangle (primary, |
(Clear) |
DFBCHECK (dfb->GetInputDevice (dfb, DIDID_KEYBOARD, &keyboard)); |
(Get keyboard) |
DFBCHECK (keyboard->CreateEventBuffer (keyboard, &buffer)); |
Create an event buffer for the keyboard. |
DFBCHECK (dfb->CreateImageProvider (dfb, DATADIR"/foot.png", &provider)); |
(Load the foot) |
DFBCHECK (primary->SetBlittingFlags (primary, DSBLIT_BLEND_ALPHACHANNEL)); |
Set blitting flags to DSBLIT_BLEND_ALPHACHANNEL that enables alpha blending using the alpha channel of the source. |
while (!quit) |
Loop as long as the escape key has not been pressed. |
DFBInputEvent event; |
Structure which stores a DirectFB input event from an input buffer. |
DFBCHECK (buffer->WaitForEvent (buffer)); |
This makes the current thread wait idle for the next event. |
while (buffer->GetEvent (buffer, DFB_EVENT(&event)) == DFB_OK) |
Fetch all events from buffer one by one and process them. |
if (event.type == DIET_KEYRELEASE) |
If any key went up, we clear the screen. |
if (event.type == DIET_KEYPRESS) |
If a key has been pressed and it's the escape key, we quit. Otherwise we put a foot print somewhere. |
} |
We do no flipping here because we created a non flipping primary surface. |
buffer->Release (buffer); |
Release the input buffer. |
keyboard->Release (keyboard); |
(Release) |
return 23; |
(C) Copyright by convergence GmbH |
![]() |