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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
Framebuffer Library Programming Reference
=========================================
A minimal framebuffer program would have something like:
{
FB *f;
f = FBopen( NULL, FB_OPEN_NEW_VC );
...
/* draw/do things here */
...
FBclose( f );
}
Library startup/exit
====================
FB *FBopen( const char *fbname, unsigned short opts )
-----------------------------------------------------
FBopen is used to initialise the framebuffer library.
fbname is the filename of the framebuffer to open (eg "/dev/fb1vga16") or it
can be left as NULL to use either the value of the FRAMEBUFFER environment
variable (if it is set) or if it is not, the current framebuffer device.
opts is a series of options that must be ORed
together if you select multiple options.
Current options are:
FB_KEEP_CURRENT_VC: The current console will be used for display.
FB_OPEN_NEW_VC: The first available console will be opened and switched to for
display.
The above two options are mutually exclusive.
It returns a handle for the opened framebuffer. If an error occured, NULL
is returned.
void FBclose( FB *f )
---------------------
FBclose shuts the framebuffer f, and if FB_OPEN_NEW_VC was selected when f was
opened, switches to the console that was current when FBopen was called.
Graphics functions
==================
The colour value given to the graphics functions are always in the current
display's native form. That means a palette based mode gives the index of
the colour, and a true-/directcolour mode gives the colour value.
void FBputpixel( FB *f, u_int16_t x, u_int16_t y, u_int32_t col )
-----------------------------------------------------------------
FBputpixel draws a single point at (x,y) on framebuffer f, with colour col.
u_int32_t FBgetpixel( FB *f, u_int16_t x, u_int16_t y )
-------------------------------------------------------
FBgetpixel returns the colour value at the point (x,y) on framebuffer f.
void FBhline( FB *f, u_int16_t x1, u_int16_t x2, u_int16_t y, u_int32_t col )
-----------------------------------------------------------------------------
FBhline draws a horizontal line on framebuffer f from (x1,y) to (x2,y) with
colour col.
void FBline( FB *f, u_int16_t x1, u_int16_t y1, u_int16_t x2, u_int16_t y2,
u_int32_t col )
---------------------------------------------------------------------------
FBline draws a line from (x1,y1) to (x2,y2) on framebuffer f with colour col.
void FBbitblt( FB *f, FBBLTPBLK *fbb)
-------------------------------------
FBbitblt blits a rectangular block from one memory area to another. It is
not limited to the framebuffer area for most display types. However, those
that do not have their own bitblt function implemented uses putpixel/getpixel
for this. VGA16 is one of these.
void FBputchar( FB *f, u_int16_t x, u_int16_t y, u_int32_t fgcol,
u_int32_t bgcol, unsigned char ch )
-----------------------------------------------------------------
FBputchar puts one character, ch, at (x,y) with colour fgcol and background
colour bgcol. If the highest bit in bgcol is set (0x80000000), the character
is drawn with transparent background.
Colourmap functions
===================
FBCMAP *FBgetcmap( FB *f )
--------------------------
FBgetcmap returns a new FBCMAP structure with the current colourmap of the
framebuffer f. It may be overwritten with a new colourmap for setting with the
FBputcmap function. Use FBfreecmap to free the colourmap allocated with this
function.
void FBputcmap( FB *f, FBCMAP *fbcmap )
---------------------------------------
FBputcmap installs the colourmap fbcmap on the framebuffer f. No error checking
of the members of fbcmap is done. To set a single colour or a range of colours,
set the start, end and len members of fbcmap appropriately.
void FBfreecmap( FBCMAP *fbcmap )
---------------------------------
FBfreecmap frees the fbcmap allocated with FBgetcmap.
u_int32_t FBc24_to_cnative( FB *f, u_int32_t col )
--------------------------------------------------
Convert a 24-bit colour value (0x00rrggbb) into the format of the current
display type. If the current display type is a palette based mode, this
function will search for the best match in the current palette and return
the index to that colour. This means it can be slow to use for each pixel.
u_int32_t FBcnative_to_c24( FB *f, u_int32_t col )
--------------------------------------------------
Convert a native colour value into a 24-bit colour value (0x00rrggbb). If
the current display type is a palette based mode, the native colour is an
index to the palette, and the colour from the current palette at that index
will be returned.
Screen settings functions (likely to be made private)
=====================================================
void FBgetfix( FB *f )
void FBgetvar( FB *f )
void FBputvar( FB *f )
These all correspond directly to the fixed and variable structures used with
the linux framebuffer. Mainly used to simplify things at this early stage.
Debug functions (likely to be made private)
===========================================
void FBfinfdump( FB *f )
void FBvinfdump( FB *f )
void FBcmapdump( FB *f )
For library programming only. You can work them out. 8-)
Still undocumented
==================
- Events (mouse, keyboard)
- Fonts
- More on bitblt
- Extra options for FBopen()
--
Martin Mitchell
Tomas Berndtsson
|