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