VGL(3)
π VGL(3) β Video Graphics Library functions π
okay bestie, welcome to the Library Functions Manual page for VGL(3) β aka the libvgl glow-up. This is your backstage pass to console-driver graphics, so grab a strawberry drink π and letβs get into it.
β¨ NAME β¨
This page covers the whole function squad: 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, VGLTextSetFontFile β all the Video Graphics Library functions. periodt π
π«Ά LIBRARY π«Ά
Video Graphics Library (libvgl, -lvgl) β yes bestie, thatβs the one. Link it with -lvgl and youβre in business.
π SYNOPSIS π
#include <sys/fbio.h>
#include <sys/consio.h>
#include <sys/kbio.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);
u_long
VGLGetXY(VGLBitmap *object, int x, int y);
void
VGLSetXY(VGLBitmap *object, int x, int y, u_long color);
void
VGLLine(VGLBitmap *object, int x1, int y1, int x2, int y2,
u_long color);
void
VGLBox(VGLBitmap *object, int x1, int y1, int x2, int y2, u_long color);
void
VGLFilledBox(VGLBitmap *object, int x1, int y1, int x2, int y2,
u_long color);
void
VGLEllipse(VGLBitmap *object, int xc, int yc, int a, int b,
u_long color);
void
VGLFilledEllipse(VGLBitmap *object, int xc, int yc, int a, int b,
u_long 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, u_long fgcol,
u_long bgcol, int fill, int dir);
void
VGLBitmapString(VGLBitmap *Object, int x, int y, char *str,
u_long fgcol, u_long bgcol, int fill, int dir);
void
VGLClear(VGLBitmap *object, u_long 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);
π DESCRIPTION π
okay so libvgl is the library that enables a programmer to access the graphics modes supported by the console driver (syscons). It handles programming the actual video hardware for you and gives you a bunch of simple functions to do various graphic operations. Thereβs also mouse support through the standard mouse system in FreeBSD β see mouse(4) β including the ability to transparently have a mouse pointer superimposed on the graphic image youβre currently working on. Screen switching? Handled. The library stores the current image in memory before switching to another virtual console, and restores it when the user switches back. Thatβs how you can have several graphic applications at once, but on different virtual consoles. iconic behavior, honestly π¦
Hereβs the function-by-function rundown, no skips:
VGLInit()β initializes the library and sets up the graphic mode mode. main character energy π₯VGLEnd()β terminates graphic mode and restores the screenmode that was active beforeVGLInit()was called.VGLCheckSwitch()β 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.VGLTextSetFontFile()β instructs the char/string functions to use the font in file filename instead of the builtin font.VGLKeyboardInit()β sets up the keyboard in the βrawβ I/O mode and specifies the key code to be used.codemust beVGL_XLATEKEYS,VGL_CODEKEYS, orVGL_RAWKEYS. WhenVGL_XLATEKEYSis specified, the keyboard translates the raw keyboard scan code into a character code. IfVGL_RAWKEYSis used, the raw keyboard scan code is read as is.VGL_CODEKEYSis 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.VGLKeyboardEnd()β when you have finished using the keyboard, call this function.VGLKeyboardGetCh()β reads 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 returns0.VGLMouseInit()β initializes the mouse. The optional on-screen mouse pointer is shown if the argument isVGL_MOUSESHOW.VGLMouseMode()β either shows the mouse pointer if the argument isVGL_MOUSESHOW, or hides the mouse pointer if the argument isVGL_MOUSEHIDE.VGLMouseStatus()β returns the current mouse pointer coordinates and button state inx,y,buttons. The return value reflects if the mouse pointer is currently shown on screen or not.VGLMouseSetImage()β with this function it is possible to change the image of the mouse pointer on screen.VGLMouseSetStdImage()β this function restores the mouse pointer to the standard arrow.VGLGetXY()β retrieves the color of the pixel located atx,y, coordinates of theobjectargument, and returns it as au_longvalue.VGLSetXY()β sets the color of the pixel located atx,y, coordinates of theobjectargument to coloru_longvalue.VGLLine()β draws a line fromx1,y1tox2,y2in colorcolor.VGLBox()β draws a box with upper left hand corner atx1,y1and lower right hand corner atx2,y2in colorcolor.VGLFilledBox()β draws a filled (solid) box with upper left hand corner atx1,y1and lower right hand corner atx2,y2in colorcolor.VGLEllipse()β draws an ellipse centered atxc,yc, makes itapixels wide, andbpixels high in colorcolor.VGLFilledEllipse()β draws a filled (solid) ellipse centered atxc,yc, makes itapixels wide, andbpixels high in colorcolor.VGLBitmapCreate()β creates a bitmap object and initializes it with the specified values and bit data.typemust beMEMBUFfor the in-memory bitmap.bitsmay beNULLso that bitmap data may be associated later. There also is a macro,VGLBITMAP_INITIALIZER(type, xsize, ysize, bits), to initialize a statically declared bitmap object.VGLBitmapDestroy()β frees the bitmap data and the bitmap object.VGLBitmapAllocateBits()β allocates a bit data buffer for the specifiedobject.VGLBitmapCopy()β copies a rectangle of pixels from bitmapsrcupper left hand corner atsrcx,srcyto bitmapdstatdstx,dstyof the sizewidth,height.VGLBitmapPutChar()β writes the characterchat positionx,yin foreground colorfgcol. Iffillis!= 0, use the colorbgcolas background; otherwise the background is transparent. The character is drawn in the direction specified by the argumentdir.VGLBitmapString()β writes the stringstrat positionx,yin foreground colorfgcol. Iffillis!= 0, use the colorbgcolas background; otherwise the background is transparent. The string is drawn in the direction specified by the argumentdir.VGLClear()β clears the entire bitmap to colorcolor.VGLSetPalette()β this function sets the palette used; the argumentsred,green,blueshould point to byte arrays of 256 positions each.VGLSetPaletteIndex()β sets the palette indexcolorto the specified RGB value.VGLSetBorder()β sets the border color to colorcolor.VGLSetVScreenSize()β changes the virtual screen size of the display. Note: this function must be called when our vty is in the foreground. Andobjectmust beVGLDisplay. 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 underlying 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);
VGLPanScreen()β changes the origin of the displayed screen in the virtual screen. Note: this function must be called when our vty is in the foreground.objectmust beVGLDisplay. Passing an in-memory bitmap to this function results in error.VGLBlankDisplay()β blanks the display if the argumentblankβ0. This can be done to shut off the screen during display updates that the user should first see when it is done.
π Program termination and signal processing π
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 VGLEnd() and exit(3) if the flag is set.
Note thatVGLInit()installs its internal signal handlers forSIGINT,SIGTERM,SIGSEGV, andSIGBUS, 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 afterVGLInit(). π
SIGUSR1 and SIGUSR2 are internally used by libvgl to control screen switching and the mouse pointer, and are not available to libvgl client programs. no cap, those are taken π«
πΈ HISTORY πΈ
The vgl library appeared in FreeBSD 3.0.
π AUTHORS π
SΓΈren Schmidt <sos@FreeBSD.org>
Debian β’ February 25, 2012 β’ VGL(3) β okay bye bestie, go slay some graphics π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 1997 SΓΈren Schmidt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms