/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 1991-1997 Søren Schmidt4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer11* in this position and unchanged.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15* 3. The name of the author may not be used to endorse or promote products16* derived from this software without specific prior written permission17*18* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR19* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES20* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.21* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,22* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT23* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,24* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY25* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF27* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.28*/2930#include <sys/types.h>31#include <sys/fbio.h>32#include <sys/kbio.h>33#include <sys/consio.h>34#include <vgl.h>3536int37main(int argc, char **argv)38{39int y, xsize, ysize, i,j;40VGLBitmap *tmp;4142// set graphics mode, here 320x240 256 colors43// supported modes are (from <sys/consio.h>):44// SW_VGA_CG320: std VGA 320x200 256 colors45// SW_VGA_MODEX: Modex VGA 320x240 256 colors46// SW_VGA_VG640: std VGA 640x480 16 colors47VGLInit(SW_VGA_MODEX);4849// initialize mouse and show pointer50VGLMouseInit(VGL_MOUSESHOW);5152// VGLDisplay is a ptr to a struct Bitmap defined and initialized by53// libvgl. The Bitmap points directly to screen memory etc.54xsize=VGLDisplay->Xsize;55ysize=VGLDisplay->Ysize;5657// alloc a new bitmap58tmp = VGLBitmapCreate(MEMBUF, 256, 256, NULL);59VGLBitmapAllocateBits(tmp);60VGLClear(tmp, 0);6162// fill the screen with colored lines63for (y=0; y<ysize; y++)64VGLLine(VGLDisplay, 0, y, xsize-1, y, y/2 % 256);6566// draw some lines and circles just to show off67VGLLine(VGLDisplay, 0, 0, xsize-1, ysize-1, 63);68VGLLine(VGLDisplay, 0, ysize-1, xsize-1, 0, 63);69VGLLine(VGLDisplay, 0, 0, 0, ysize-1, 63);70VGLLine(VGLDisplay, xsize-1, 0, xsize-1, ysize-1, 63);71VGLEllipse(VGLDisplay, 256, 0, 256, 256, 63);72VGLEllipse(VGLDisplay, 0, 256, 256, 256, 0);7374// some text is also useful75VGLBitmapString(VGLDisplay, 100,100,76"This is text", 63, 0, 0, VGL_DIR_RIGHT);77sleep(2);78VGLBitmapString(VGLDisplay, 100,100,79"This is text", 63, 0, 0, VGL_DIR_UP);80sleep(2);81VGLBitmapString(VGLDisplay, 100,100,82"This is text", 63, 0, 0, VGL_DIR_LEFT);83sleep(2);84VGLBitmapString(VGLDisplay, 100,100,85"This is text", 63, 0, 0, VGL_DIR_DOWN);86sleep(2);8788// now show some simple bitblit89for (i=0; i<256; i++)90for (j=0; j<256; j++)91tmp->Bitmap[i+256*j] = i%16;92VGLBitmapCopy(tmp, 0, 0, VGLDisplay, 0, 0, 128, 128);93for (i=0; i<256; i++)94for (j=0; j<256; j++)95tmp->Bitmap[i+256*j] = j%16;96VGLBitmapCopy(tmp, 0, 0, VGLDisplay, 3, 128, 128, 128);97sleep(2);98VGLBitmapCopy(VGLDisplay, 237, 311, tmp, 64, 64, 128, 128);99VGLBitmapCopy(tmp, 32, 32, VGLDisplay, 400, 128, 128, 128);100sleep(2);101VGLBitmapCopy(VGLDisplay, 300, 300, VGLDisplay, 500, 128, 128, 128);102sleep(5);103i=0;104105// loop around drawing and copying106while (++i) {107VGLBitmapCopy(VGLDisplay, rand()%xsize, rand()%ysize,108VGLDisplay, rand()%xsize, rand()%ysize,109rand()%xsize, rand()%ysize);110VGLLine(VGLDisplay, rand()%xsize, rand()%ysize,111rand()%xsize, rand()%ysize, rand()%256);112VGLEllipse(VGLDisplay, rand()%xsize, rand()%ysize,113rand()%xsize/2, rand()%ysize/2, rand()%256);114rand();115if (i > 1000) break;116}117118// restore screen to its original mode119VGLEnd();120return 0;121}122123124