static void gl_ggiClear(GLcontext *ctx, GLbitfield mask) { ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; int x = ctx->DrawBuffer->_Xmin; int y = ctx->DrawBuffer->_Ymin; int w = ctx->DrawBuffer->_Xmax - x; int h = ctx->DrawBuffer->_Ymax - y; GLboolean all = (w == ctx->DrawBuffer->Width && h == ctx->DrawBuffer->height) GGIMESADPRINT_CORE("gl_ggiClear() called\n"); if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) { ggiSetGCForeground(ggi_ctx->ggi_visual, ggi_ctx->clearcolor); if (all) { int w, h; w = LIBGGI_VIRTX(ggi_ctx->ggi_visual); h = LIBGGI_VIRTX(ggi_ctx->ggi_visual); ggiDrawBox(ggi_ctx->ggi_visual, 0, 0, w, h); } else { ggiDrawBox(ggi_ctx->ggi_visual, x, y, //FLIP(y), width, height); } ggiSetGCForeground(ggi_ctx->ggi_visual, ggi_ctx->color); mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT); } _swrast_Clear(ctx, mask); }
int draw_window(struct window * w) { int i; /* clear background */ ggiSetGCForeground(w->vis, ggiMapColor(w->vis,&w->backgroundcolor)); ggiDrawBox(w->vis, w->xorigin, w->yorigin, w->xsize, w->ysize); /* draw border */ ggiSetGCForeground(w->vis, ggiMapColor(w->vis,&w->bordercolor)); for (i = w->borderwidth; i > 0; i--){ /*printf("border %d\n", i);*/ ggiDrawHLine(w->vis, w->xorigin, w->yorigin+i-1, w->xsize); ggiDrawHLine(w->vis, w->xorigin, w->yorigin+w->ysize-i, w->xsize); ggiDrawVLine(w->vis, w->xorigin+i-1, w->yorigin, w->ysize); ggiDrawVLine(w->vis, w->xorigin+w->xsize-i, w->yorigin, w->ysize); } ggiSetGCForeground(w->vis, ggiMapColor(w->vis,&w->titlecolor)); ggiSetGCBackground(w->vis, ggiMapColor(w->vis,&w->backgroundcolor)); ggiPuts(w->vis, w->xorigin+10, w->yorigin+/*2*/0, w->title); return 0; }
static void testcase1(const char *desc) { ggi_visual_t vis; ggi_color green, back; int err; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; err = ggiInit(); printassert(err == GGI_OK, "ggiInit failed with %i\n", err); vis = ggiOpen(NULL); printassert(vis != NULL, "ggiOpen() failed\n"); err = ggiSetGraphMode(vis, GGI_AUTO, GGI_AUTO, GGI_AUTO, GGI_AUTO, GT_8BIT); if(err < 0) { printassert(0, "Palettized mode not available.\n"); printsuccess(); ggiClose(vis); ggiExit(); return; } green.r = 100; green.g = 40000; green.b = 4000; err = ggiSetPalette(vis, GGI_PALETTE_DONTCARE, 1, &green); if (err < 0) { printfailure("Unable to install colormap with one entry.\n"); ggiClose(vis); ggiExit(); return; } printassert(err == (int)ggiMapColor(vis, &green), "ggiMapColor inconsistent with retval of ggiSetPalette.\n"); ggiUnmapPixel(vis, err, &back); if(green.r != back.r || green.g != back.g || green.b != back.b) { printfailure("Unexpected color from ggiUnmapPixel.\n"); ggiClose(vis); ggiExit(); return; } ggiSetGCForeground(vis, err); ggiDrawBox(vis, 0, 0, 3000, 3000); ggiFlush(vis); /* You should see a green square, how to test this? */ ggUSleep(5000000); printsuccess(); ggiClose(vis); ggiExit(); }
static void animate_one_frame(ggi_visual_t vis, int x, int y, int w, int h, ggi_pixel * buf, int x2) { ggiDrawHLine(vis, x, y, w); ggiDrawHLine(vis, x, y + h - 1, w); ggiDrawVLine(vis, x, y, h); ggiDrawVLine(vis, x + w - 1, y, h); ggiDrawBox(vis, x + 2, y + 2, w - 4, h - 4); ggiGetBox(vis, x + 5, y + 5, w - 10, h / 2 - 7, buf); ggiPutBox(vis, x + 5, y + 5, w - 10, h / 2 - 7, buf); ggiCopyBox(vis, x + 5, y + h / 2, w - 10, h / 2 - 5, x + 5, y + h / 2); ggiPuts(vis, x + 7, y + 7, "Get/Put"); ggiPuts(vis, x + 7, y + h / 2 + 2, "Copy"); ggiDrawBox(vis, x2, y, 5, 5); }
static void perf_DRAWBOX(TeleUser *u, TeleCmdDrawBoxData *d) { /* Put a solid box */ if ((d->x < 0) || (d->y < 0) || (d->x + d->width > vis_mode.virt.x) || (d->y + d->height > vis_mode.virt.y)) { fprintf(stderr, "teleserver: ILLEGAL DRAWBOX.\n"); return; } /* if */ ggiSetGCForeground(vis, (ggi_pixel)d->pixel); ggiDrawBox(vis, d->x, d->y, d->width, d->height); } /* perf_DRAWBOX */
void x_bar(int xz, int yz, int xk, int yk) { #ifndef TXTDEBUG #ifdef GGI ggiSetGCForeground (ggiVis, ggi_getcolor (xg_fillc)); ggiDrawBox (ggiVis, xz, yz, xk-xz+1, yk-yz+1); #else unsigned char *palptr = xg_hipal + 3*xg_fillc; int r, g, b; r = ((int) (*palptr++)) << 2; g = ((int) (*palptr++)) << 2; b = ((int) (*palptr)) << 2; //printf ("box (%d): %d %d %d\n", xg_fillc, r, g, b); // rectangle filled with background color gl_fillbox(xz,yz,xk-xz+1,yk-yz+1, gl_rgbcolor(r,g,b)); #endif #endif }
void resolution(ggi_visual_t vis) { int xmax, ymax; ggi_mode currmode; ggiGetMode(vis, &currmode); xmax = currmode.visible.x; ymax = currmode.visible.y; ggiSetGCForeground(vis, blue); ggiDrawBox(vis, 0, 0, xmax, ymax); stripevert(vis, 0, 0, xmax - 1, ymax - 1, black, white, 1); ggiFlush(vis); if (waitabit(vis)) return; stripevert(vis, 0, 0, xmax - 1, ymax - 1, black, white, 2); ggiFlush(vis); if (waitabit(vis)) return; stripevert(vis, 0, 0, xmax - 1, ymax - 1, black, white, 3); ggiFlush(vis); if (waitabit(vis)) return; stripevert(vis, 0, 0, xmax - 1, ymax - 1, black, white, 4); ggiFlush(vis); if (waitabit(vis)) return; stripehor(vis, 0, 0, xmax - 1, ymax - 1, black, white, 1); ggiFlush(vis); if (waitabit(vis)) return; stripehor(vis, 0, 0, xmax - 1, ymax - 1, black, white, 2); ggiFlush(vis); if (waitabit(vis)) return; starone(vis, 0, 0, xmax - 1, ymax - 1, black, white); ggiFlush(vis); if (waitabit(vis)) return; starfive(vis, 0, 0, xmax - 1, ymax - 1, white, black); ggiFlush(vis); if (waitabit(vis)) return; startwoten(vis, 0, 0, xmax - 1, ymax - 1, white, black); ggiFlush(vis); if (waitabit(vis)) return; ggiSetGCForeground(vis, black); ggiDrawBox(vis, 0, 0, xmax, ymax); stripevert(vis, 1 * xmax / 16, 2 * ymax / 8, 3 * xmax / 16 - 1, 3 * ymax / 8 - 1, black, red, 4); stripevert(vis, 3 * xmax / 16, 2 * ymax / 8, 5 * xmax / 16 - 1, 3 * ymax / 8 - 1, black, red, 3); stripevert(vis, 5 * xmax / 16, 2 * ymax / 8, 7 * xmax / 16 - 1, 3 * ymax / 8 - 1, black, red, 2); stripevert(vis, 7 * xmax / 16, 2 * ymax / 8, 9 * xmax / 16 - 1, 3 * ymax / 8 - 1, black, red, 1); stripevert(vis, 9 * xmax / 16, 2 * ymax / 8, 11 * xmax / 16 - 1, 3 * ymax / 8 - 1, black, red, 2); stripevert(vis, 11 * xmax / 16, 2 * ymax / 8, 13 * xmax / 16 - 1, 3 * ymax / 8 - 1, black, red, 3); stripevert(vis, 13 * xmax / 16, 2 * ymax / 8, 15 * xmax / 16 - 1, 3 * ymax / 8 - 1, black, red, 4); stripevert(vis, 1 * xmax / 16, 3 * ymax / 8, 3 * xmax / 16 - 1, 4 * ymax / 8 - 1, black, green, 4); stripevert(vis, 3 * xmax / 16, 3 * ymax / 8, 5 * xmax / 16 - 1, 4 * ymax / 8 - 1, black, green, 3); stripevert(vis, 5 * xmax / 16, 3 * ymax / 8, 7 * xmax / 16 - 1, 4 * ymax / 8 - 1, black, green, 2); stripevert(vis, 7 * xmax / 16, 3 * ymax / 8, 9 * xmax / 16 - 1, 4 * ymax / 8 - 1, black, green, 1); stripevert(vis, 9 * xmax / 16, 3 * ymax / 8, 11 * xmax / 16 - 1, 4 * ymax / 8 - 1, black, green, 2); stripevert(vis, 11 * xmax / 16, 3 * ymax / 8, 13 * xmax / 16 - 1, 4 * ymax / 8 - 1, black, green, 3); stripevert(vis, 13 * xmax / 16, 3 * ymax / 8, 15 * xmax / 16 - 1, 4 * ymax / 8 - 1, black, green, 4); stripevert(vis, 1 * xmax / 16, 4 * ymax / 8, 3 * xmax / 16 - 1, 5 * ymax / 8 - 1, black, blue, 4); stripevert(vis, 3 * xmax / 16, 4 * ymax / 8, 5 * xmax / 16 - 1, 5 * ymax / 8 - 1, black, blue, 3); stripevert(vis, 5 * xmax / 16, 4 * ymax / 8, 7 * xmax / 16 - 1, 5 * ymax / 8 - 1, black, blue, 2); stripevert(vis, 7 * xmax / 16, 4 * ymax / 8, 9 * xmax / 16 - 1, 5 * ymax / 8 - 1, black, blue, 1); stripevert(vis, 9 * xmax / 16, 4 * ymax / 8, 11 * xmax / 16 - 1, 5 * ymax / 8 - 1, black, blue, 2); stripevert(vis, 11 * xmax / 16, 4 * ymax / 8, 13 * xmax / 16 - 1, 5 * ymax / 8 - 1, black, blue, 3); stripevert(vis, 13 * xmax / 16, 4 * ymax / 8, 15 * xmax / 16 - 1, 5 * ymax / 8 - 1, black, blue, 4); stripevert(vis, 1 * xmax / 16, 5 * ymax / 8, 3 * xmax / 16 - 1, 6 * ymax / 8 - 1, black, white, 4); stripevert(vis, 3 * xmax / 16, 5 * ymax / 8, 5 * xmax / 16 - 1, 6 * ymax / 8 - 1, black, white, 3); stripevert(vis, 5 * xmax / 16, 5 * ymax / 8, 7 * xmax / 16 - 1, 6 * ymax / 8 - 1, black, white, 2); stripevert(vis, 7 * xmax / 16, 5 * ymax / 8, 9 * xmax / 16 - 1, 6 * ymax / 8 - 1, black, white, 1); stripevert(vis, 9 * xmax / 16, 5 * ymax / 8, 11 * xmax / 16 - 1, 6 * ymax / 8 - 1, black, white, 2); stripevert(vis, 11 * xmax / 16, 5 * ymax / 8, 13 * xmax / 16 - 1, 6 * ymax / 8 - 1, black, white, 3); stripevert(vis, 13 * xmax / 16, 5 * ymax / 8, 15 * xmax / 16 - 1, 6 * ymax / 8 - 1, black, white, 4); ggiFlush(vis); if (waitabit(vis)) return; }