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);
}
示例#2
0
文件: hzinput.c 项目: descent/jmcce
void
BarMenu (int xmax, int ymax, int leftmar, int stepwidth)
{

  int ii, jj;
  int lastx, lasty;
  int key1, key2;
  int i;
  int ok_flag = 0;



  ClrSelArea ();

  if (gEncode == BIG5) {
    input_print_string (0, 1, "請選擇->", LIGHTBAR_MESSAGE, INPUT_BGCOLOR);
  }

  if (gEncode == GB) {
    input_print_string (0, 1, string_BIG5toGB ("請選擇->"), LIGHTBAR_MESSAGE,
			INPUT_BGCOLOR);
  }

  for (jj = 1; jj <= xmax; jj++)
    for (ii = 1; ii <= ymax; ii++) {
      chinese_bar (jj, ii, leftmar, stepwidth,
		   Item_attr[jj] == 1 ? NORMAL : NORMALDISABLE,
		   Item_str[jj][ii]);
    }

  chinese_bar (mx, my, leftmar, stepwidth,
	       Item_attr[mx] == 1 ? REVERSE : REVERSEDISABLE,
	       Item_str[mx][my]);

  #ifdef VGALIB
  gl_copyscreen(physical_screen);
  #endif

  initscr ();
  noecho ();
  keypad (stdscr, TRUE);


  while (ok_flag == 0) {

    key2 = getch ();
    lastx = mx;
    lasty = my;
    switch (key2) {

    case KEY_HOME:
      mx = 1;
      my = 1;
      break;
    case KEY_END:
      mx = xmax;
      my = ymax;
      break;
    case KEY_UP:
      Up (xmax, ymax);
      break;
    case KEY_LEFT:
      BarLeft (xmax, ymax, leftmar, stepwidth);
      break;
    case KEY_RIGHT:
      BarRight (xmax, ymax, leftmar, stepwidth);
      break;
    case KEY_DOWN:
      Dn (xmax, ymax);
      break;
    case 10:
    case 13:
    case KEY_ENTER:
      ok_flag = 1;
      ClrSelArea ();
      if (mx == 10 && gItem_disp_off == 0) {
	set_active_input_method (0);
      } else {
	set_active_input_method (mx + gItem_disp_off);
      }
      break;
    case 200:
    case 201:
    case 202:
    case 203:
    case 204:
    case 205:
    case 206:
    case 207:
    case 208:
    case 209:
      ok_flag = 1;
      ClrSelArea ();
      if (key2 - 200 == 0) {
	mx = 10;
	my = 1;
	set_active_input_method (0);
      } else {
	mx = key2 - 200;
	my = 1;
	set_active_input_method (mx);
      }
      BarMenuInit (10, 1);
      BarMenu (10, 1, 8, 6);
      break;
    default:
      ok_flag = 1;
      ClrSelArea ();
      if (mx == 10 && gItem_disp_off == 0) {
	set_active_input_method (0);
      } else {
	set_active_input_method (mx + gItem_disp_off);
      }

      hz_filter (hztty_list->tty_fd, key2);
      break;
    }

    if (ok_flag == 1) {
      break;
    }



    chinese_bar (mx, my, leftmar, stepwidth,
		 Item_attr[mx] == 1 ? REVERSE : REVERSEDISABLE,
		 Item_str[mx][my]);

    if (!(lasty == my && lastx == mx)) {
      chinese_bar (lastx, lasty, leftmar, stepwidth,
		   Item_attr[lastx] == 1 ? NORMAL : NORMALDISABLE,
		   Item_str[lastx][lasty]);
    }
    #ifdef VGALIB
    gl_copyscreen(physical_screen);
    #endif


  }

  keypad (stdscr, FALSE);

}
示例#3
0
文件: mandel-svga.c 项目: palmerc/lab
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;
}
示例#4
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);
}
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);
}
示例#6
0
文件: gr.c 项目: Ringdingcoder/d1x
void gr_update()
{
	if (usebuffer)
		gl_copyscreen(physicalscreen);
}