/* Draw all roaches. */ void DrawRoaches(void) { Roach *roach; int rx; for (rx=0; rx<curRoaches; rx++) { roach = &roaches[rx]; if (roach->intX >= 0) { GrClearArea(GR_ROOT_WINDOW_ID, roach->intX, roach->intY, roach->rp->width, roach->rp->height, GR_FALSE); } } for (rx=0; rx<curRoaches; rx++) { roach = &roaches[rx]; if (!roach->hidden) { int size = roach->rp->width * roach->rp->height; GR_PIXELVAL roachbuf[size]; GR_PIXELVAL screenbuf[size]; int i; roach->intX = roach->x; roach->intY = roach->y; roach->rp = &roachPix[roach->index]; /* //XSetForeground(display, gc, AllocNamedColor(roachColor, black)); //XSetFillStyle(display, gc, FillStippled); //XSetStipple(display, gc, roach->rp->pixmap); //XSetTSOrigin(display, gc, roach->intX, roach->intY); //XFillRectangle(display, rootWin, gc, //roach->intX, roach->intY, roach->rp->width, roach->rp->height); */ /* read roach bitmap*/ GrReadArea(roach->rp->pixmap, 0, 0, roach->rp->width, roach->rp->height, roachbuf); /* read root window*/ GrReadArea(GR_ROOT_WINDOW_ID, roach->intX, roach->intY, roach->rp->width, roach->rp->height, screenbuf); /* convert fg roach bitmap bits to roach color on root window bits*/ for (i=0; i<size; ++i) if (roachbuf[i] != BLACK) screenbuf[i] = roachColor; /* write root window*/ GrArea(GR_ROOT_WINDOW_ID, gc, roach->intX, roach->intY, roach->rp->width, roach->rp->height, screenbuf, MWPF_PIXELVAL); } else { roach->intX = -1; } } GrFlush(); }
/* FIXME: fails with size > 64k if sizeof(int) == 2*/ static void GrAreaWrapper(void *r) { nxAreaReq *req = r; GrArea(req->drawid, req->gcid, req->x, req->y, req->width, req->height, GetReqData(req), req->pixtype); }
void nglXSwapBuffers(NGLXDrawable drawable) { GLContext *gl_context; TinyNGLXContext *ctx; /* retrieve the current NGLXContext */ gl_context = gl_get_context(); ctx = (TinyNGLXContext *)gl_context->opaque; GrArea(drawable, ctx->gc, 0, 0, ctx->xsize, ctx->ysize, ctx->gl_context->zb->pbuf, ctx->pixtype); }
/* * Copy raw pixel data to the screen */ void CopyDataToScreen(CARD8 *buf, int x, int y, int width, int height) { #if 0 /* DEBUG */ printf("CDTS "); fflush(stdout); #endif if (rawDelay != 0) { #if 0 XFillRectangle(dpy, canvas, DefaultGC(dpy,DefaultScreen(dpy)), x, y, width, height); #endif XSync(dpy,False); usleep(rawDelay * 1000); } if (!useBGR233) { GrArea(canvas, gc, x, y, width, height, buf, MWPF_PALETTE); } else { CopyBGR233ToScreen(buf, x, y, width, height); } }
/* * Here when a button is pressed. */ void do_buttondown(GR_EVENT_BUTTON *bp) { GR_PIXELVAL intable[W2_WIDTH * W2_HEIGHT]; GR_PIXELVAL outtable[W2_WIDTH * W2_HEIGHT * 6]; GR_PIXELVAL *inp; GR_PIXELVAL *outp; GR_PIXELVAL *oldinp; GR_COORD row; GR_COORD col; /*static int xx = 100; static int yy = 50;*/ if (bp->wid == w3) { GrRaiseWindow(w3); GrReadArea(w2, 0, 0, W2_WIDTH, W2_HEIGHT, intable); inp = intable; outp = outtable; for (row = 0; row < W2_HEIGHT; row++) { oldinp = inp; for (col = 0; col < W2_WIDTH; col++) { *outp++ = *inp; *outp++ = *inp++; } inp = oldinp; for (col = 0; col < W2_WIDTH; col++) { *outp++ = *inp; *outp++ = *inp++; } inp = oldinp; for (col = 0; col < W2_WIDTH; col++) { *outp++ = *inp; *outp++ = *inp++; } } GrArea(w1, gc1, 0, 0, W2_WIDTH * 2, W2_HEIGHT * 3, outtable, MWPF_PIXELVAL); return; } if (bp->wid == w4) { GrRaiseWindow(w4); linexpos = bp->x; lineypos = bp->y; xorxpos = bp->x; xorypos = bp->y; GrLine(w4, gc4, xorxpos, xorypos, linexpos, lineypos); lineok = GR_TRUE; return; } if (bp->wid != w1) { /* * Cause a fatal error for testing if more than one * button is pressed. */ if ((bp->buttons & -((int) bp->buttons)) != bp->buttons) GrClearWindow(-1, 0); return; } GrRaiseWindow(w1); /*GrMoveWindow(w1, ++xx, yy);*/ if (bp->buttons & GR_BUTTON_L) { GrClearWindow(w1, GR_TRUE); return; } begxpos = bp->x; xpos = bp->x; ypos = bp->y; }