/* Draw the message if it's a mini */ void draw_message(char *msg1, char *msg2) { int offset; /* Clear the window */ GrClearWindow(message_wid, GR_FALSE); /* Put the foreground and background in good shapes */ GrSetGCForeground(tuxchess_gc, GR_RGB(0,0,0)); GrSetGCBackground(tuxchess_gc, GR_RGB(255,255,255)); /* Draw the "window" */ GrLine(message_wid, tuxchess_gc, 1, 0, 34, 0); GrLine(message_wid, tuxchess_gc, 1, 16, 34, 16); GrLine(message_wid, tuxchess_gc, 1, 0, 1, 110); GrLine(message_wid, tuxchess_gc, 34, 0, 34, 110); GrLine(message_wid, tuxchess_gc, 1, 110, 34, 110); GrText(message_wid, tuxchess_gc, 3,13, "Chess", -1, GR_TFASCII); /* Title in the text box */ GrText(message_wid, tuxchess_gc, 3,73, msg1, -1, GR_TFASCII); if ((strcmp(msg2, "Play") == 0) || (strcmp(msg2, " ") == 0)) { offset = 3; msg2 = "Play"; } else { offset = 0; } GrText(message_wid, tuxchess_gc, 4+offset,53, msg2, -1, GR_TFASCII); }
/* ***********************************************************/ void draw_historic(void) { /* Clear the window */ GrClearWindow (historic_wid, GR_FALSE); /* Put the foreground and background in good shapes */ GrSetGCForeground(tuxchess_gc, GR_RGB(0,0,0)); GrSetGCBackground(tuxchess_gc, GR_RGB(255,255,255)); /* Draw the "window" */ GrLine(historic_wid, tuxchess_gc, 1, 1, 55, 1); GrLine(historic_wid, tuxchess_gc, 1, 1, 1, 104); GrLine(historic_wid, tuxchess_gc, 1, 105, 55, 105); GrLine(historic_wid, tuxchess_gc, 55, 1, 55, 105); GrText(historic_wid, tuxchess_gc, 14,14, "Moves", -1, GR_TFASCII); /* Title in the text box */ GrLine(historic_wid, tuxchess_gc, 1, 17, 56, 17); /* So ugly code since char* arrays seem to confuse my iPod - writes 6 lines */ GrText(historic_wid, tuxchess_gc, 6, 33, historic_line1, -1, GR_TFASCII); GrText(historic_wid, tuxchess_gc, 6, 46, historic_line2, -1, GR_TFASCII); GrText(historic_wid, tuxchess_gc, 6, 59, historic_line3, -1, GR_TFASCII); GrText(historic_wid, tuxchess_gc, 6, 72, historic_line4, -1, GR_TFASCII); GrText(historic_wid, tuxchess_gc, 6, 85, historic_line5, -1, GR_TFASCII); GrText(historic_wid, tuxchess_gc, 6, 99, historic_line6, -1, GR_TFASCII); }
static void reset_board() { int index; for(index = 0; index < 9; index++) board[index] = '-'; difficulty = 6; gameRunning = 1; currSquare = 0; draw_header(); /* Clear the window */ GrClearWindow (tictactoe_wid, GR_FALSE); GrSetGCUseBackground(tictactoe_gc, GR_TRUE); GrSetGCBackground(tictactoe_gc, WHITE); GrSetGCForeground(tictactoe_gc, BLACK); GrLine(tictactoe_wid, tictactoe_gc, wi.width * .90, (wi.height / 2.) - (wi.height / 2. * .33), wi.width - wi.width * .90, (wi.height / 2.) - (wi.height / 2. * .33)); GrLine(tictactoe_wid, tictactoe_gc, wi.width * .90, (wi.height / 2.) + (wi.height / 2. * .33), wi.width - wi.width * .90, (wi.height / 2.) + (wi.height / 2. * .33)); GrLine(tictactoe_wid, tictactoe_gc, (wi.width / 2.) - (wi.width / 2. * .33), wi.height * .90, (wi.width / 2.) - (wi.width / 2. * .33), wi.height - wi.height * .90); GrLine(tictactoe_wid, tictactoe_gc, (wi.width / 2.) + (wi.width / 2. * .33), wi.height * .90, (wi.width / 2.) + (wi.width / 2. * .33), wi.height - wi.height * .90); currSquare = 0; drawXO(currSquare, GRAY, 'x'); }
static void chopDrawScene() { char s[30]; GrClearWindow (chopBuffer, GR_FALSE); sprintf (s, "Chopper - %d", chopCounter); pz_draw_header (s); GrSetGCForeground(chopGC, GR_RGB(WHITE)); GrFillRect(chopBuffer, chopGC, 0,0,screen_info.cols,screen_info.rows ); chopDrawPlayer(iPlayerPosX - iCameraPosX,iPlayerPosY); /* If I was less lazy I could make a nifty shadow effect with this stuff... int h = chopTerrainHeightAtPoint(&mGround, iPlayerPosX); GrSetGCForeground(gc, GR_RGB(BLACK)); GrFillRect(chopBuffer,gc,iPlayerPosX - iCameraPosX,h - 1,2,2); */ chopDrawTheWorld(); //Flip the buffer GrCopyArea(chopWindow, chopGC, 0, 0, screen_info.cols, (screen_info.rows - (HEADER_TOPLINE + 1)), chopBuffer, 0, 0, MWROP_SRCCOPY); }
static void dobuttonup(GR_EVENT_BUTTON *bp) { if (bp->wid != mapwid) return; if (bp->changebuttons & COORDBUTTON) { showcoords(GR_FALSE); coordenabled = GR_FALSE; } if (bp->changebuttons & SELECTBUTTON) { showselection(GR_FALSE); if (selectmode == SELECT_NONE) return; selectmode = SELECT_NONE; if (selectwidth <= 0) return; Longitude += FIDIV(FIMUL(viewlong, selectx - mapxorig), mapwidth); Latitude -= FIDIV(FIMUL(viewlat, selecty - mapyorig), mapheight); setzoom(FIDIV(FIMUL(zoom, mapwidth), selectwidth)); GrClearWindow(mapwid, GR_TRUE); } }
void new_video_window(char *filename) { #ifndef IPOD pz_error("No video support on the desktop."); #else /* IPOD */ if (full_hw_version==0) { full_hw_version = ipod_get_hw_version(); } outl(1, VAR_VIDEO_ON); outl(0, VAR_VIDEO_MODE); cop_wakeup(); init_variables(); video_status = VIDEO_CONTROL_MODE_STARTING; video_curPosition = 0; video_gc = pz_get_gc(1); GrSetGCUseBackground(video_gc, GR_FALSE); GrSetGCForeground(video_gc, GR_RGB(0,0,0)); //nes_window("Create win"); video_wid = pz_new_window(0, 0, screen_info.cols, screen_info.rows, video_do_draw, video_do_keystroke); GrSelectEvents(video_wid, GR_EVENT_MASK_KEY_DOWN| GR_EVENT_MASK_KEY_UP); GrMapWindow(video_wid); GrClearWindow(video_wid, GR_FALSE); //nes_window("Load"); video_status_message("Loading video..."); //nes_window("Play"); playVideo(filename); outl(0, VAR_VIDEO_ON); #endif }
/* End of the game */ void draw_end(char col) { int offset, off_x, off_y; if (end == 0) { end = 1; end_type = col; } else { end = 2; if (is_mini) { offset = 0; off_x = 11; off_y = 9; } else { offset = HEADER_TOPLINE+1; off_x = 0; off_y = 0; } end_wid = pz_new_window (0, offset, screen_info.cols, screen_info.rows - offset, tuxchess_do_draw, tuxchess_handle_event); GrSelectEvents(end_wid, GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP); GrMapWindow(end_wid); /* Put the foreground and background in good shapes */ GrSetGCForeground(tuxchess_gc, GR_RGB(0,0,0)); GrSetGCBackground(tuxchess_gc, GR_RGB(255,255,255)); /* Clear the window */ GrClearWindow(end_wid, GR_FALSE); if (col=='b') { GrText(end_wid, tuxchess_gc, 57-off_x,40-off_y, "You Lost", -1, GR_TFASCII); } else if (col=='w') { GrText(end_wid, tuxchess_gc, 54-off_x,40-off_y, "Well Done", -1, GR_TFASCII); } else if (col=='d') { GrText(end_wid, tuxchess_gc, 67-off_x,40-off_y, "Draw", -1, GR_TFASCII); } GrText(end_wid, tuxchess_gc, 52-off_x,65-off_y, "Menu : Quit", -1, GR_TFASCII); GrText(end_wid, tuxchess_gc, 33-off_x,80-off_y, "Action : New Game", -1, GR_TFASCII); } }
static void credits_var_init(void) { int i; GrGetWindowInfo(credits_wid, &credits_info); GrClearWindow(credits_wid, GR_FALSE); cols = (credits_info.width/COL_W)+1; stream = credits_malloc(cols); for (i = 0; i < cols; i++) { stream[i] = ' '; } }
void saver4_exposure(nstate *state) { int i; s4state *s = state->priv; GrClearWindow(state->main_window, 0); if(!s->length) return; for(i = 0; i < SAVER4_NUMWORMS; i++) { GrSetGCForeground(state->main_gc, s->worms[i].colour); GrPoints(state->main_window, state->main_gc, s->length, s->worms[i].points); } }
/* * Initialize the board for playing */ static void newgame(void) { GR_COORD row; GR_COORD col; GR_COUNT count; CELL cell; POS pos; for (row = 0; row < FULLSIZE; row++) { for (col = 0; col < FULLSIZE; col++) { cell = F_EMPTY; if (badsquare(row) || badsquare(col)) cell |= F_EDGE; board[boardpos(row, col)] = cell; } } playing = GR_TRUE; count = 0; legs = 2; steps = 0; drawstatus(); setcursor(); while (count < mines) { do { row = (rand() / 16) % (size * size + 1); } while (row == (size * size)); col = (row % size) + 1; row = (row / size) + 1; pos = boardpos(row, col); if ((pos == boardpos(1,1)) || (pos == boardpos(1,2)) || (pos == boardpos(2,1)) || (pos == boardpos(2,2)) || (pos == boardpos(size,size))) continue; if (!ismine(board[pos]) && checkpath(pos)) count++; } board[boardpos(1,1)] = (F_OLD | '0'); GrClearWindow(boardwid, GR_TRUE); }
void saver2_animate(nstate *state) { GR_COORD x, y; GR_COLOR c; int pixels = SAVER2_PIXELS_PER_FRAME; s2state *s = state->priv; while(pixels--) { if(!(s->pixels--)) { s->pixels = SAVER2_MAXPIXELS; GrClearWindow(state->main_window, 0); } get_random_point_on_screen(state, &x, &y, &c); GrSetGCForeground(state->main_gc, c); GrPoint(state->main_window, state->main_gc, x, y); } }
void saver3_animate(nstate *state) { GR_COORD newx, newy; GR_COLOR c; s3state *s = state->priv; int pixels = SAVER3_SEGMENTS_PER_FRAME; while(pixels--) { if(!(s->maxsegments--)) { s->maxsegments = SAVER3_MAXSEGMENTS; GrClearWindow(state->main_window, 0); } get_random_point_on_screen(state, &newx, &newy, &c); GrSetGCForeground(state->main_gc, c); GrLine(state->main_window, state->main_gc, s->lastx, s->lasty, newx, newy); s->lastx = newx; s->lasty = newy; } }
void char_out(GR_CHAR ch) { switch(ch) { case '\r': xpos = 0; return; case '\n': ypos += height; if(ypos > si.rows - 60 - height) { ypos -= height; #if HAVEBLIT bogl_cfb8_blit(50, 30, si.cols-120, si.rows-60-height, 50, 30+height); GrFillRect(w1, gc3, 50, ypos, si.cols-120, height); #else /* FIXME: changing FALSE to TRUE crashes nano-X*/ /* clear screen, no scroll*/ ypos = 0; GrClearWindow(w1, GR_FALSE); #endif } return; case '\007': /* bel*/ return; case '\t': xpos += width; while((xpos/width) & 7) char_out(' '); return; case '\b': /* assumes fixed width font!!*/ if (xpos <= 0) return; char_del(xpos, ypos); return; } GrText(w1, gc1, xpos+1, ypos, &ch, 1, GR_TFTOP); xpos += width; }
static void char_out(GR_CHAR ch) { switch(ch) { case '\r': case '\n': xpos = 0; ypos += height; if(ypos >= TEXTWIN_HEIGHT - height) { ypos -= height; /* FIXME: changing FALSE to TRUE crashes nano-X*/ /* clear screen, no scroll*/ ypos = 0; GrClearWindow(wt, GR_FALSE); } return; case '\007': /* bel*/ return; case '\t': xpos += width; while((xpos/width) & 7) char_out(' '); return; case '\b': /* assumes fixed width font!!*/ if (xpos <= 0) return; char_del(xpos, ypos); char_out(' '); char_del(xpos, ypos); return; } GrText(wt, gct, xpos+1, ypos, &ch, 1, GR_TFTOP); xpos += width; if (xpos >= TEXTWIN_WIDTH-width) char_out('\n'); }
static void dokeydown(GR_EVENT_KEYSTROKE *kp) { if (kp->wid != mapwid) return; if (selectmode != SELECT_NONE) { switch (kp->ch) { case 's': /* scale selection */ selectmode = SELECT_SCALE; break; case 'm': /* move selection */ selectmode = SELECT_MOVE; break; case '\033': /* cancel selection */ showselection(GR_FALSE); selectmode = SELECT_NONE; break; } return; } switch (kp->ch) { case 'q': /* quit */ case 'Q': GrClose(); exit(0); case 't': /* redraw total map */ Longitude = ITOF(0); Latitude = ITOF(0); setzoom(ITOF(1)); GrClearWindow(mapwid, GR_TRUE); } }
/** * deactivate action of init view */ static void deactivate(void) { DisplayState *displaystate = getDisplayState(); /*Clear screen*/ GrClearWindow(displaystate->gWinID,GR_FALSE); }
/* * 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; }
void initialise(lstate *state) { GR_SCREEN_INFO si; GR_IMAGE_ID back_image; GR_IMAGE_INFO imageinfo; int rows = 1, columns = 1, width, height, x = 0, y = 0; GR_WM_PROPERTIES props; litem *i; if(GrOpen() < 0) { GrError("Couldn't connect to Nano-X server\n"); exit(4); } state->window_background_mode = 0; state->window_background_image = NULL; sspid = -1; read_config(state); GrGetScreenInfo(&si); if(si.rows > si.cols) { rows = state->numlitems; while((((rows / columns) + rows % columns) * ITEM_HEIGHT) > si.rows) { columns++; } if((columns * ITEM_WIDTH) > si.cols) goto toomany; rows = (rows / columns) + (rows % columns); width = columns * ITEM_WIDTH + 1 + columns; height = rows * ITEM_HEIGHT + 1 + rows; } else { columns = state->numlitems; while((((columns / rows) + (columns % rows)) * ITEM_WIDTH) > si.cols) { rows++; } if((rows * ITEM_HEIGHT) > si.rows) goto toomany; columns = (columns / rows) + (columns % rows); width = columns * ITEM_WIDTH + 1 + columns; height = (rows * ITEM_HEIGHT) + 1 + rows; y = si.rows - (rows * ITEM_HEIGHT) - 1 - rows; } state->gc = GrNewGC(); GrSetGCForeground(state->gc, ITEM_TEXT_COLOUR); GrSetGCBackground(state->gc, ITEM_BACKGROUND_COLOUR); if(state->window_background_image) { if(!(back_image = GrLoadImageFromFile( state->window_background_image, 0))) { GrError("Couldn't load background image\n"); } else { GrGetImageInfo(back_image, &imageinfo); if(!(state->background_pixmap = GrNewPixmap( imageinfo.width, imageinfo.height, NULL))) { GrError("Couldn't allocate pixmap " "for background image\n"); } else { GrDrawImageToFit(state->background_pixmap, state->gc, 0, 0, imageinfo.width, imageinfo.height, back_image); GrFreeImage(back_image); GrSetBackgroundPixmap(GR_ROOT_WINDOW_ID, state->background_pixmap, state->window_background_mode); GrClearWindow(GR_ROOT_WINDOW_ID, GR_TRUE); } } } if(state->ssitems) GrSelectEvents(GR_ROOT_WINDOW_ID, GR_EVENT_MASK_SCREENSAVER); state->main_window = GrNewWindow(GR_ROOT_WINDOW_ID, 0, y, width, height, 0, ITEM_BACKGROUND_COLOUR, 0); GrSelectEvents(state->main_window, GR_EVENT_MASK_CLOSE_REQ | GR_EVENT_MASK_TIMER); props.flags = GR_WM_FLAGS_PROPS; props.props = GR_WM_PROPS_NOMOVE | GR_WM_PROPS_NODECORATE | GR_WM_PROPS_NOAUTOMOVE | GR_WM_PROPS_NOAUTORESIZE; GrSetWMProperties(state->main_window, &props); i = state->lastlitem; y = 0; while(i) { i->wid = GrNewWindow(state->main_window, (x * ITEM_WIDTH) + x + 1, (y * ITEM_HEIGHT) + y + 1, ITEM_WIDTH, ITEM_HEIGHT, 1, ITEM_BACKGROUND_COLOUR, ITEM_BORDER_COLOUR); GrSelectEvents(i->wid, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN); GrMapWindow(i->wid); i = i->prev; if(++x == columns) { x = 0; y++; } } GrMapWindow(state->main_window); signal(SIGCHLD, &reaper); do_startups(state); return; toomany: GrError("Too many items to fit on screen\n"); exit(6); }
void saver3_exposure(nstate *state) { GrClearWindow(state->main_window, 0); }
int main() { #ifdef TEST_FOR_X Display *display; Window window; GC gc; XGCValues gcValues; Colormap colormap; Pixmap src_pixmap; unsigned long fgColor, bgColor; int screenNum; XPoint points[NUM_POINTS]; #else GR_WINDOW_ID window; GR_WINDOW_ID src_pixmap; unsigned char* src_pixmap_buf[320*240*2]; GR_GC_ID gc; GR_POINT points[NUM_POINTS]; #endif int c, c1, count=4500; int x, y, x1, y1, x2, y2; #ifdef TEST_FOR_X if(!(display=XOpenDisplay(""))) { printf("Cannot connect to X.\n"); } screenNum = DefaultScreen(display); colormap = DefaultColormap(display, screenNum); bgColor = BlackPixel(display, screenNum); fgColor = WhitePixel(display, screenNum); window = XCreateSimpleWindow(display, RootWindow(display, screenNum), 0, 0 , 639, 479, 0, fgColor, bgColor); src_pixmap = XCreatePixmap(display, window, 320, 240, 16); XMapRaised(display, window); gcValues.background = bgColor; gcValues.foreground = fgColor; gcValues.line_width = 1; gcValues.line_style = LineSolid; gcValues.fill_style = FillSolid; gcValues.fill_rule = WindingRule; gcValues.arc_mode = ArcPieSlice; gc = XCreateGC(display, window, GCForeground | GCBackground | GCLineWidth | GCLineStyle | GCFillStyle, &gcValues); #else GrOpen(); window = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, 639, 479, 0, BLACK, BLUE); src_pixmap = GrNewPixmap(640, 480, src_pixmap_buf); GrMapWindow(window); gc = GrNewGC(); GrSetGCForeground(gc, WHITE); GrSetGCBackground(gc, BLACK); GrSetGCMode(gc, GR_MODE_COPY); #endif // Horizontal Line //////////////////////////////////////////////// printf("Horizontal Line(XDrawLine)\n"); start_timer(); for(c=0; c<count*20; c++) { y1=random()%480; #ifdef TEST_FOR_X XDrawLine(display, window, gc, 0, y1, 639, y1); XFlush(display); #else GrLine(window, gc, 0, y1, 639, y1); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XClearWindow(display, window); #else GrClearWindow(window, GR_TRUE); #endif // Vertical Line ///////////////////////////////////////////////// printf("Vertical Line(XDrawLine)\n"); start_timer(); for(c=0; c<count*19; c++) { x1=random()%640; #ifdef TEST_FOR_X XDrawLine(display, window, gc, x1, 0, x1, 479); XFlush(display); #else GrLine(window, gc, x1, 0, x1, 479); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XClearWindow(display, window); #else GrClearWindow(window, GR_TRUE); #endif // General Line ///////////////////////////////////////////////// printf("General Line(XDrawLine)\n"); start_timer(); for(c=0; c<count*22; c++) { x1 = random()%640; x2 = random()%640; y1 = random()%480; y2 = random()%480; #ifdef TEST_FOR_X XDrawLine(display, window, gc, x1, y1, x2, y2); XFlush(display); #else GrLine(window, gc, x1, y1, x2, y2); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XClearWindow(display, window); #else GrClearWindow(window, GR_TRUE); #endif // Point ////////////////////////////////////////////////// printf("XPoint\n"); start_timer(); for(c=0; c<count*25; c++) { x1 = random()%640; y1 = random()%480; #ifdef TEST_FOR_X XDrawPoint(display, window, gc, x1, y1); XFlush(display); #else GrPoint(window, gc, x1, y1); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XClearWindow(display, window); #else GrClearWindow(window, GR_TRUE); #endif // Rectangle ////////////////////////////////////////////////// printf("XRectangle\n"); start_timer(); for(c=0; c<count*20; c++) { x1=random()%639; y1=random()%479; x2=random()%(639-x1)+1; y2=random()%(479-y1)+1; #ifdef TEST_FOR_X XDrawRectangle(display, window, gc, x1, y1, x2, y2); XFlush(display); #else GrRect(window, gc, x1, y1, x2, y2); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XClearWindow(display, window); #else GrClearWindow(window, GR_TRUE); #endif // FillRectangle ////////////////////////////////////////////////// printf("XFillRectangle\n"); start_timer(); for(c=0; c<count*18; c++) { x1=random()%639; y1=random()%479; x2=random()%(639-x1)+1; y2=random()%(479-y1)+1; #ifdef TEST_FOR_X XFillRectangle(display, window, gc, x1, y1, x2, y2); XFlush(display); #else GrFillRect(window, gc, x1, y1, x2, y2); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XClearWindow(display, window); #else GrClearWindow(window, GR_TRUE); #endif // FillPolygon ////////////////////////////////////////////////// printf("XFillPolygon\n"); start_timer(); for(c=0; c<count; c++) { for(c1=0; c1<NUM_POINTS; c1++) { points[c1].x = random()%640; points[c1].y = random()%480; } #ifdef TEST_FOR_X XFillPolygon(display, window, gc, points, NUM_POINTS, 0, 0); XFlush(display); #else GrFillPoly(window, gc, NUM_POINTS, points); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XClearWindow(display, window); #else GrClearWindow(window, GR_TRUE); #endif // CopyArea ///////////////////////////////////////////////// printf("XCopyArea\n"); start_timer(); for(c=0; c<count*5; c++) { x1=random()%320; y1=random()%240; x2=random()%319+1; y2=random()%239+1; #ifdef TEST_FOR_X XCopyArea(display, src_pixmap, window, gc, 0, 0, x2, y2, x1, y1); XFlush(display); #else GrCopyArea(window, gc, x1, y1, x2 ,y2, src_pixmap, 0, 0, 0); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XDestroyWindow(display, window); #else GrClose(); #endif }
/* ***********************************************************/ void open_tuxchess_window (void) { tuxchess_gc = pz_get_gc(1); /* Get the graphics context */ is_mini = (screen_info.cols == 138); if (is_mini) { /* Open the window for the board: */ tuxchess_wid = pz_new_window(0, 2, 104, screen_info.rows, tuxchess_do_draw, tuxchess_handle_event); /* Open the window for the message on the left : */ message_wid = pz_new_window(104, 0, screen_info.cols, screen_info.rows, tuxchess_do_draw, tuxchess_handle_event); GrSelectEvents(tuxchess_wid, GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP); GrSelectEvents(message_wid, GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP); } else { /* Open the window for the board: */ tuxchess_wid = pz_new_window(0, HEADER_TOPLINE + 1, 104, screen_info.rows - HEADER_TOPLINE - 1, tuxchess_do_draw, tuxchess_handle_event); /* Open the window for the historic : */ historic_wid = pz_new_window(104, HEADER_TOPLINE + 1, screen_info.cols, screen_info.rows - HEADER_TOPLINE - 1, tuxchess_do_draw, tuxchess_handle_event); GrSelectEvents(tuxchess_wid, GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP); GrSelectEvents(historic_wid, GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP); } /* Display the windows : */ if (is_mini) { GrMapWindow(message_wid); draw_message("A1-","Play"); } else { GrMapWindow(historic_wid); } GrMapWindow(tuxchess_wid); tuxchess_do_draw(); /* Clear the window */ GrClearWindow(tuxchess_wid, GR_FALSE); gen_moves(); max_time = 100000;//1 << 25; max_depth = 1; end = 0; print_board(); if (!is_mini) { draw_historic(); } /* make sure the right window has focus so we get input events */ // GrSetFocus(tuxchess_wid); }