void screen1(void) { int x, y; for (y = 0; y < HEIGHT; y++) for (x = 0; x < WIDTH; x++) /* limited RGB palette in 256-color modes */ /* some color information is not used in */ /* 15-bit color modes */ gl_setpixelrgb(x, y, x * 256 / WIDTH, 255 - x * 256 / WIDTH, y * 256 / HEIGHT); }
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); }