Exemplo n.º 1
0
void logotest(void)
{
    int h;
    void *scaled;
    /* Set logo palette. */
    setcustompalette();
    /* Create logo bitmap */
    logobitmap = alloca(LOGOWIDTH * LOGOHEIGHT);
    loadbitmap("linuxlogo.bmp", logobitmap);
    /* Allocate buffer for scaled bitmap. */
    scaled = alloca(WIDTH * HEIGHT);
    gl_clearscreen(0);
    /* Stretch vertically. */
    for (h = 0; h <= LOGOHEIGHT; h++) {
	gl_scalebox(LOGOWIDTH, LOGOHEIGHT, logobitmap,
		    LOGOWIDTH, h, scaled);
	gl_putbox(0, 0, LOGOWIDTH, h, scaled);
	if (VIRTUAL)
	    gl_copyscreen(physicalscreen);
    }
    gl_clearscreen(0);
    /* Scale to screen resolution. */
    gl_scalebox(LOGOWIDTH, LOGOHEIGHT, logobitmap, WIDTH, HEIGHT, scaled);
    gl_putbox(0, 0, WIDTH, HEIGHT, scaled);
    gl_copyscreen(physicalscreen);
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
    vga_init();
    
    if(argc>=2) {
        timescale=atoi(argv[1]);
        if(timescale<1)timescale=1;
    }

    VGAMODE = vga_getdefaultmode();
    if (VGAMODE == -1)
	VGAMODE = G320x200x256;	/* Default mode. */

    if (!vga_hasmode(VGAMODE)) {
	printf("Mode not available.\n");
	exit(-1);
    }
    VIRTUAL = 0;		/* No virtual screen. */
    if (vga_getmodeinfo(VGAMODE)->colors == 16 ||
	(vga_getmodeinfo(VGAMODE)->flags & IS_MODEX))
	/* These modes are supported indirectly by vgagl. */
	VIRTUAL = 1;

    if (VIRTUAL) {
	/* Create virtual screen. */
	gl_setcontextvgavirtual(VGAMODE);
	backscreen = gl_allocatecontext();
	gl_getcontext(backscreen);
    }
    vga_setmode(VGAMODE);
    gl_setcontextvga(VGAMODE);	/* Physical screen context. */
    physicalscreen = gl_allocatecontext();
    gl_getcontext(physicalscreen);
    if (COLORS == 256)
	gl_setrgbpalette();

	if(argc==3)sleep(2);

    test();

    /* Now do the same with clipping enabled. */
    gl_clearscreen(0);
    gl_setclippingwindow(WIDTH / 4, HEIGHT / 4, WIDTH - WIDTH / 4 - 1,
			 HEIGHT - HEIGHT / 4 - 1);

    test();

    gl_disableclipping();
    if (COLORS == 256)
	/* Show the logo if using 256 color mode. */
	logotest();

    getchar();

    if (VIRTUAL)
	gl_freecontext(backscreen);
    vga_setmode(TEXT);
    exit(0);
}
Exemplo n.º 3
0
void blit(void)
{
    gl_clearscreen(0x86);
    vga_imageblt(vga_getgraphmem(), 0, WIDTH - 128, HEIGHT - 128,
		 WIDTH * BYTESPERPIXEL);
/*      vga_bitblt(0, 100 * WIDTH * BYTESPERPIXEL, 50, 50, WIDTH * BYTESPERPIXEL);
   vga_fillblt(100 * BYTESPERPIXEL, 50, 50, WIDTH * BYTESPERPIXEL, 0x86);
 */
}
Exemplo n.º 4
0
int GGI_vgagl_fillscreen(ggi_visual *vis)
{
	if (LIBGGICLIP_FULLSCREEN(vis)) {
		gl_clearscreen(LIBGGI_GC_FGCOLOR(vis));
	} else {
		gl_fillbox(LIBGGI_GC(vis)->cliptl.x, LIBGGI_GC(vis)->cliptl.y,
			   LIBGGI_GC(vis)->clipbr.x - LIBGGI_GC(vis)->cliptl.x,
			   LIBGGI_GC(vis)->clipbr.y - LIBGGI_GC(vis)->cliptl.y,
			   LIBGGI_GC_FGCOLOR(vis));
	}

	return 0;
}
Exemplo n.º 5
0
void initscreen(void)
{
	int vgamode;

	vga_init();

	vgamode = G640x480x16;

	if (!vga_hasmode(vgamode)) {
		printf("Mode not available.\n");
		exit(-1);
	}
	vga_setmode(vgamode);

	/* Create virtual screen. */
	gl_setcontextvgavirtual(vgamode);
	backscreen = gl_allocatecontext();
	gl_getcontext(backscreen);

	/* Physical screen context. */
	vga_setmode(vgamode);
	gl_setcontextvga(vgamode);
	physicalscreen = gl_allocatecontext();
	gl_getcontext(physicalscreen);

	gl_setcontext(backscreen);
	/*drawgraypalette(); */

	gl_clearscreen(0);

//    gl_setcontextvga(vgamode);
	gl_enableclipping();
	gl_setclippingwindow(0, 0, 639, 479);
	gl_setwritemode(WRITEMODE_OVERWRITE | FONT_COMPRESSED);
	gl_setfont(8, 8, gl_font8x8);
	gl_setfontcolors(0, 1);
}
Exemplo n.º 6
0
int main() {
   int maxCols = 1024;
   int maxRows = 768;
   int maxIterations = 2048;
   int maxSize = 4;
   float Xmin = -2.0;
   float Xmax = 1.2;
   float Ymin = -1.2;
   float Ymax = 1.2;
 
   double X, Y;
   double Xsquare, Ysquare;
   double currentP;
   double currentQ[767];
   double deltaP, deltaQ;
   int color;
   int currentRow, currentCol;
 
   deltaP = (Xmax - Xmin)/(double)maxCols;
 
   deltaQ = (Ymax - Ymin)/(double)maxRows;
 
   currentQ[0] = Ymax;
   for (currentRow = 1; currentRow < maxRows; currentRow++) {
      currentQ[currentRow] = currentQ[currentRow-1] - deltaQ;
   }
   currentP = Xmin;
 
   vga_init();
   vga_setmode(G1024x768x256);
   gl_setcontextvga(G1024x768x256);
   physicalscreen = gl_allocatecontext();
   gl_getcontext(physicalscreen);
   gl_setcontextvgavirtual(G1024x768x256);
   virtualscreen = gl_allocatecontext();
   gl_getcontext(virtualscreen);
   gl_setcontext(virtualscreen);
 
   for (currentCol = 0; currentCol < maxCols; currentCol++) {
      for (currentRow = 0; currentRow < maxRows; currentRow++) {
         X = 0.0;
         Y = 0.0;
         Xsquare = 0.0;
         Ysquare = 0.0;
         color = 0;
         while ((color <= maxIterations) && (Xsquare + Ysquare <= maxSize)) {
            Xsquare = X * X;
            Ysquare = Y * Y;
            Y = (2*X*Y) + currentQ[currentRow];
            X = (Xsquare - Ysquare) + currentP;
            color++;
         }
             gl_setpixel(currentCol, currentRow, color % 256);
      }
      currentP = currentP + deltaP;
      gl_copyscreen(physicalscreen);
   }
   vga_getch();
   gl_clearscreen(0);
   vga_setmode(TEXT);
 
   return 0;
}
Exemplo n.º 7
0
int main(int argc, char **argv)
{
	int fd;
	__u32 mode;
	lirc_t data;
	lirc_t x1, y1, x2, y2;
	int result;
	int c = 10;
	char textbuffer[80];
	int div = 5;
	char *device = LIRC_DRIVER_DEVICE;
	char *progname;
	struct stat s;

	progname = "smode2";
	while (1) {
		int c;
		static struct option long_options[] = {
			{"help", no_argument, NULL, 'h'},
			{"version", no_argument, NULL, 'v'},
			{"device", required_argument, NULL, 'd'},
			{"timediv", required_argument, NULL, 't'},
			{0, 0, 0, 0}
		};
		c = getopt_long(argc, argv, "hvd:t:", long_options, NULL);
		if (c == -1)
			break;
		switch (c) {
		case 'h':
			printf("Usage: %s [options]\n", progname);
			printf("\t -h --help\t\tdisplay usage summary\n");
			printf("\t -v --version\t\tdisplay version\n");
			printf("\t -d --device=device\tread from given device\n");
			printf("\t -t --timediv=value\tms per unit\n");
			return (EXIT_SUCCESS);
		case 'v':
			printf("%s %s\n", progname, VERSION);
			return (EXIT_SUCCESS);
		case 'd':
			device = optarg;
			break;
		case 't':	/* timediv */
			div = strtol(optarg, NULL, 10);
			break;
		default:
			printf("Usage: %s [options]\n", progname);
			return (EXIT_FAILURE);
		}
	}
	if (optind < argc - 1) {
		fprintf(stderr, "%s: too many arguments\n", progname);
		return (EXIT_FAILURE);
	}

	fd = open(device, O_RDONLY);
	if (fd == -1) {
		perror(progname);
		fprintf(stderr, "%s: error opening %s\n", progname, device);
		exit(EXIT_FAILURE);
	};
	if ((fstat(fd, &s) != -1) && (S_ISFIFO(s.st_mode))) {
		/* can't do ioctls on a pipe */
	} else if (ioctl(fd, LIRC_GET_REC_MODE, &mode) == -1 || mode != LIRC_MODE_MODE2) {
		printf("This program is only intended for receivers supporting the pulse/space layer.\n");
		printf("Note that this is no error, but this program simply makes no sense for your\nreceiver.\n");
		printf("In order to test your setup run lircd with the "
		       "--nodaemon option and \n" "then check if the remote works with the irw tool.\n");
		close(fd);
		exit(EXIT_FAILURE);
	}

	initscreen();

	y1 = 20;
	x1 = x2 = 0;
	for (y2 = 0; y2 < 640; y2 += 20)
		gl_line(y2, 0, y2, 480, 1);
	sprintf(textbuffer, "%d ms/unit", div);
	gl_write(500, 10, textbuffer);
	gl_copyscreen(physicalscreen);

	while (1) {
		result = read(fd, &data, sizeof(data));
		if (result == sizeof(data)) {
//                  printf("%.8lx\t",(unsigned long) data);
			x2 = (data & PULSE_MASK) / (div * 50);
			if (x2 > 400) {
				y1 += 15;
				x1 = 0;
				gl_copyscreen(physicalscreen);
			} else {
				if (x1 < 640) {
					gl_line(x1, ((data & PULSE_BIT) ? y1 : y1 + 10), x1 + x2,
						((data & PULSE_BIT) ? y1 : y1 + 10), c);
					x1 += x2;
					gl_line(x1, ((data & PULSE_BIT) ? y1 : y1 + 10), x1,
						((data & PULSE_BIT) ? y1 + 10 : y1), c);
				}
			}
			if (y1 > 480) {
				y1 = 20;
				gl_clearscreen(0);
				for (y2 = 0; y2 < 640; y2 += 10)
					gl_line(y2, 0, y2, 480, 1);
				gl_write(500, 10, textbuffer);
			}
		}
//              gl_copyscreen(physicalscreen);
	};
	closescreen();
	exit(EXIT_SUCCESS);
}
Exemplo n.º 8
0
void test(void)
{
    int i, j;
    unsigned char *bitmap;
    GraphicsContext *savedcontext;

    if (VIRTUAL)
	gl_setcontext(backscreen);

    gl_clearscreen(0);
    for (i = 0; i < 5; i++) {
	gl_clearscreen(0);
	for (j = 0; j < 20000; j++)
	    gl_setpixel(random() % WIDTH, random() % HEIGHT,
			random() % COLORS);
    }

    if (VIRTUAL)
	gl_copyscreen(physicalscreen);

    gl_clearscreen(0);
    for (i = 0; i < 5000; i++) {
	int x, y;
	x = random() % (WIDTH - 1);
	y = random() % (HEIGHT - 1);
	gl_fillbox(x, y, random() % (WIDTH - x), random()
		   % (HEIGHT - y), random() % COLORS);
    }

    if (VIRTUAL)
	gl_copyscreen(physicalscreen);

    gl_clearscreen(0);
    for (i = 0; i < 4000; i++)
	gl_line(random() % WIDTH, random() % HEIGHT,
		random() % WIDTH, random() % HEIGHT,
		random() % COLORS);

    if (VIRTUAL)
	gl_copyscreen(physicalscreen);

    /* Create bitmap. */
    bitmap = malloc(64 * 64 * BYTESPERPIXEL);
    /* Create temporary graphics context to create bitmap in. */
    savedcontext = gl_allocatecontext();
    gl_getcontext(savedcontext);
    gl_setcontextvirtual(64, 64, BYTESPERPIXEL, BITSPERPIXEL, bitmap);
    /* The rgb functions can be used to create nice bitmaps easily for */
    /* hicolor/truecolor modes. The 256 color 'emulated' truecolor */
    /* looks less impressive. */
    for (i = 0; i < 32; i++)
	for (j = 0; j < 32; j++) {
	    int c;
	    c = 255 - (i + j) * 4;
	    gl_setpixelrgb(31 - i, 31 - j, c, 0, 0);
	    gl_setpixelrgb(32 + i, 31 - j, c, c, 0);
	    gl_setpixelrgb(31 - i, 32 + j, c, 0, c);
	    gl_setpixelrgb(32 + i, 32 + j, c, c, c);
	}
    /* Restore previous context. */
    gl_setcontext(savedcontext);

    gl_clearscreen(0);
    for (i = 0; i < 4000; i++) {
	int x, y;
	x = random() % (WIDTH - 64 + 1);
	y = random() % (HEIGHT - 64 + 1);
	gl_putbox(x, y, 64, 64, bitmap);
    }

    free(bitmap);

    if (VIRTUAL)
	gl_copyscreen(physicalscreen);
}