1.\" Copyright (c) 1997 S�ren Schmidt 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer, 9.\" in this position and unchanged. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 3. The name of the author may not be used to endorse or promote products 14.\" derived from this software withough specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26.\" 27.\" $FreeBSD$ 28.Dd November 7, 1999 29.Dt VGL 3 30.Os FreeBSD 3.0 31.Sh NAME 32.Nm VGLBitmapAllocateBits , 33.Nm VGLBitmapCopy , 34.Nm VGLBitmapCreate , 35.Nm VGLBitmapDestroy , 36.Nm VGLBitmapPutChar , 37.Nm VGLBitmapString , 38.Nm VGLBlankDisplay , 39.Nm VGLBox , 40.Nm VGLCheckSwitch , 41.Nm VGLClear , 42.Nm VGLEllipse , 43.Nm VGLEnd , 44.Nm VGLFilledBox , 45.Nm VGLFilledEllipse , 46.Nm VGLGetXY , 47.Nm VGLInit , 48.Nm VGLLine , 49.Nm VGLKeyboardInit , 50.Nm VGLKeyboardEnd , 51.Nm VGLKeyboardGetCh , 52.Nm VGLMouseInit , 53.Nm VGLMouseMode , 54.Nm VGLMouseSetImage , 55.Nm VGLMouseSetStdImage , 56.Nm VGLMouseStatus , 57.Nm VGLPanScreen , 58.Nm VGLSetBorder , 59.Nm VGLSetPalette , 60.Nm VGLSetPaletteIndex , 61.Nm VGLSetVScreenSize , 62.Nm VGLSetXY , 63.Nm VGLTextSetFontFile 64.Nd Video Graphics Library functions (libvgl) 65.Sh SYNOPSIS 66.Fd #include <machine/console.h> 67.Fd #include <vgl.h> 68.Ft int 69.Fn VGLInit "int mode" 70.Ft void 71.Fn VGLEnd "void" 72.Ft void 73.Fn VGLCheckSwitch "void" 74.Ft int 75.Fn VGLTextSetFontFile "char *filename" 76.Ft int 77.Fn VGLKeyboardInit "int code" 78.Ft void 79.Fn VGLKeyboardEnd "void" 80.Ft int 81.Fn VGLKeyboardGetCh "void" 82.Ft int 83.Fn VGLMouseInit "int mode" 84.Ft void 85.Fn VGLMouseMode "int mode" 86.Ft int 87.Fn VGLMouseStatus "int *x" "int *y" "char *buttons" 88.Ft void 89.Fn VGLMouseSetImage "VGLBitmap *AndMask" "VGLBitmap *OrMask" 90.Ft void 91.Fn VGLMouseSetStdImage "void" 92.Ft byte 93.Fn VGLGetXY "VGLBitmap *object" "int x" "int y" 94.Ft void 95.Fn VGLSetXY "VGLBitmap *object" "int x" "int y" "byte color" 96.Ft void 97.Fn VGLLine "VGLBitmap *object" "int x1" "int y1" "int x2" "int y2" "byte color" 98.Ft void 99.Fn VGLBox "VGLBitmap *object" "int x1" "int y1" "int x2" "int y2" "byte color" 100.Ft void 101.Fn VGLFilledBox "VGLBitmap *object" "int x1" "int y1" "int x2" "int y2" "byte color" 102.Ft void 103.Fn VGLEllipse "VGLBitmap *object" "int xc" "int yc" "int a" "int b" "byte color" 104.Ft void 105.Fn VGLFilledEllipse "VGLBitmap *object" "int xc" "int yc" "int a" "int b" "byte color" 106.Ft VGLBitmap * 107.Fn VGLBitmapCreate "int type" "int xsize" "int ysize" "byte *bits" 108.Ft void 109.Fn VGLBitmapDestroy "VGLBitmap *object" 110.Ft int 111.Fn VGLBitmapAllocateBits "VGLBitmap *object" 112.Ft int 113.Fn VGLBitmapCopy "VGLBitmap *src" "int srcx" "int srcy" "VGLBitmap *dst" "int dstx" "int dsty" "int width" "int hight" 114.Ft void 115.Fn VGLBitmapPutChar "VGLBitmap *Object" "int x" "int y" "byte ch" "byte fgcol" "byte bgcol" "int fill" "int dir" 116.Ft void 117.Fn VGLBitmapString "VGLBitmap *Object" "int x" "int y" "char *str" "byte fgcol" "byte bgcol" "int fill" "int dir" 118.Ft void 119.Fn VGLClear "VGLBitmap *object" "byte color" 120.Ft void 121.Fn VGLSetPalette "byte *red" "byte *green" "byte *blue" 122.Ft void 123.Fn VGLSetPaletteIndex "byte color" "byte red" "byte green" "byte blue" 124.Ft void 125.Fn VGLSetBorder "byte color" 126.Ft int 127.Fn VGLSetVScreenSize "VGLBitmap *object" "int vxsize" "int vysize" 128.Ft int 129.Fn VGLPanScreen "VGLBitmap *object" "int x" "int y" 130.Ft void 131.Fn VGLBlankDisplay "int blank" 132.Sh DESCRIPTION 133.Nm Libvgl 134is a library that enables the programmer access to the graphics 135modes supported by the console driver (syscons). The library takes care of 136programming the actual video hardware, and provides a number of simple 137functions to do various graphic operations. There is also support for a 138mouse via the standard mouse system in 139.Fx , 140see 141.Xr mouse 4 , 142including the ability to transparently have a mouse pointer superimposed on 143the graphic image currently being worked on. 144The library takes care of screen switching by storing the current image in 145memory before switching to another virtual console, and restoring when the 146user switches back. This allows several graphic applications at once, but 147on different virtual consoles. 148 149Below is a short description of the various functions: 150.Pp 151.Fn VGLInit 152initialize the library and set up the graphic mode 153.Va mode . 154.Pp 155.Fn VGLEnd 156terminate graphic mode, and restore the screenmode that was active before 157.Fn VGLInit 158was called. 159.Pp 160.Fn VGLCheckSwitch 161if the program goes into longer periods of processing without doing 162any graphics output, calling this function occasionally will allow 163the system to switch screens. 164.Pp 165.Fn VGLTextSetFontFile 166instruct the char/string functions to use the font in file 167.Pa filename 168instead of the builtin font. 169.Pp 170.Fn VGLKeyboardInit 171set up the keyboard in the 172.Dq raw 173I/O mode and 174specify the key code to be used. 175.Va code 176must be 177.Dv VGL_XLATEKEYS , 178.Dv VGL_CODEKEYS , 179or 180.Dv VGL_RAWKEYS . 181When 182.Dv VGL_XLATEKEYS 183is specified, the keyboard translate the raw keyboard scan code into 184a character code. 185If 186.Dv VGL_RAWKEYS 187is used, the raw keyboard scan code is read as is. 188.Dv VGL_CODEKEYS 189is the intermediate key code; each key is assigned a unique code whereas 190more than one raw scan code may be generated when a key is pressed. 191.Pp 192.Fn VGLKeyboardEnd 193when you have finished using the keyboard, call this function. 194.Pp 195.Fn VGLKeyboardGetCh 196read one byte from the keyboard. As the keyboard I/O is in the 197.Dq raw 198input mode, the function will not block even if there is no input data, 199and returns 0. 200.Pp 201.Fn VGLMouseInit 202initialize the mouse. The optional on-screen mouse pointer is shown if the 203argument is 204.Dv VGL_MOUSESHOW . 205.Pp 206.Fn VGLMouseMode 207either shows the mouse pointer if the argument is 208.Dv VGL_MOUSESHOW , 209or hides the mouse pointer if the argument is 210.Dv VGL_MOUSEHIDE . 211.Pp 212.Fn VGLMouseStatus 213returns the current mouse pointer coordinates and button state in 214.Va x , y , 215buttons. The return value reflects if the mouse pointer 216is currently shown on screen or not. 217.Pp 218.Fn VGLMouseSetImage 219with this function it is possible to change the image of the mouse pointer 220on screen. 221.Pp 222.Fn VGLMouseSetStdImage 223this function restores the mouse pointer to the standard arrow. 224.Pp 225.Fn VGLGetXY 226retrieves the color of the pixel located at 227.Va x , y , 228coordinates of the 229.Va object 230argument, and returns it as a byte value. 231.Pp 232.Fn VGLSetXY 233sets the color of the pixel located at 234.Va x , y , 235coordinates of the 236.Va object 237argument to 238.Va color 239byte value. 240.Pp 241.Fn VGLLine 242draw a line from 243.Va x1 , y1 244to 245.Va x2 , y2 246in color 247.Va color . 248.Pp 249.Fn VGLBox 250draw a box with upper left hand corner at 251.Va x1 , y1 252and lower right hand corner at 253.Va x2 , y2 254in color 255.Va color . 256.Pp 257.Fn VGLFilledBox 258draw a filled (solid) box with upper left hand corner at 259.Va x1 , y1 260and lower right hand corner at 261.Va x2 , y2 262in color 263.Va color . 264.Pp 265.Fn VGLEllipse 266draw an ellipse centered at 267.Va xc , yc 268make it 269.Va a 270pixels wide, and 271.Va b 272pixels high in color 273.Va color . 274.Pp 275.Fn VGLFilledEllipse 276draw a filled (solid) ellipse centered at 277.Va xc , yc 278make it 279.Va a 280pixels wide, and 281.Va b 282pixels high in color 283.Va color . 284.Pp 285.Fn VGLBitmapCreate 286create a bitmap object and initialize it with the specified 287values and bit data. 288.Va type 289must be 290.Dv MEMBUF 291for the in-memory bitmap. 292.Va bits 293may be NULL so that bitmap data may be associated later. 294.Pp 295There also is a macro, 296.Fn VGLBITMAP_INITIALIZER "type" "xsize" "ysize" "bits" 297to initialize a statically declared bitmap object. 298.Pp 299.Fn VGLBitmapDestroy 300free the bitmap data and the bitmap object. 301.Pp 302.Fn VGLBitmapAllocateBits 303allocate a bit data buffer for the specified object. 304.Pp 305.Fn VGLBitmapCopy 306copy a rectangle of pixels from bitmap 307.Va src 308upper left hand corner at 309.Va srcx , srcy 310to bitmap 311.Va dst 312at 313.Va dstx , dsty 314of the size 315.Va width , height . 316.Pp 317.Fn VGLBitmapPutChar 318write the character 319.Va ch 320at position 321.Va x , y 322in foreground color 323.Va fgcol . 324If 325.Va fill 326is != 0, use the color 327.Va bgcol 328as background otherwise the background is transparent. 329The character is drawn in the direction specified by the argument 330.Va dir . 331.Pp 332.Fn VGLBitmapString 333write the string 334.Va str 335at position 336.Va x , y 337in foreground color 338.Va fgcol . 339If 340.Va fill 341is != 0, use the color 342.Va bgcol 343as background otherwise the background is transparent. 344The string is drawn in the direction specified by the argument 345.Va dir . 346.Pp 347.Fn VGLClear 348clears the entire bitmap to color 349.Va color . 350.Pp 351.Fn VGLSetPalette 352this function sets the palette used, the arguments 353.Va red , green , blue 354should point to byte arrays of 256 positions each. 355.Pp 356.Fn VGLSetPaletteIndex 357set the palette index 358.Va color 359to the specified RGB value. 360.Pp 361.Fn VGLSetBorder 362set the border color to color 363.Va color . 364.Pp 365.Fn VGLSetVScreenSize 366change the virtual screen size of the display. Note that this 367function must be called when our vty is in the foreground. 368And 369.Va object 370must be 371.Va VGLDisplay . 372Passing a in-memory bitmap to this function results in error. 373.Pp 374The desired virtual screen width may not be achievable because 375of the video card hardware. In such case the video driver (and 376underlaying video BIOS) may choose the next largest values. 377Always examine 378.Va object->VXsize 379and 380.Va VYsize 381after calling this function, in order to see how the virtual screen 382is actually set up. 383.Pp 384In order to set up the largest possible virtual screen, you may 385call this function with arbitrary large values. 386.Pp 387.Dl VGLSetVScreenSize(10000, 10000); 388.Pp 389.Fn VGLPanSreen 390change the origin of the displayed screen in the virtual screen. 391Note that this function must be called when our vty is in the 392foreground. 393.Va object 394must be 395.Va VGLDisplay . 396Passing a in-memory bitmap to this function results in error. 397.Pp 398.Fn VGLBlankDisplay 399blank the display if the argment 400.Va blank 401!= 0. This can be done to shut off the screen during display updates that 402the user should first see when it's done. 403.Sh AUTHORS 404.An S�ren Schmidt Aq sos@FreeBSD.org 405.Sh HISTORY 406The 407.Nm vgl 408library appeared in 409.Fx 3.0 . 410