man.bsd.lv manual page server

Manual Page Search Parameters

VGL(3) Library Functions Manual VGL(3)

VGLBitmapAllocateBits, VGLBitmapCopy, VGLBitmapCreate, VGLBitmapDestroy, VGLBitmapPutChar, VGLBitmapString, VGLBlankDisplay, VGLBox, VGLCheckSwitch, VGLClear, VGLEllipse, VGLEnd, VGLFilledBox, VGLFilledEllipse, VGLGetXY, VGLInit, VGLLine, VGLKeyboardInit, VGLKeyboardEnd, VGLKeyboardGetCh, VGLMouseInit, VGLMouseMode, VGLMouseSetImage, VGLMouseSetStdImage, VGLMouseStatus, VGLPanScreen, VGLSetBorder, VGLSetPalette, VGLSetPaletteIndex, VGLSetVScreenSize, VGLSetXY, VGLTextSetFontFileVideo Graphics Library functions

library “libvgl”

#include <machine/console.h>
#include <vgl.h>

int
VGLInit(int mode);

void
VGLEnd(void);

void
VGLCheckSwitch(void);

int
VGLTextSetFontFile(char *filename);

int
VGLKeyboardInit(int code);

void
VGLKeyboardEnd(void);

int
VGLKeyboardGetCh(void);

int
VGLMouseInit(int mode);

void
VGLMouseMode(int mode);

int
VGLMouseStatus(int *x, int *y, char *buttons);

void
VGLMouseSetImage(VGLBitmap *AndMask, VGLBitmap *OrMask);

void
VGLMouseSetStdImage(void);

byte
VGLGetXY(VGLBitmap *object, int x, int y);

void
VGLSetXY(VGLBitmap *object, int x, int y, byte color);

void
VGLLine(VGLBitmap *object, int x1, int y1, int x2, int y2, byte color);

void
VGLBox(VGLBitmap *object, int x1, int y1, int x2, int y2, byte color);

void
VGLFilledBox(VGLBitmap *object, int x1, int y1, int x2, int y2, byte color);

void
VGLEllipse(VGLBitmap *object, int xc, int yc, int a, int b, byte color);

void
VGLFilledEllipse(VGLBitmap *object, int xc, int yc, int a, int b, byte color);

VGLBitmap *
VGLBitmapCreate(int type, int xsize, int ysize, byte *bits);

void
VGLBitmapDestroy(VGLBitmap *object);

int
VGLBitmapAllocateBits(VGLBitmap *object);

int
VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy, VGLBitmap *dst, int dstx, int dsty, int width, int hight);

void
VGLBitmapPutChar(VGLBitmap *Object, int x, int y, byte ch, byte fgcol, byte bgcol, int fill, int dir);

void
VGLBitmapString(VGLBitmap *Object, int x, int y, char *str, byte fgcol, byte bgcol, int fill, int dir);

void
VGLClear(VGLBitmap *object, byte color);

void
VGLSetPalette(byte *red, byte *green, byte *blue);

void
VGLSetPaletteIndex(byte color, byte red, byte green, byte blue);

void
VGLSetBorder(byte color);

int
VGLSetVScreenSize(VGLBitmap *object, int vxsize, int vysize);

int
VGLPanScreen(VGLBitmap *object, int x, int y);

void
VGLBlankDisplay(int blank);

Libvgl is a library that enables the programmer access to the graphics modes supported by the console driver (syscons(4)). The library takes care of programming the actual video hardware, and provides a number of simple functions to do various graphic operations. There is also support for a mouse via the standard mouse system in DragonFly, see mouse(4), including the ability to transparently have a mouse pointer superimposed on the graphic image currently being worked on. The library takes care of screen switching by storing the current image in memory before switching to another virtual console, and restoring when the user switches back. This allows several graphic applications at once, but on different virtual consoles.

Below is a short description of the various functions:

() initialize the library and set up the graphic mode mode.

() terminate graphic mode, and restore the screenmode that was active before VGLInit() was called.

() if the program goes into longer periods of processing without doing any graphics output, calling this function occasionally will allow the system to switch screens.

() instruct the char/string functions to use the font in file filename instead of the builtin font.

() set up the keyboard in the “raw” I/O mode and specify the key code to be used. code must be VGL_XLATEKEYS, VGL_CODEKEYS, or VGL_RAWKEYS. When VGL_XLATEKEYS is specified, the keyboard translate the raw keyboard scan code into a character code. If VGL_RAWKEYS is used, the raw keyboard scan code is read as is. VGL_CODEKEYS is the intermediate key code; each key is assigned a unique code whereas more than one raw scan code may be generated when a key is pressed.

() when you have finished using the keyboard, call this function.

() read one byte from the keyboard. As the keyboard I/O is in the “raw” input mode, the function will not block even if there is no input data, and returns 0.

() initialize the mouse. The optional on-screen mouse pointer is shown if the argument is VGL_MOUSESHOW.

() either shows the mouse pointer if the argument is VGL_MOUSESHOW, or hides the mouse pointer if the argument is VGL_MOUSEHIDE.

() returns the current mouse pointer coordinates and button state in x, y, buttons. The return value reflects if the mouse pointer is currently shown on screen or not.

() with this function it is possible to change the image of the mouse pointer on screen.

() this function restores the mouse pointer to the standard arrow.

() retrieves the color of the pixel located at x, y, coordinates of the object argument, and returns it as a byte value.

() sets the color of the pixel located at x, y, coordinates of the object argument to color byte value.

() draw a line from x1, y1 to x2, y2 in color color.

() draw a box with upper left hand corner at x1, y1 and lower right hand corner at x2, y2 in color color.

() draw a filled (solid) box with upper left hand corner at x1, y1 and lower right hand corner at x2, y2 in color color.

() draw an ellipse centered at xc, yc make it a pixels wide, and b pixels high in color color.

() draw a filled (solid) ellipse centered at xc, yc make it a pixels wide, and b pixels high in color color.

() create a bitmap object and initialize it with the specified values and bit data. type must be MEMBUF for the in-memory bitmap. bits may be NULL so that bitmap data may be associated later.

There also is a macro, (type, xsize, ysize, bits) to initialize a statically declared bitmap object.

() free the bitmap data and the bitmap object.

() allocate a bit data buffer for the specified object.

() copy a rectangle of pixels from bitmap src upper left hand corner at srcx, srcy to bitmap dst at dstx, dsty of the size width, height.

() write the character ch at position x, y in foreground color fgcol. If fill is != 0, use the color bgcol as background otherwise the background is transparent. The character is drawn in the direction specified by the argument dir.

() write the string str at position x, y in foreground color fgcol. If fill is != 0, use the color bgcol as background otherwise the background is transparent. The string is drawn in the direction specified by the argument dir.

() clears the entire bitmap to color color.

() this function sets the palette used, the arguments red, green, blue should point to byte arrays of 256 positions each.

() set the palette index color to the specified RGB value.

() set the border color to color color.

() change the virtual screen size of the display. Note that this function must be called when our vty is in the foreground. And object must be VGLDisplay. Passing an in-memory bitmap to this function results in error.

The desired virtual screen width may not be achievable because of the video card hardware. In such case the video driver (and underlaying video BIOS) may choose the next largest values. Always examine object->VXsize and VYsize after calling this function, in order to see how the virtual screen is actually set up.

In order to set up the largest possible virtual screen, you may call this function with arbitrary large values.

VGLSetVScreenSize(10000, 10000);

() change the origin of the displayed screen in the virtual screen. Note that this function must be called when our vty is in the foreground. object must be VGLDisplay. Passing an in-memory bitmap to this function results in error.

() blank the display if the argument blank ≠ 0. This can be done to shut off the screen during display updates that the user should first see when it's done.

It is important to call VGLEnd() before terminating the program. Care must be taken if you install signal handlers and try to call VGLEnd() and exit(3) to end the program. If a signal is caught while the program is inside libvgl functions, VGLEnd() may not be able to properly restore the graphics hardware.

The recommended way to handle signals and program termination is to have a flag to indicate signal's delivery. Your signal handlers set this flag but do not terminate the program immediately. The main part of the program checks the flag to see if it is supposed to terminate, and calls () and exit(3) if the flag is set.

Note that () installs its internal signal handlers for SIGINT, SIGTERM, SIGSEGV, and SIGBUS, and terminates the program at appropriate time, after one of these signals is caught. If you want to have your own signal handlers for these signals, install handlers VGLInit().

SIGUSR1 and SIGUSR2 are internally used by libvgl to control screen switching and the mouse pointer, and are not available to libvgl client programs.

The vgl library appeared in FreeBSD 3.0.

Søren Schmidt <sos@FreeBSD.org>

November 7, 1999 DragonFly-5.6.1