1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#include <++dfb.h>
#include "dfbapp.h"
class DFBTestFontBlend : public DFBApp {
private:
IDirectFBFont font;
/* called after initialization */
virtual bool Setup( int width, int height ) {
DFBFontDescription desc;
desc.flags = DFDESC_HEIGHT;
desc.height = 256;
font = m_dfb.CreateFont( FONT, desc );
return true;
}
/* render callback */
virtual void Render( IDirectFBSurface &surface ) {
surface.Clear( 0, 0, 255, 255 );
surface.SetFont( font );
surface.SetColor( 0, 0, 0, 255 );
surface.SetSrcBlendFunction( DSBF_INVSRCALPHA );
surface.SetDstBlendFunction( DSBF_INVSRCALPHA );
surface.DrawString( "Test Text", -1, 10, 10, (DFBSurfaceTextFlags)(DSTF_TOPLEFT | DSTF_BLEND_FUNCS) );
}
};
int
main( int argc, char *argv[] )
{
DFBTestFontBlend app;
try {
/* Initialize DirectFB command line parsing. */
DirectFB::Init( &argc, &argv );
/* Parse remaining arguments and run. */
if (app.Init( argc, argv ))
app.Run();
}
catch (DFBException *ex) {
/*
* Exception has been caught, destructor of 'app' will deinitialize
* anything at return time (below) that got initialized until now.
*/
std::cerr << std::endl;
std::cerr << "Caught exception!" << std::endl;
std::cerr << " -- " << ex << std::endl;
}
return 0;
}
|