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