ENTRYPOINT void draw_lightning (ModeInfo * mi) { int i; Storm *st; if (Helga == NULL) return; st = &Helga[MI_SCREEN(mi)]; MI_IS_DRAWN(mi) = True; switch (st->stage) { case 0: MI_IS_DRAWN(mi) = False; MI_CLEARWINDOW(mi); MI_IS_DRAWN(mi) = True; st->color = NRAND(MI_NPIXELS(mi)); st->draw_time = 0; if (storm_active(st)) st->stage++; else st->stage = 4; break; case 1: for (i = 0; i < st->multi_strike; i++) { if (st->bolts[i].visible) draw_bolt(&(st->bolts[i]), mi); update_bolt(&(st->bolts[i]), st->draw_time); } st->draw_time++; st->stage++; st->busyLoop = 0; break; case 2: if (++st->busyLoop > 6) { st->stage++; st->busyLoop = 0; } break; case 3: MI_IS_DRAWN(mi) = False; MI_CLEARWINDOW(mi); MI_IS_DRAWN(mi) = True; if (storm_active(st)) st->stage = 1; else st->stage++; break; case 4: if (++st->busyLoop > 100) { st->busyLoop = 0; } init_lightning(mi); break; } }
void refresh_voters(ModeInfo * mi) { int col, row, colrow; voterstruct *vp; if (voters == NULL) return; vp = &voters[MI_SCREEN(mi)]; if (vp->first == NULL) return; if (vp->painted) { MI_CLEARWINDOW(mi); vp->painted = False; for (row = 0; row < vp->nrows; row++) for (col = 0; col < vp->ncols; col++) { colrow = col + row * vp->ncols; /* Draw all old, will get corrected soon if wrong... */ drawcell(mi, col, row, (unsigned long) (MI_NPIXELS(mi) * vp->arr[colrow] / BITMAPS), vp->arr[colrow], False); } } }
ENTRYPOINT void init_stairs (ModeInfo * mi) { int screen = MI_SCREEN(mi); stairsstruct *sp; if (stairs == NULL) { if ((stairs = (stairsstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (stairsstruct))) == NULL) return; } sp = &stairs[screen]; sp->step = 0.0; sp->rotating = 0; sp->sphere_position = NRAND(NPOSITIONS); sp->sphere_tick = 0; if ((sp->glx_context = init_GL(mi)) != NULL) { reshape_stairs(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); glDrawBuffer(GL_BACK); if (!glIsList(sp->objects)) sp->objects = glGenLists(1); pinit(mi); } else { MI_CLEARWINDOW(mi); } sp->trackball = gltrackball_init (False); }
ENTRYPOINT void init_boxed(ModeInfo * mi) { int screen = MI_SCREEN(mi); /* Colormap cmap; */ /* Boolean rgba, doublebuffer, cmap_installed; */ boxedstruct *gp; MI_INIT(mi, boxed, free_boxed); gp = &boxed[screen]; gp->window = MI_WINDOW(mi); if ((gp->glx_context = init_GL(mi)) != NULL) { reshape_boxed(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); glDrawBuffer(GL_BACK); if (!glIsList(gp->listobjects)) { gp->listobjects = glGenLists(3); gp->gllists[0] = 0; gp->gllists[1] = 0; gp->gllists[2] = 0; } pinit(mi); } else { MI_CLEARWINDOW(mi); } }
void refresh_tik_tak(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); int i; tik_takstruct *tiktak; if (tik_taks == NULL) return; tiktak = &tik_taks[MI_SCREEN(mi)]; if (tiktak->object == NULL) return; if (!tiktak->painted) return; MI_CLEARWINDOW(mi); XSetFunction(display, tiktak->gc, GXxor); for (i = 0; i < tiktak->num_object; i++) { tik_takobject *object0; object0 = &tiktak->object[i]; if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) { XSetForeground(display, tiktak->gc, tiktak->colors[object0->colour].pixel); } else { XSetForeground(display, tiktak->gc, object0->colour); } tik_tak_setupobject( mi , object0); tik_tak_reset_object( object0); tik_tak_drawobject(mi, object0 ); } XSetFunction(display, tiktak->gc, GXcopy); }
ENTRYPOINT void init_cubicgrid(ModeInfo *mi) { cubicgrid_conf *cp; if(!cubicgrid) { cubicgrid = (cubicgrid_conf *)calloc(MI_NUM_SCREENS(mi), sizeof(cubicgrid_conf)); if(!cubicgrid) return; } cp = &cubicgrid[MI_SCREEN(mi)]; if ((cp->glx_context = init_GL(mi)) != NULL) { init_gl(mi); reshape_cubicgrid(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } else { MI_CLEARWINDOW(mi); } { double spin_speed = 0.045 * speed; double spin_accel = 0.005 * speed; cp->rot = make_rotator (spin_speed, spin_speed, spin_speed, spin_accel, 0, True); cp->trackball = gltrackball_init (); } }
ENTRYPOINT void init_providence(ModeInfo *mi) { providencestruct *mp; if(!providence) { if((providence = (providencestruct *) calloc(MI_NUM_SCREENS(mi), sizeof (providencestruct))) == NULL) return; } mp = &providence[MI_SCREEN(mi)]; mp->trackball = gltrackball_init (); mp->position0[0] = 1; mp->position0[1] = 5; mp->position0[2] = 1; mp->position0[3] = 1; mp->camera_velocity = -8.0; mp->mono = MI_IS_MONO(mi); mp->wire = MI_IS_WIREFRAME(mi); /* make multiple screens rotate at slightly different rates. */ mp->theta_scale = 0.7 + frand(0.6); if((mp->glx_context = init_GL(mi)) != NULL) { reshape_providence(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); glDrawBuffer(GL_BACK); pinit(mp); } else MI_CLEARWINDOW(mi); }
ENTRYPOINT void init_bubble3d(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); int screen = MI_SCREEN(mi); struct context *c; if (contexts == 0) { contexts = (struct context *) calloc(sizeof (struct context), MI_NUM_SCREENS(mi)); if (contexts == 0) return; } c = &contexts[screen]; c->glx_context = init_GL(mi); init_colors(mi); if (c->glx_context != 0) { init(c); reshape_bubble3d(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); do_display(c); glFinish(); glXSwapBuffers(display, window); } else MI_CLEARWINDOW(mi); }
ENTRYPOINT void init_cube21(ModeInfo *mi) { cube21_conf *cp; MI_INIT(mi, cube21); cp = &cube21[MI_SCREEN(mi)]; cp->trackball = gltrackball_init (False); if(!cp->texp) { init_posc(cp); make_texture(cp); } #ifdef HAVE_MOBILE size *= 2; #endif if ((cp->glx_context = init_GL(mi)) != NULL) { init_gl(mi); init_cp(cp); reshape_cube21(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } else { MI_CLEARWINDOW(mi); } }
ENTRYPOINT void init_antspotlight(ModeInfo *mi) { double rot_speed = 0.3; antspotlightstruct *mp; if(!antspotlight) { if((antspotlight = (antspotlightstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (antspotlightstruct))) == NULL) return; } mp = &antspotlight[MI_SCREEN(mi)]; mp->rot = make_rotator (rot_speed, rot_speed, rot_speed, 1, 0, True); mp->trackball = gltrackball_init (); if((mp->glx_context = init_GL(mi)) != NULL) { reshape_antspotlight(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); glDrawBuffer(GL_BACK); pinit(); } else MI_CLEARWINDOW(mi); glGenTextures(1, &mp->screentexture); glBindTexture(GL_TEXTURE_2D, mp->screentexture); get_snapshot(mi); build_ant(mp); mp->mono = MI_IS_MONO(mi); mp->wire = MI_IS_WIREFRAME(mi); mp->boardsize = 8.0; mp->mag = 1; }
ENTRYPOINT void init_queens(ModeInfo *mi) { int screen = MI_SCREEN(mi); Queenscreen *qs; int poly_counts[PIECES]; wire = MI_IS_WIREFRAME(mi); # ifdef HAVE_JWZGLES /* #### glPolygonMode other than GL_FILL unimplemented */ wire = 0; # endif if(!qss && !(qss = (Queenscreen *) calloc(MI_NUM_SCREENS(mi), sizeof(Queenscreen)))) return; qs = &qss[screen]; qs->window = MI_WINDOW(mi); if((qs->glx_context = init_GL(mi))) reshape_queens(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); else MI_CLEARWINDOW(mi); qs->trackball = gltrackball_init (); qs->BOARDSIZE = 8; /* 8 cuz its classic */ chessmodels_gen_lists(-1, poly_counts); qs->queen_list = QUEEN; qs->queen_polys = poly_counts[QUEEN]; /* find a solution */ go(qs); }
/* xextrusion initialization routine */ ENTRYPOINT void init_extrusion (ModeInfo * mi) { int screen = MI_SCREEN(mi); extrusionstruct *gp; if (MI_IS_WIREFRAME(mi)) do_light = 0; if (Extrusion == NULL) { if ((Extrusion = (extrusionstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (extrusionstruct))) == NULL) return; } gp = &Extrusion[screen]; gp->window = MI_WINDOW(mi); if ((gp->glx_context = init_GL(mi)) != NULL) { reshape_extrusion(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); initializeGL(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); chooseExtrusionExample(mi); } else { MI_CLEARWINDOW(mi); } }
ENTRYPOINT void init_moebius (ModeInfo * mi) { moebiusstruct *mp; if (moebius == NULL) { if ((moebius = (moebiusstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (moebiusstruct))) == NULL) return; } mp = &moebius[MI_SCREEN(mi)]; mp->step = NRAND(90); mp->ant_position = NRAND(90); { double rot_speed = 0.3; mp->rot = make_rotator (rot_speed, rot_speed, rot_speed, 1, 0, True); mp->trackball = gltrackball_init (); } if ((mp->glx_context = init_GL(mi)) != NULL) { reshape_moebius(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); glDrawBuffer(GL_BACK); pinit(mi); } else { MI_CLEARWINDOW(mi); } }
ENTRYPOINT void init_hypertorus(ModeInfo *mi) { hypertorusstruct *hp; if (hyper == NULL) { hyper = (hypertorusstruct *)calloc(MI_NUM_SCREENS(mi), sizeof(hypertorusstruct)); if (hyper == NULL) return; } hp = &hyper[MI_SCREEN(mi)]; hp->trackballs[0] = gltrackball_init(); hp->trackballs[1] = gltrackball_init(); hp->current_trackball = 0; hp->button_pressed = False; /* make multiple screens rotate at slightly different rates. */ hp->speed_scale = 0.9 + frand(0.3); if ((hp->glx_context = init_GL(mi)) != NULL) { reshape_hypertorus(mi,MI_WIDTH(mi),MI_HEIGHT(mi)); glDrawBuffer(GL_BACK); init(mi); } else { MI_CLEARWINDOW(mi); } }
void init_morph3d(ModeInfo * mi) { morph3dstruct *mp; if (morph3d == NULL) { if ((morph3d = (morph3dstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (morph3dstruct))) == NULL) return; } mp = &morph3d[MI_SCREEN(mi)]; mp->step = NRAND(90); mp->VisibleSpikes = 1; if ((mp->glx_context = init_GL(mi)) != NULL) { reshape_morph3d(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); glDrawBuffer(GL_BACK); mp->object = MI_COUNT(mi); if (mp->object <= 0 || mp->object > 5) mp->object = NRAND(5) + 1; pinit(mi); } else { MI_CLEARWINDOW(mi); } }
ENTRYPOINT void init_rubikblocks(ModeInfo *mi) { rubikblocks_conf *cp; if(!rubikblocks) { rubikblocks = (rubikblocks_conf *)calloc(MI_NUM_SCREENS(mi), sizeof(rubikblocks_conf)); if(!rubikblocks) return; } cp = &rubikblocks[MI_SCREEN(mi)]; if(tex) make_texture(cp); if ((cp->glx_context = init_GL(mi)) != NULL) { init_gl(mi); init_cp(cp); init_lists(cp); reshape_rubikblocks(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } else { MI_CLEARWINDOW(mi); } }
ENTRYPOINT void init_providence(ModeInfo *mi) { providencestruct *mp; MI_INIT(mi, providence); mp = &providence[MI_SCREEN(mi)]; mp->trackball = gltrackball_init (False); mp->position0[0] = 1; mp->position0[1] = 5; mp->position0[2] = 1; mp->position0[3] = 1; mp->camera_velocity = -8.0; mp->mono = MI_IS_MONO(mi); mp->wire = MI_IS_WIREFRAME(mi); # ifdef HAVE_JWZGLES /* #### glPolygonMode other than GL_FILL unimplemented */ mp->wire = 0; # endif /* make multiple screens rotate at slightly different rates. */ mp->theta_scale = 0.7 + frand(0.6); if((mp->glx_context = init_GL(mi)) != NULL) { reshape_providence(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); /* glDrawBuffer(GL_BACK); */ pinit(mp); } else MI_CLEARWINDOW(mi); }
static void startover(ModeInfo * mi) { int j; sierpinskistruct *sp = &tris[MI_SCREEN(mi)]; if (MI_NPIXELS(mi) > 2) { if (sp->corners == 3) { sp->colors[0] = (NRAND(MI_NPIXELS(mi))); sp->colors[1] = (sp->colors[0] + MI_NPIXELS(mi) / 7 + NRAND(2 * MI_NPIXELS(mi) / 7 + 1)) % MI_NPIXELS(mi); sp->colors[2] = (sp->colors[0] + 4 * MI_NPIXELS(mi) / 7 + NRAND(2 * MI_NPIXELS(mi) / 7 + 1)) % MI_NPIXELS(mi); } else if (sp->corners == 4) { sp->colors[0] = (NRAND(MI_NPIXELS(mi))); sp->colors[1] = (sp->colors[0] + MI_NPIXELS(mi) / 7 + NRAND(MI_NPIXELS(mi) / 7 + 1)) % MI_NPIXELS(mi); sp->colors[2] = (sp->colors[0] + 3 * MI_NPIXELS(mi) / 7 + NRAND(MI_NPIXELS(mi) / 7 + 1)) % MI_NPIXELS(mi); sp->colors[3] = (sp->colors[0] + 5 * MI_NPIXELS(mi) / 7 + NRAND(MI_NPIXELS(mi) / 7 + 1)) % MI_NPIXELS(mi); } else { (void) fprintf(stderr, "colors not set for %d corners\n", sp->corners); } } for (j = 0; j < sp->corners; j++) { sp->vertex[j].x = NRAND(sp->width); sp->vertex[j].y = NRAND(sp->height); } sp->px = NRAND(sp->width); sp->py = NRAND(sp->height); sp->time = 0; MI_CLEARWINDOW(mi); }
ENTRYPOINT void init_lisa (ModeInfo * mi) { int lctr; lisacons *lc; if (Lisa == NULL) { if ((Lisa = (lisacons *) calloc(MI_NUM_SCREENS(mi), sizeof (lisacons))) == NULL) return; } lc = &Lisa[MI_SCREEN(mi)]; lc->width = MI_WIDTH(mi); lc->height = MI_HEIGHT(mi); lc->loopcount = 0; lc->nlissajous = MI_COUNT(mi); if (lc->nlissajous <= 0) lc->nlissajous = 1; MI_CLEARWINDOW(mi); lc->painted = False; if (lc->lissajous == NULL) { if ((lc->lissajous = (lisas *) calloc(lc->nlissajous, sizeof (lisas))) == NULL) return; for (lctr = 0; lctr < lc->nlissajous; lctr++) { if (!initlisa(mi, &lc->lissajous[lctr])) return; lc->loopcount++; } } else { refreshlisa(mi); } }
ENTRYPOINT void init_slideshow (ModeInfo *mi) { int screen = MI_SCREEN(mi); slideshow_state *ss; int wire = MI_IS_WIREFRAME(mi); if (sss == NULL) { if ((sss = (slideshow_state *) calloc (MI_NUM_SCREENS(mi), sizeof(slideshow_state))) == NULL) return; } ss = &sss[screen]; if ((ss->glx_context = init_GL(mi)) != NULL) { reshape_slideshow (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } else { MI_CLEARWINDOW(mi); } if (debug_p) fprintf (stderr, "%s: pan: %d; fade: %d; img: %d; zoom: %d%%\n", blurb(), pan_seconds, fade_seconds, image_seconds, zoom); sanity_check(mi); if (debug_p) fprintf (stderr, "%s: pan: %d; fade: %d; img: %d; zoom: %d%%\n\n", blurb(), pan_seconds, fade_seconds, image_seconds, zoom); glDisable (GL_LIGHTING); glDisable (GL_DEPTH_TEST); glDepthMask (GL_FALSE); glEnable (GL_CULL_FACE); glCullFace (GL_BACK); if (! wire) { glEnable (GL_TEXTURE_2D); glShadeModel (GL_SMOOTH); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } if (debug_p) glLineWidth (3); ss->font_data = load_texture_font (mi->dpy, "titleFont"); if (debug_p) hack_resources(); ss->now = double_time(); ss->dawn_of_time = ss->now; ss->prev_frame_time = ss->now; ss->awaiting_first_image_p = True; alloc_image (mi); }
ENTRYPOINT void init_fire(ModeInfo * mi) { firestruct *fs; /* allocate the main fire table if needed */ if (fire == NULL) { if ((fire = (firestruct *) calloc(MI_NUM_SCREENS(mi), sizeof(firestruct))) == NULL) return; } /* initialise the per screen fire structure */ fs = &fire[MI_SCREEN(mi)]; fs->np = MI_COUNT(mi); fs->fog = do_fog; fs->shadows = do_shadows; /* initialise fire particles if any */ if ((fs->np)&&(fs->p == NULL)) { if ((fs->p = (part *) calloc(fs->np, sizeof(part))) == NULL) { free_fire(fs); return; } } else if (fs->r == NULL) { /* initialise rain particles if no fire particles */ if ((fs->r = (rain *) calloc(NUMPART, sizeof(part))) == NULL) { free_fire(fs); return; } } /* check tree number */ if (do_texture) fs->num_trees = (num_trees<MAX_TREES)?num_trees:MAX_TREES; else fs->num_trees = 0; fs->trackball = gltrackball_init (); /* xlock GL stuff */ if ((fs->glx_context = init_GL(mi)) != NULL) { #ifndef STANDALONE Reshape(mi); /* xlock mode */ #else reshape_fire(mi,MI_WIDTH(mi),MI_HEIGHT(mi)); /* xscreensaver mode */ #endif glDrawBuffer(GL_BACK); if (!Init(mi)) { free_fire(fs); return; } } else { MI_CLEARWINDOW(mi); } }
ENTRYPOINT void init_commander(ModeInfo *mi) { commander_conf *cp; int i; int do_which = -1; if(!commander) { commander = (commander_conf *)calloc(MI_NUM_SCREENS(mi), sizeof(commander_conf)); if(!commander) return; } cp = &commander[MI_SCREEN(mi)]; if ((cp->glx_context = init_GL(mi)) != NULL) { init_gl(mi); cp->which = -1; reshape_commander(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } else { MI_CLEARWINDOW(mi); } { double spin_speed = 0.7 * speed; double spin_accel = 0.1 * speed; cp->rot = make_rotator (spin_speed, spin_speed, spin_speed, spin_accel, 0, True); cp->trackball = gltrackball_init (True); } /* figure out which ship to display */ /* do_which=-1 for "random" mode */ if(!strcasecmp (do_which_str, "random")) ; else { for(i=0;i<NUM_ELEM(ship_names);i++) { if(!strcasecmp(do_which_str, ship_names[i])) { do_which=i; cp->which=i; } } if(do_which<0) { fprintf(stderr, "%s: no such ship: \"%s\"\n", progname, do_which_str); exit(1); } } /* FIXME (what?) */ if(do_which==-1) { cp->which=random() % NUM_ELEM(ship_names); } new_ship(mi); }
void refresh_bouboule(ModeInfo * mi) { /* use the right `black' pixel values: */ if (MI_IS_INSTALL(mi) && MI_IS_USE3D(mi)) { MI_CLEARWINDOWCOLOR(mi, MI_NONE_COLOR(mi)); } else { MI_CLEARWINDOW(mi); } }
ENTRYPOINT void init_atlantis(ModeInfo * mi) { int screen = MI_SCREEN(mi); atlantisstruct *ap; Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); if (atlantis == NULL) { if ((atlantis = (atlantisstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (atlantisstruct))) == NULL) return; } ap = &atlantis[screen]; ap->num_sharks = MI_COUNT(mi); if (ap->sharks == NULL) { if ((ap->sharks = (fishRec *) calloc(ap->num_sharks, sizeof (fishRec))) == NULL) { /* free everything up to now */ (void) free((void *) atlantis); atlantis = NULL; return; } } ap->sharkspeed = MI_CYCLES(mi); /* has influence on the "width" of the movement */ ap->sharksize = MI_SIZE(mi); /* has influence on the "distance" of the sharks */ ap->whalespeed = whalespeed; ap->wire = MI_IS_WIREFRAME(mi); if (MI_IS_DEBUG(mi)) { (void) fprintf(stderr, "%s:\n\tnum_sharks=%d\n\tsharkspeed=%.1f\n\tsharksize=%d\n\twhalespeed=%.1f\n\twireframe=%s\n", MI_NAME(mi), ap->num_sharks, ap->sharkspeed, ap->sharksize, ap->whalespeed, ap->wire ? "yes" : "no" ); } if ((ap->glx_context = init_GL(mi)) != NULL) { reshape_atlantis(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); glDrawBuffer(GL_BACK); Init(mi); AllDisplay(ap); glXSwapBuffers(display, window); } else { MI_CLEARWINDOW(mi); } }
ENTRYPOINT void init_thornbird (ModeInfo * mi) { thornbirdstruct *hp; if (thornbirds == NULL) { if ((thornbirds = (thornbirdstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (thornbirdstruct))) == NULL) return; } hp = þbirds[MI_SCREEN(mi)]; hp->maxx = MI_WIDTH(mi); hp->maxy = MI_HEIGHT(mi); hp->b = 0.1; hp->i = hp->j = 0.1; hp->pix = 0; hp->inc = 0; hp->nbuffers = MI_CYCLES(mi); if (hp->pointBuffer == NULL) if ((hp->pointBuffer = (XPoint **) calloc(MI_CYCLES(mi), sizeof (XPoint *))) == NULL) { free_thornbird(hp); return; } if (hp->pointBuffer[0] == NULL) if ((hp->pointBuffer[0] = (XPoint *) malloc(MI_COUNT(mi) * sizeof (XPoint))) == NULL) { free_thornbird(hp); return; } /* select frequencies for parameter variation */ hp->liss.f1 = LRAND() % 5000; hp->liss.f2 = LRAND() % 2000; /* choose random 3D tumbling */ hp->tumble.theta = 0; hp->tumble.phi = 0; hp->tumble.dtheta = balance_rand(0.001); hp->tumble.dphi = balance_rand(0.005); /* Clear the background. */ MI_CLEARWINDOW(mi); hp->count = 0; }
ENTRYPOINT void draw_fadeplot (ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); GC gc = MI_GC(mi); int i, j, temp; fadeplotstruct *fp; if (fadeplots == NULL) return; fp = &fadeplots[MI_SCREEN(mi)]; if (fp->stab == NULL) return; MI_IS_DRAWN(mi) = True; XSetForeground(display, gc, MI_BLACK_PIXEL(mi)); XDrawPoints(display, window, gc, fp->pts, fp->maxpts, CoordModeOrigin); if (MI_NPIXELS(mi) > 2) { XSetForeground(display, gc, MI_PIXEL(mi, fp->pix)); if (++fp->pix >= MI_NPIXELS(mi)) fp->pix = 0; } else XSetForeground(display, gc, MI_WHITE_PIXEL(mi)); temp = 0; for (j = 0; j < fp->nbstep; j++) { for (i = 0; i < fp->maxpts / fp->nbstep; i++) { fp->pts[temp].x = fp->stab[(fp->st.x + fp->speed.x * j + i * fp->step.x) % fp->angles] * fp->factor.x + fp->width / 2 - fp->min; fp->pts[temp].y = fp->stab[(fp->st.y + fp->speed.y * j + i * fp->step.y) % fp->angles] * fp->factor.y + fp->height / 2 - fp->min; temp++; } } XDrawPoints(display, window, gc, fp->pts, temp, CoordModeOrigin); fp->st.x = (fp->st.x + fp->speed.x) % fp->angles; fp->st.y = (fp->st.y + fp->speed.y) % fp->angles; fp->temps++; if ((fp->temps % (fp->angles / 2)) == 0) { fp->temps = fp->temps % fp->angles * 5; if ((fp->temps % (fp->angles)) == 0) fp->speed.y = (fp->speed.y + 1) % 30 + 1; if ((fp->temps % (fp->angles * 2)) == 0) fp->speed.x = (fp->speed.x) % 20; if ((fp->temps % (fp->angles * 3)) == 0) fp->step.y = (fp->step.y + 1) % 2 + 1; MI_CLEARWINDOW(mi); } }
ENTRYPOINT Bool hop_handle_event (ModeInfo *mi, XEvent *event) { if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event)) { MI_CLEARWINDOW(mi); init_hop (mi); return True; } return False; }
ENTRYPOINT void init_screenflip(ModeInfo *mi) { int screen = MI_SCREEN(mi); Screenflip *c; if (screenflip == NULL) { if ((screenflip = (Screenflip *) calloc(MI_NUM_SCREENS(mi), sizeof(Screenflip))) == NULL) return; } c = &screenflip[screen]; c->window = MI_WINDOW(mi); c->trackball = gltrackball_init (); if ((c->glx_context = init_GL(mi)) != NULL) { reshape_screenflip(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } else { MI_CLEARWINDOW(mi); } c->winh = MI_WIN_HEIGHT(mi); c->winw = MI_WIN_WIDTH(mi); c->qw = QW; c->qh = QH; c->qx = -6; c->qy = 6; c->rx = c->ry = 1; c->odrot = 1; c->show_colors[0] = c->show_colors[1] = c->show_colors[2] = c->show_colors[3] = 1; if (! MI_IS_WIREFRAME(mi)) { glShadeModel(GL_SMOOTH); glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glDisable(GL_LIGHTING); } if (strstr ((char *) glGetString(GL_EXTENSIONS), "GL_EXT_texture_filter_anisotropic")) glGetFloatv (GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &c->anisotropic); else c->anisotropic = 0.0; glGenTextures(1, &c->texid); c->first_image_p = True; getSnapshot(mi); }
/* Resets state of ghosts + pacman. Creates a new level, draws that level. */ static void repopulate(ModeInfo * mi) { pacmangamestruct *pp = &pacmangames[MI_SCREEN(mi)]; unsigned int ghost; int i = createnewlevel(mi); MI_CLEARWINDOW(mi); drawlevel(mi); pp->gamestate = GHOST_DANGER; pp->pacman.row = (LEVHEIGHT + JAILHEIGHT)/2 - i; pp->pacman.col = (LEVWIDTH/2); pp->pacman.nextrow = NOWHERE; pp->pacman.nextcol = NOWHERE; pp->pacman.cf = NOWHERE; pp->pacman.rf = NOWHERE; pp->pacman.oldcf = NOWHERE; pp->pacman.oldrf = NOWHERE; pp->pacman.oldlx = NOWHERE; pp->pacman.oldly = NOWHERE; pp->pacman.aistate = ps_eating; pp->pacman.cur_trace = 0; pp->pacman.roundscore = 0; pp->pacman.speed = 4; pp->pacman.lastturn = 0; pp->pacman.delta.x = 0; pp->pacman.delta.y = 0; pac_clear_trace(&(pp->pacman)); for (ghost = 0; ghost < pp->nghosts; ghost++) { pp->ghosts[ghost].col = (LEVWIDTH/2); pp->ghosts[ghost].row = (LEVHEIGHT/2); pp->ghosts[ghost].nextcol = NOWHERE; pp->ghosts[ghost].nextrow = NOWHERE; pp->ghosts[ghost].dead = 0; pp->ghosts[ghost].lastbox = START; pp->ghosts[ghost].cf = NOWHERE; pp->ghosts[ghost].rf = NOWHERE; pp->ghosts[ghost].oldcf = NOWHERE; pp->ghosts[ghost].oldrf = NOWHERE; pp->ghosts[ghost].aistate = inbox; pp->ghosts[ghost].timeleft = ghost * 50; pp->ghosts[ghost].speed = 3; pp->ghosts[ghost].delta.x = 0; pp->ghosts[ghost].delta.y = 0; ghost_update(pp, &(pp->ghosts[ghost])); } check_death(mi, pp); pac_update(mi, pp, &(pp->pacman)); }
void init_gasket(ModeInfo *mi) { int screen = MI_SCREEN(mi); gasketstruct *gp; if (gasket == NULL) { if ((gasket = (gasketstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (gasketstruct))) == NULL) return; } gp = &gasket[screen]; gp->window = MI_WINDOW(mi); gp->rotx = FLOATRAND(1.0) * RANDSIGN(); gp->roty = FLOATRAND(1.0) * RANDSIGN(); gp->rotz = FLOATRAND(1.0) * RANDSIGN(); /* bell curve from 0-1.5 degrees, avg 0.75 */ gp->dx = (FLOATRAND(1) + FLOATRAND(1) + FLOATRAND(1)) / (360*2); gp->dy = (FLOATRAND(1) + FLOATRAND(1) + FLOATRAND(1)) / (360*2); gp->dz = (FLOATRAND(1) + FLOATRAND(1) + FLOATRAND(1)) / (360*2); gp->d_max = gp->dx * 2; gp->ddx = 0.00006 + FLOATRAND(0.00003); gp->ddy = 0.00006 + FLOATRAND(0.00003); gp->ddz = 0.00006 + FLOATRAND(0.00003); gp->ddx = 0.00001; gp->ddy = 0.00001; gp->ddz = 0.00001; intens_factor = intensity / 65536000.0; gp->ncolors = 255; gp->colors = (XColor *) calloc(gp->ncolors, sizeof(XColor)); make_smooth_colormap (mi, None, gp->colors, &gp->ncolors, False, (Bool *) NULL); if ((gp->glx_context = init_GL(mi)) != NULL) { reshape_gasket(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); pinit(mi); } else { MI_CLEARWINDOW(mi); } }