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); } }
ENTRYPOINT void init_stonerview (ModeInfo *mi) { stonerview_configuration *bp; if (!bps) { bps = (stonerview_configuration *) calloc (MI_NUM_SCREENS(mi), sizeof (stonerview_configuration)); if (!bps) { fprintf(stderr, "%s: out of memory\n", progname); exit(1); } bp = &bps[MI_SCREEN(mi)]; } bp = &bps[MI_SCREEN(mi)]; bp->glx_context = init_GL(mi); bp->trackball = gltrackball_init (); bp->st = init_view(MI_IS_WIREFRAME(mi)); init_move(bp->st); reshape_stonerview (mi, MI_WIDTH(mi), MI_HEIGHT(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_stonerview (ModeInfo *mi) { stonerview_configuration *bp; if (!bps) { bps = (stonerview_configuration *) calloc (MI_NUM_SCREENS(mi), sizeof (stonerview_configuration)); if (!bps) { fprintf(stderr, "%s: out of memory\n", progname); exit(1); } } bp = &bps[MI_SCREEN(mi)]; bp->glx_context = init_GL(mi); bp->trackball = gltrackball_init (); bp->st = stonerview_init_view(MI_IS_WIREFRAME(mi), transparent_p); stonerview_init_move(bp->st); reshape_stonerview (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); clear_gl_error(); /* WTF? sometimes "invalid op" from glViewport! */ }
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); }
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_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 (); } }
static void init_cp(rubikblocks_conf *cp) { int i, j, k, m; cp->pause = True; cp->t = 0.0; cp->tmax = twait; for(i = -1, m = 0; i <= 1; i++) for(j = -1; j <= 1; j++) for(k = -1; k <= 1; k++) { cp->pieces[m].pos[0] = k; cp->pieces[m].pos[1] = j; cp->pieces[m].pos[2] = i; cp->pieces[m].qr[0] = 1; cp->pieces[m].qr[1] = 0; cp->pieces[m].qr[2] = 0; cp->pieces[m].qr[3] = 0; m++; } cp->rot = make_rotator(spin?spinspeed:0, spin?spinspeed:0, spin?spinspeed:0, 0.1, wander?wspeed:0, True); cp->trackball = gltrackball_init(True); if(rndstart) randomize(cp); }
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_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); }
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_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_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_cube (ModeInfo *mi) { int i; cube_configuration *cc; MI_INIT (mi, ccs); cc = &ccs[MI_SCREEN(mi)]; if ((cc->glx_context = init_GL(mi)) != NULL) { reshape_cube (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } cc->trackball = gltrackball_init (False); cc->ncolors = 256; cc->colors = (XColor *) calloc(cc->ncolors, sizeof(XColor)); reset_colors (mi); init_wave (mi); cc->ncubes = MI_COUNT (mi); if (cc->ncubes < 1) cc->ncubes = 1; cc->cubes = (cube *) calloc (sizeof(cube), cc->ncubes); for (i = 0; i < cc->ncubes; i++) { /* Set the size to roughly cover a 2x2 square on average. */ GLfloat scale = 1.8 / sqrt (cc->ncubes); cube *cube = &cc->cubes[i]; double th = -(skew ? frand(skew) : 0) * M_PI / 180; cube->x = (frand(1)-0.5); cube->y = (frand(1)-0.5); cube->z = frand(0.12); cube->cth = cos(th); cube->sth = sin(th); cube->w = scale * (frand(1) + 0.2); cube->d = scale * (frand(1) + 0.2); if (cube->x < cc->min_x) cc->min_x = cube->x; if (cube->y < cc->min_y) cc->min_y = cube->y; if (cube->x > cc->max_x) cc->max_x = cube->x; if (cube->y > cc->max_y) cc->max_y = cube->y; } /* Sorting by depth improves frame rate slightly. With 6000 polygons we get: 3.9 FPS unsorted; 3.1 FPS back to front; 4.3 FPS front to back. */ qsort (cc->cubes, cc->ncubes, sizeof(*cc->cubes), cmp_cubes); }
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); }
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); }
ENTRYPOINT void init_pinion (ModeInfo *mi) { pinion_configuration *pp; int wire = MI_IS_WIREFRAME(mi); if (!pps) { pps = (pinion_configuration *) calloc (MI_NUM_SCREENS(mi), sizeof (pinion_configuration)); if (!pps) { fprintf(stderr, "%s: out of memory\n", progname); exit(1); } pp = &pps[MI_SCREEN(mi)]; } pp = &pps[MI_SCREEN(mi)]; pp->glx_context = init_GL(mi); load_fonts (mi); reshape_pinion (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); pp->title_list = glGenLists (1); pp->ngears = 0; pp->gears_size = 0; pp->gears = 0; pp->plane_displacement = gear_size * 0.1; if (!wire) { GLfloat pos[4] = {-3.0, 1.0, 1.0, 0.0}; GLfloat amb[4] = { 0.0, 0.0, 0.0, 1.0}; GLfloat dif[4] = { 1.0, 1.0, 1.0, 1.0}; GLfloat spc[4] = { 1.0, 1.0, 1.0, 1.0}; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glLightfv(GL_LIGHT0, GL_POSITION, pos); glLightfv(GL_LIGHT0, GL_AMBIENT, amb); glLightfv(GL_LIGHT0, GL_DIFFUSE, dif); glLightfv(GL_LIGHT0, GL_SPECULAR, spc); } pp->trackball = gltrackball_init (); ffwd (mi); }
ENTRYPOINT void init_stream (ModeInfo *mi) { stream_configuration *es; streamtime current_time; MI_INIT (mi, ess); es = &ess[MI_SCREEN(mi)]; es->glx_context = init_GL (mi); reshape_stream (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); gettime (¤t_time); es->start_time = GETSECS(current_time) * 1000 + GETMSECS(current_time); es->num_streams = num_streams; es->streams = (flare_stream *) calloc (es->num_streams, sizeof(flare_stream)); init_flare_stream (&es->streams[0], 150, 0, 50, 0, 300); init_flare_stream (&es->streams[1], 150, 0, 0, 0, 150); init_flare_stream (&es->streams[2], 150, 0, 90, 60, 250); init_flare_stream (&es->streams[3], 150, 0, -100, 30, 160); init_flare_stream (&es->streams[4], 150, 0, 50, -100, 340); init_flare_stream (&es->streams[5], 150, 0, -50, 50, 270 ); init_flare_stream (&es->streams[6], 150, 0, 100, 50, 180); init_flare_stream (&es->streams[7], 150, 0, -30, 90, 130); init_flare_stream (&es->streams[8], 150, 0, 150, 10, 200); init_flare_stream (&es->streams[9], 150, 0, 100, -100, 210); init_flare_stream (&es->streams[10], 150, 0, 190, 160, 220); init_flare_stream (&es->streams[11], 150, 0, -200, 130, 230); init_flare_stream (&es->streams[12], 150, 0, 150, -200, 240); init_flare_stream (&es->streams[13], 150, 0, -150, 250, 160); init_flare_stream (&es->streams[14], 150, 0, 200, 150, 230); init_flare_stream (&es->streams[15], 150, 0, -130, 190, 250); { double spin_speed = 0.5 * global_speed; double wander_speed = 0.02 * global_speed; double spin_accel = 1.1; es->rot = make_rotator (do_spin ? spin_speed : 0, do_spin ? spin_speed : 0, do_spin ? spin_speed : 0, spin_accel, do_wander ? wander_speed : 0, True); es->trackball = gltrackball_init (True); } }
static void init_rotation (ModeInfo *mi) { extrusionstruct *gp = &Extrusion[MI_SCREEN(mi)]; double spin_speed = 0.5; gp->rot = make_rotator (spin_speed, spin_speed, spin_speed, 0.2, 0.005, True); gp->trackball = gltrackball_init (); lastx = (random() % (int) (max_lastx - min_lastx)) + min_lastx; lasty = (random() % (int) (max_lasty - min_lasty)) + min_lasty; }
ENTRYPOINT 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); { double spin_speed = 1.0; double wander_speed = 0.03; gp->rot = make_rotator (do_spin ? spin_speed : 0, do_spin ? spin_speed : 0, do_spin ? spin_speed : 0, 1.0, do_wander ? wander_speed : 0, True); gp->trackball = gltrackball_init (); } gp->ncolors = 255; gp->colors = (XColor *) calloc(gp->ncolors, sizeof(XColor)); make_smooth_colormap (0, 0, 0, gp->colors, &gp->ncolors, False, 0, False); gp->ccolor0 = 0; gp->ccolor1 = gp->ncolors * 0.25; gp->ccolor2 = gp->ncolors * 0.5; gp->ccolor3 = gp->ncolors * 0.75; gp->tick = 999999; if ((gp->glx_context = init_GL(mi)) != NULL) { reshape_gasket(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); pinit(mi); } else { MI_CLEARWINDOW(mi); } }
ENTRYPOINT void init_bit (ModeInfo *mi) { bit_configuration *bp; int i; if (!bps) { bps = (bit_configuration *) calloc (MI_NUM_SCREENS(mi), sizeof (bit_configuration)); if (!bps) { fprintf(stderr, "%s: out of memory\n", progname); exit(1); } } bp = &bps[MI_SCREEN(mi)]; bp->glx_context = init_GL(mi); reshape_bit (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); { double spin_speed = 3.0; double wander_speed = 0.03 * speed; double spin_accel = 4.0; bp->rot = make_rotator (do_spin ? spin_speed : 0, do_spin ? spin_speed : 0, do_spin ? spin_speed : 0, spin_accel, do_wander ? wander_speed : 0, False); bp->trackball = gltrackball_init (); } for (i = 0; i < countof(bp->dlists); i++) { bp->dlists[i] = glGenLists (1); glNewList (bp->dlists[i], GL_COMPILE); bp->polys [i] = make_bit (mi, i); glEndList (); } bp->frequency = 0.30 / speed; /* parity around 3x/second */ bp->confidence = 0.06; /* provide answer 1/15 or so */ for (i = 0; i < countof(bp->histogram); i++) bp->histogram[i] = 128 + (random() % 16) - 8; }
ENTRYPOINT void init_queens(ModeInfo *mi) { int screen = MI_SCREEN(mi); Queenscreen *qs; wire = MI_IS_WIREFRAME(mi); if(!qss && !(qss = (Queenscreen *) calloc(MI_NUM_SCREENS(mi), sizeof(Queenscreen)))) return; qs = &qss[screen]; qs->window = MI_WINDOW(mi); qs->trackball = gltrackball_init (); qs->BOARDSIZE = 8; /* 8 cuz its classic */ if((qs->glx_context = init_GL(mi))) reshape_queens(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); else MI_CLEARWINDOW(mi); glClearColor(0.0, 0.0, 0.0, 0.0); glNewList(QUEEN, GL_COMPILE); qs->queen_polys = draw_model(countof(spidermodel), spidermodel, 24); glEndList(); if(flat) glShadeModel(GL_FLAT); clearbits = GL_COLOR_BUFFER_BIT; glColorMaterial(GL_FRONT, GL_DIFFUSE); glEnable(GL_COLOR_MATERIAL); if(!wire) { setup_lights(qs); glEnable(GL_DEPTH_TEST); clearbits |= GL_DEPTH_BUFFER_BIT; clearbits |= GL_STENCIL_BUFFER_BIT; glEnable(GL_CULL_FACE); glCullFace(GL_BACK); } else glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); /* find a solution */ go(qs); }
ENTRYPOINT void init_hexstrut (ModeInfo *mi) { hexstrut_configuration *bp; MI_INIT (mi, bps, free_hexstrut); bp = &bps[MI_SCREEN(mi)]; bp->glx_context = init_GL(mi); reshape_hexstrut (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); { double spin_speed = 0.002; double wander_speed = 0.003; double spin_accel = 1.0; bp->rot = make_rotator (do_spin ? spin_speed : 0, do_spin ? spin_speed : 0, do_spin ? spin_speed : 0, spin_accel, do_wander ? wander_speed : 0, False); bp->trackball = gltrackball_init (True); } /* Let's tilt the scene a little. */ gltrackball_reset (bp->trackball, -0.4 + frand(0.8), -0.4 + frand(0.8)); if (thickness < 0.05) thickness = 0.05; if (thickness < 0.05) MI_IS_WIREFRAME(mi) = True; if (thickness > 1.7) thickness = 1.7; if (speed > 2) speed = 2; bp->ncolors = 64; bp->colors = (XColor *) calloc(bp->ncolors, sizeof(XColor)); make_smooth_colormap (0, 0, 0, bp->colors, &bp->ncolors, False, 0, False); make_plane (mi); }
/* xgflux initialization routine */ ENTRYPOINT void init_gflux(ModeInfo * mi) { int screen = MI_SCREEN(mi); gfluxstruct *gp; if (gfluxes == NULL) { if ((gfluxes = (gfluxstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (gfluxstruct))) == NULL) return; } gp = &gfluxes[screen]; gp->trackball = gltrackball_init (); gp->time = frand(1000.0); /* don't run two screens in lockstep */ { //char *s = get_string_resource (mi->dpy, "mode", "Mode"); char *s = _strdup(mode); if (!s || !*s) _draw = wire; else if (!strcasecmp (s, "wire")) _draw = wire; else if (!strcasecmp (s, "solid")) _draw = solid; else if (!strcasecmp (s, "light")) _draw = light; else if (!strcasecmp (s, "checker")) _draw = checker; else if (!strcasecmp (s, "grab")) _draw = grab; else { fprintf (stderr, "%s: mode must be one of: wire, solid, " "light, checker, or grab; not \"%s\"\n", progname, s); exit (1); } } gp->modeinfo = mi; gp->window = MI_WINDOW(mi); if ((gp->glx_context = init_GL(mi)) != NULL) { reshape_gflux(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); initializeGL(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } else { MI_CLEARWINDOW(mi); } }
ENTRYPOINT void init_antinspect(ModeInfo * mi) { antinspectstruct *mp; MI_INIT(mi, antinspect); mp = &antinspect[MI_SCREEN(mi)]; mp->step = NRAND(90); mp->ant_position = NRAND(90); mp->trackball = gltrackball_init (False); if ((mp->glx_context = init_GL(mi)) != NULL) { reshape_antinspect(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); glDrawBuffer(GL_BACK); pinit(); } else MI_CLEARWINDOW(mi); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); }
ENTRYPOINT void init_sballs(ModeInfo * mi) { sballsstruct *sb; MI_INIT(mi, sballs, free_sballs); sb = &sballs[MI_SCREEN(mi)]; sb->trackball = gltrackball_init (True); if ((sb->glx_context = init_GL(mi)) != NULL) { #ifndef STANDALONE Reshape(mi); /* xlock mode */ #else reshape_sballs(mi,MI_WIDTH(mi),MI_HEIGHT(mi)); /* xscreensaver mode */ #endif glDrawBuffer(GL_BACK); Init(mi); } else { MI_CLEARWINDOW(mi); } }
ENTRYPOINT void init_cube21(ModeInfo *mi) { cube21_conf *cp; if(!cube21) { cube21 = (cube21_conf *)calloc(MI_NUM_SCREENS(mi), sizeof(cube21_conf)); if(!cube21) return; } cp = &cube21[MI_SCREEN(mi)]; cp->trackball = gltrackball_init (False); if(!cp->texp) { init_posc(cp); make_texture(cp); } 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_ball (ModeInfo *mi) { ball_configuration *bp; int wire = MI_IS_WIREFRAME(mi); MI_INIT (mi, bps); bp = &bps[MI_SCREEN(mi)]; bp->glx_context = init_GL(mi); if (! wire) build_texture (mi); reshape_ball (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); bp->th = 180 - frand(360); if (MI_COUNT(mi) < 10) MI_COUNT(mi) = 10; if (MI_COUNT(mi) > 200) MI_COUNT(mi) = 200; { double spin_speed = 0.1; double wander_speed = 0.003; double spin_accel = 1; bp->rot = make_rotator (do_spin ? spin_speed : 0, do_spin ? spin_speed : 0, do_spin ? spin_speed : 0, spin_accel, do_wander ? wander_speed : 0, False); bp->trackball = gltrackball_init (True); } build_ball (mi); if (!wire) { GLfloat color[4] = {0.5, 0.5, 0.5, 1}; GLfloat cspec[4] = {1, 1, 1, 1}; static const GLfloat shiny = 10; static GLfloat pos0[4] = { 0.5, -1, -0.5, 0}; static GLfloat pos1[4] = {-0.75, -1, 0, 0}; static GLfloat amb[4] = {0, 0, 0, 1}; static GLfloat dif[4] = {1, 1, 1, 1}; static GLfloat spc[4] = {1, 1, 1, 1}; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); color[0] += frand(0.2); color[1] += frand(0.2); color[2] += frand(0.2); cspec[0] -= frand(0.2); cspec[1] -= frand(0.2); cspec[2] -= frand(0.2); glLightfv(GL_LIGHT0, GL_POSITION, pos0); glLightfv(GL_LIGHT0, GL_AMBIENT, amb); glLightfv(GL_LIGHT0, GL_DIFFUSE, dif); glLightfv(GL_LIGHT0, GL_SPECULAR, spc); glLightfv(GL_LIGHT1, GL_POSITION, pos1); glLightfv(GL_LIGHT1, GL_AMBIENT, amb); glLightfv(GL_LIGHT1, GL_DIFFUSE, dif); glLightfv(GL_LIGHT1, GL_SPECULAR, spc); glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color); glMaterialfv (GL_FRONT, GL_SPECULAR, cspec); glMateriali (GL_FRONT, GL_SHININESS, shiny); } }
ENTRYPOINT void init_planet (ModeInfo * mi) { planetstruct *gp; int screen = MI_SCREEN(mi); Bool wire = MI_IS_WIREFRAME(mi); if (planets == NULL) { if ((planets = (planetstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (planetstruct))) == NULL) return; } gp = &planets[screen]; if ((gp->glx_context = init_GL(mi)) != NULL) { reshape_planet(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } { //char *f = get_string_resource(mi->dpy, "imageForeground", "Foreground"); //char *b = get_string_resource(mi->dpy, "imageBackground", "Background"); char *f = _strdup(imageForeground); char *b = _strdup(imageBackground); char *s; if (!f) f = _strdup("white"); if (!b) b = _strdup("black"); for (s = f + strlen(f)-1; s > f; s--) if (*s == ' ' || *s == '\t') *s = 0; for (s = b + strlen(b)-1; s > b; s--) if (*s == ' ' || *s == '\t') *s = 0; if (!XParseColor(mi->dpy, mi->xgwa.colormap, f, &gp->fg)) { fprintf(stderr, "%s: unparsable color: \"%s\"\n", progname, f); exit(1); } if (!XParseColor(mi->dpy, mi->xgwa.colormap, b, &gp->bg)) { fprintf(stderr, "%s: unparsable color: \"%s\"\n", progname, f); exit(1); } free (f); free (b); } { double spin_speed = 0.5; double wander_speed = 0.02; gp->rot = make_rotator (do_roll ? spin_speed : 0, do_roll ? spin_speed : 0, 0, 1, do_wander ? wander_speed : 0, True); gp->z = frand (1.0); gp->trackball = gltrackball_init (); } if (wire) { do_texture = False; do_light = False; } if (do_texture) setup_texture (mi); if (do_light) init_sun (mi); if (do_stars) init_stars (mi); if (random() & 1) star_spin = -star_spin; /* construct the polygons of the planet */ gp->platelist = glGenLists(1); glNewList (gp->platelist, GL_COMPILE); glColor3f (1,1,1); glPushMatrix (); glScalef (RADIUS, RADIUS, RADIUS); glRotatef (90, 1, 0, 0); glFrontFace(GL_CCW); unit_sphere (resolution, resolution, wire); glPopMatrix (); glEndList(); /* construct the polygons of the latitude/longitude/axis lines. */ gp->latlonglist = glGenLists(1); glNewList (gp->latlonglist, GL_COMPILE); glPushMatrix (); glDisable (GL_TEXTURE_2D); glDisable (GL_LIGHTING); glDisable (GL_LINE_SMOOTH); glColor3f (0.1, 0.3, 0.1); glScalef (RADIUS, RADIUS, RADIUS); glScalef (1.01, 1.01, 1.01); glRotatef (90, 1, 0, 0); unit_sphere (12, 24, 1); glBegin(GL_LINES); glVertex3f(0, -2, 0); glVertex3f(0, 2, 0); glEnd(); glPopMatrix (); glEndList(); }
ENTRYPOINT void init_spheremonics (ModeInfo *mi) { spheremonics_configuration *cc; MI_INIT (mi, ccs); cc = &ccs[MI_SCREEN(mi)]; if ((cc->glx_context = init_GL(mi)) != NULL) { gl_init(mi); reshape_spheremonics (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } { Bool spinx=False, spiny=False, spinz=False; double spin_speed = 1.0; double wander_speed = 0.03; char *s = do_spin; while (*s) { if (*s == 'x' || *s == 'X') spinx = True; else if (*s == 'y' || *s == 'Y') spiny = True; else if (*s == 'z' || *s == 'Z') spinz = True; else if (*s == '0') ; else { fprintf (stderr, "%s: spin must contain only the characters X, Y, or Z (not \"%s\")\n", progname, do_spin); exit (1); } s++; } cc->rot = make_rotator (spinx ? spin_speed : 0, spinz ? spin_speed : 0, spiny ? spin_speed : 0, 1.0, do_wander ? wander_speed : 0, (spinx && spiny && spinz)); cc->trackball = gltrackball_init (True); } cc->tracer = -1; cc->mesher = -1; cc->resolution = res; cc->font_data = load_texture_font (mi->dpy, "labelfont"); cc->dlist = glGenLists(1); cc->dlist2 = glGenLists(1); cc->m_max = 4; /* 9? */ { unsigned int i; for (i = 0; i < countof(cc->dm); i++) cc->dm[i] = 1; /* going up! */ /* Generate a few more times so we don't always start off with a sphere */ for (i = 0; i < 5; i++) tweak_parameters (mi); } generate_spheremonics(mi); }