1997-10-16 07:29:26 +00:00
|
|
|
/*-
|
2011-05-22 14:03:21 +00:00
|
|
|
* Copyright (c) 1991-1997 Søren Schmidt
|
1997-10-16 07:29:26 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer
|
|
|
|
* in this position and unchanged.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
2002-06-02 20:05:59 +00:00
|
|
|
* derived from this software without specific prior written permission
|
1997-10-16 07:29:26 +00:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
1999-08-28 00:22:10 +00:00
|
|
|
* $FreeBSD$
|
1997-10-16 07:29:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2000-10-08 21:34:00 +00:00
|
|
|
#include <sys/fbio.h>
|
|
|
|
#include <sys/kbio.h>
|
|
|
|
#include <sys/consio.h>
|
1999-12-14 08:47:42 +00:00
|
|
|
#include <vgl.h>
|
1997-10-16 07:29:26 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
1999-12-14 08:47:42 +00:00
|
|
|
int y, xsize, ysize, i,j;
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLBitmap *tmp;
|
1997-10-16 07:29:26 +00:00
|
|
|
|
|
|
|
// set graphics mode, here 320x240 256 colors
|
2000-10-08 21:34:00 +00:00
|
|
|
// supported modes are (from <sys/consio.h>):
|
2011-05-22 14:03:21 +00:00
|
|
|
// SW_VGA_CG320: std VGA 320x200 256 colors
|
|
|
|
// SW_VGA_MODEX: Modex VGA 320x240 256 colors
|
|
|
|
// SW_VGA_VG640: std VGA 640x480 16 colors
|
1997-10-16 07:29:26 +00:00
|
|
|
VGLInit(SW_VGA_MODEX);
|
|
|
|
|
|
|
|
// initialize mouse and show pointer
|
|
|
|
VGLMouseInit(VGL_MOUSESHOW);
|
|
|
|
|
2011-05-22 14:03:21 +00:00
|
|
|
// VGLDisplay is a ptr to a struct Bitmap defined and initialized by
|
1997-10-16 07:29:26 +00:00
|
|
|
// libvgl. The Bitmap points directly to screen memory etc.
|
|
|
|
xsize=VGLDisplay->Xsize;
|
|
|
|
ysize=VGLDisplay->Ysize;
|
|
|
|
|
1999-11-08 11:37:46 +00:00
|
|
|
// alloc a new bitmap
|
|
|
|
tmp = VGLBitmapCreate(MEMBUF, 256, 256, NULL);
|
|
|
|
VGLBitmapAllocateBits(tmp);
|
|
|
|
VGLClear(tmp, 0);
|
1997-10-16 07:29:26 +00:00
|
|
|
|
|
|
|
// fill the screen with colored lines
|
2011-05-22 14:03:21 +00:00
|
|
|
for (y=0; y<ysize; y++)
|
1997-10-16 07:29:26 +00:00
|
|
|
VGLLine(VGLDisplay, 0, y, xsize-1, y, y/2 % 256);
|
|
|
|
|
|
|
|
// draw some lines and circles just to show off
|
|
|
|
VGLLine(VGLDisplay, 0, 0, xsize-1, ysize-1, 63);
|
|
|
|
VGLLine(VGLDisplay, 0, ysize-1, xsize-1, 0, 63);
|
|
|
|
VGLLine(VGLDisplay, 0, 0, 0, ysize-1, 63);
|
|
|
|
VGLLine(VGLDisplay, xsize-1, 0, xsize-1, ysize-1, 63);
|
|
|
|
VGLEllipse(VGLDisplay, 256, 0, 256, 256, 63);
|
|
|
|
VGLEllipse(VGLDisplay, 0, 256, 256, 256, 0);
|
|
|
|
|
2011-05-22 14:03:21 +00:00
|
|
|
// some text is also useful
|
1997-10-16 07:29:26 +00:00
|
|
|
VGLBitmapString(VGLDisplay, 100,100,
|
|
|
|
"This is text", 63, 0, 0, VGL_DIR_RIGHT);
|
|
|
|
sleep(2);
|
|
|
|
VGLBitmapString(VGLDisplay, 100,100,
|
|
|
|
"This is text", 63, 0, 0, VGL_DIR_UP);
|
|
|
|
sleep(2);
|
|
|
|
VGLBitmapString(VGLDisplay, 100,100,
|
|
|
|
"This is text", 63, 0, 0, VGL_DIR_LEFT);
|
|
|
|
sleep(2);
|
|
|
|
VGLBitmapString(VGLDisplay, 100,100,
|
|
|
|
"This is text", 63, 0, 0, VGL_DIR_DOWN);
|
|
|
|
sleep(2);
|
|
|
|
|
2011-05-22 14:03:21 +00:00
|
|
|
// now show some simple bitblit
|
1997-10-16 07:29:26 +00:00
|
|
|
for (i=0; i<256; i++)
|
|
|
|
for (j=0; j<256; j++)
|
1999-11-08 11:37:46 +00:00
|
|
|
tmp->Bitmap[i+256*j] = i%16;
|
|
|
|
VGLBitmapCopy(tmp, 0, 0, VGLDisplay, 0, 0, 128, 128);
|
1997-10-16 07:29:26 +00:00
|
|
|
for (i=0; i<256; i++)
|
|
|
|
for (j=0; j<256; j++)
|
1999-11-08 11:37:46 +00:00
|
|
|
tmp->Bitmap[i+256*j] = j%16;
|
|
|
|
VGLBitmapCopy(tmp, 0, 0, VGLDisplay, 3, 128, 128, 128);
|
1997-10-16 07:29:26 +00:00
|
|
|
sleep(2);
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLBitmapCopy(VGLDisplay, 237, 311, tmp, 64, 64, 128, 128);
|
|
|
|
VGLBitmapCopy(tmp, 32, 32, VGLDisplay, 400, 128, 128, 128);
|
1997-10-16 07:29:26 +00:00
|
|
|
sleep(2);
|
|
|
|
VGLBitmapCopy(VGLDisplay, 300, 300, VGLDisplay, 500, 128, 128, 128);
|
|
|
|
sleep(5);
|
|
|
|
i=0;
|
|
|
|
|
|
|
|
// loop around drawing and copying
|
|
|
|
while (++i) {
|
|
|
|
VGLBitmapCopy(VGLDisplay, rand()%xsize, rand()%ysize,
|
2011-05-22 14:03:21 +00:00
|
|
|
VGLDisplay, rand()%xsize, rand()%ysize,
|
|
|
|
rand()%xsize, rand()%ysize);
|
1997-10-16 07:29:26 +00:00
|
|
|
VGLLine(VGLDisplay, rand()%xsize, rand()%ysize,
|
|
|
|
rand()%xsize, rand()%ysize, rand()%256);
|
|
|
|
VGLEllipse(VGLDisplay, rand()%xsize, rand()%ysize,
|
2011-05-22 14:03:21 +00:00
|
|
|
rand()%xsize/2, rand()%ysize/2, rand()%256);
|
1997-10-16 07:29:26 +00:00
|
|
|
rand();
|
|
|
|
if (i > 1000) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// restore screen to its original mode
|
|
|
|
VGLEnd();
|
|
|
|
return 0;
|
|
|
|
}
|