コード例 #1
0
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);
}
コード例 #2
0
ファイル: antspotlight.c プロジェクト: RazZziel/pongclock
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;
}
コード例 #3
0
ファイル: cubicgrid.c プロジェクト: RazZziel/pongclock
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 ();
  }
}
コード例 #4
0
/* Allocates a frame structure and stores it in the list.
 */
static image_frame *
alloc_frame (ModeInfo *mi)
{
  carousel_state *ss = &sss[MI_SCREEN(mi)];
  image_frame *frame = (image_frame *) calloc (1, sizeof (*frame));

  frame->mi = mi;
  frame->mode = EARLY;
  frame->rot = make_rotator (0, 0, 0, 0, 0.04 * frand(1.0) * speed, False);

  glGenTextures (1, &frame->current.texid);
  glGenTextures (1, &frame->loading.texid);
  if (frame->current.texid <= 0) abort();
  if (frame->loading.texid <= 0) abort();

  if (ss->frames_size <= ss->nframes)
    {
      ss->frames_size = (ss->frames_size * 1.2) + ss->nframes;
      ss->frames = (image_frame **)
        realloc (ss->frames, ss->frames_size * sizeof(*ss->frames));
      if (! ss->frames)
        {
          fprintf (stderr, "%s: out of memory (%d images)\n",
                   progname, ss->frames_size);
          exit (1);
        }
    }

  ss->frames[ss->nframes++] = frame;

  return frame;
}
コード例 #5
0
ファイル: moebius.c プロジェクト: davehorner/XScreenSaverWin
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);
	}
}
コード例 #6
0
ファイル: commander.c プロジェクト: davebiffuk/commander
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);

}
コード例 #7
0
ファイル: energystream.c プロジェクト: Zygo/xscreensaver
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 (&current_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);
  }
}
コード例 #8
0
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;
}
コード例 #9
0
ENTRYPOINT void
draw_cube (ModeInfo *mi)
{
  cube_configuration *bp = &bps[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);
  int i;

  if (!bp->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix ();
  glRotatef(current_device_rotation(), 0, 0, 1);
  gltrackball_rotate (bp->trackball);

  glScalef (2, 2, 2);

  mi->polygon_count = 0;

# if 0
  {
    floater F;
    F.x = F.y = F.z = 0;
    F.dx = F.dy = F.dz = 0;
    F.ddx = F.ddy = F.ddz = 0;
    F.rot = make_rotator (0, 0, 0, 1, 0, False);
    glRotatef (45, 0, 1, 0);
    draw_floater (mi, &F);
  }
# else
  for (i = 0; i < bp->nfloaters; i++)
    {
      floater *f = &bp->floaters[i];
      draw_floater (mi, f);
      tick_floater (mi, f);
    }
# endif

  glPopMatrix ();

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}
コード例 #10
0
ファイル: sierpinski3d.c プロジェクト: RazZziel/pongclock
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);
  }
}
コード例 #11
0
ファイル: tronbit.c プロジェクト: BuBuaBu/bang-screensaver
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;
}
コード例 #12
0
ファイル: hexstrut.c プロジェクト: sev-/xscreensaver
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);
}
コード例 #13
0
ファイル: molecule.c プロジェクト: david-sackmary/distro-mods
ENTRYPOINT void 
init_molecule (ModeInfo *mi)
{
  molecule_configuration *mc;
  int wire;

  if (!mcs) {
    mcs = (molecule_configuration *)
      calloc (MI_NUM_SCREENS(mi), sizeof (molecule_configuration));
    if (!mcs) {
      fprintf(stderr, "%s: out of memory\n", progname);
      exit(1);
    }
  }

  mc = &mcs[MI_SCREEN(mi)];

  if ((mc->glx_context = init_GL(mi)) != NULL) {
    gl_init(mi);
    reshape_molecule (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
  }

  load_fonts (mi);
  startup_blurb (mi);

  wire = MI_IS_WIREFRAME(mi);

  {
    Bool spinx=False, spiny=False, spinz=False;
    double spin_speed   = 0.5;
    double spin_accel   = 0.3;
    double wander_speed = 0.01;

    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++;
      }

    mc->rot = make_rotator (spinx ? spin_speed : 0,
                            spiny ? spin_speed : 0,
                            spinz ? spin_speed : 0,
                            spin_accel,
                            do_wander ? wander_speed : 0,
                            (spinx && spiny && spinz));
    mc->trackball = gltrackball_init ();
  }

  orig_do_labels = do_labels;
  orig_do_atoms  = do_atoms;
  orig_do_bonds  = do_bonds;
  orig_do_shells = do_shells;
  orig_wire = MI_IS_WIREFRAME(mi);

  mc->molecule_dlist = glGenLists(1);
  if (do_shells)
    mc->shell_dlist = glGenLists(1);

  load_molecules (mi);
  mc->which = random() % mc->nmolecules;

  mc->no_label_threshold = get_float_resource (mi->dpy, "noLabelThreshold",
                                               "NoLabelThreshold");
  mc->wireframe_threshold = get_float_resource (mi->dpy, "wireframeThreshold",
                                                "WireframeThreshold");
  mc->mode = 0;

  if (wire)
    do_bonds = 1;
}
コード例 #14
0
ファイル: lament.c プロジェクト: Ro6afF/XScreenSaver
ENTRYPOINT void
init_lament (ModeInfo *mi)
{
  lament_configuration *lc;
  int i;
  if (!lcs)
    {
      lcs = (lament_configuration *)
	calloc(MI_NUM_SCREENS(mi), sizeof (lament_configuration));
      if (!lcs)
	{
	  fprintf(stderr, "%s: out of memory\n", progname);
	  exit(1);
	}
    }

  lc = &lcs[MI_SCREEN(mi)];

  {
    double rot_speed = 0.5;
    lc->rot = make_rotator (rot_speed, rot_speed, rot_speed, 1, 0, True);
    lc->trackball = gltrackball_init (True);
  }

  lc->type = LAMENT_BOX;
  lc->anim_pause = 300 + (random() % 100);

  if ((lc->glx_context = init_GL(mi)) != NULL)
    {
      reshape_lament(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
      gl_init(mi);
    }

  lc->states = (lament_type *) calloc (200, sizeof (*lc->states));
  lc->nstates = 0;

# define PUSH(N,WHICH) \
    for (i = 0; i < N; i++) lc->states[lc->nstates++] = WHICH

  PUSH (4, LAMENT_TETRA_UNE);		/* most common */
  PUSH (4, LAMENT_TETRA_USW);
  PUSH (4, LAMENT_TETRA_DWN);
  PUSH (4, LAMENT_TETRA_DSE);

  PUSH (8, LAMENT_STAR_OUT);		/* pretty common */
  PUSH (8, LAMENT_TASER_OUT);
  PUSH (8, LAMENT_PILLAR_OUT);

  PUSH (4, LAMENT_LID_OPEN);		/* rare */
  PUSH (2, LAMENT_SPHERE_OUT);		/* rare */
  PUSH (1, LAMENT_LEVIATHAN_SPIN);	/* very rare */

  PUSH (35, LAMENT_BOX);		/* rest state */
# undef PUSH

  shuffle_states (lc);

# ifdef DEBUG_MODE
  lc->type = DEBUG_MODE;
  lc->anim_pause = 0;
# endif

}
コード例 #15
0
ファイル: dangerball.c プロジェクト: MaddTheSane/xscreensaver
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);

  reshape_ball (mi, MI_WIDTH(mi), MI_HEIGHT(mi));

  if (!wire)
    {
      GLfloat pos[4] = {1.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] = {0.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);
    }

  {
    double spin_speed   = 10.0;
    double wander_speed = 0.12;
    double spin_accel   = 2.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,
                            True);
    bp->trackball = gltrackball_init (True);
  }

  bp->ncolors = 128;
  bp->colors = (XColor *) calloc(bp->ncolors, sizeof(XColor));
  make_smooth_colormap (0, 0, 0,
                        bp->colors, &bp->ncolors,
                        False, 0, False);

  bp->spikes = (int *) calloc(MI_COUNT(mi), sizeof(*bp->spikes) * 2);

  bp->ball_list = glGenLists (1);
  bp->spike_list = glGenLists (1);

  glNewList (bp->ball_list, GL_COMPILE);
  unit_sphere (SPHERE_STACKS, SPHERE_SLICES, wire);
  glEndList ();

  glNewList (bp->spike_list, GL_COMPILE);
  cone (0, 0, 0,
        0, 1, 0,
        1, 0, SPIKE_FACES, SMOOTH_SPIKES, False, wire);
  glEndList ();

  randomize_spikes (mi);
}
コード例 #16
0
ファイル: glplanet.c プロジェクト: Zygo/xscreensaver
ENTRYPOINT void
init_planet (ModeInfo * mi)
{
  planetstruct *gp;
  int screen = MI_SCREEN(mi);
  Bool wire = MI_IS_WIREFRAME(mi);

  MI_INIT (mi, planets);
  gp = &planets[screen];

  gp->window = MI_WINDOW(mi);

  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 *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;

	free (f);
	free (b);
  }

  {
    double spin_speed   = 0.1;
    double wander_speed = 0.005;
    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->tilt = frand (23.4);
    gp->trackball = gltrackball_init (True);
  }

  if (!wire && !do_texture)
    {
      GLfloat pos[4] = {1, 1, 1, 0};
      GLfloat amb[4] = {0, 0, 0, 1};
      GLfloat dif[4] = {1, 1, 1, 1};
      GLfloat spc[4] = {0, 1, 1, 1};
      glEnable(GL_LIGHTING);
      glEnable(GL_LIGHT0);
      glLightfv(GL_LIGHT0, GL_POSITION, pos);
      glLightfv(GL_LIGHT0, GL_AMBIENT,  amb);
      glLightfv(GL_LIGHT0, GL_DIFFUSE,  dif);
      glLightfv(GL_LIGHT0, GL_SPECULAR, spc);
    }

  if (wire)
    do_texture = False;

  if (do_texture)
    setup_texture (mi);

  if (do_stars)
    init_stars (mi);

  /* construct the polygons of the planet
   */
  gp->platelist = glGenLists(1);
  glNewList (gp->platelist, GL_COMPILE);
  glFrontFace(GL_CCW);
  glPushMatrix();
  glRotatef (90, 1, 0, 0);
  unit_sphere (resolution, resolution, wire);
  glPopMatrix();
  glEndList();

  gp->shadowlist = glGenLists(1);
  glNewList (gp->shadowlist, GL_COMPILE);
  glFrontFace(GL_CCW);

  if (wire)
    glColor4f (0.5, 0.5, 0, 1);
# ifdef BLENDED_TERMINATOR
  else
    {
      GLfloat c[] = { 0, 0, 0, 1 };
      glColor4fv (c);
      if (!do_texture)
        glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, c);
    }
# endif

  glPushMatrix();
  glScalef (1.01, 1.01, 1.01);
  unit_dome (resolution, resolution, wire);

# ifdef BLENDED_TERMINATOR
  terminator_tube (mi, resolution);
  if (!wire)
    {
      /* We have to draw the transparent side of the mask too, 
         though I'm not sure why. */
      GLfloat c[] = { 0, 0, 0, 0 };
      glColor4fv (c);
      if (!do_texture)
        glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, c);
      glRotatef (180, 1, 0, 0);
      unit_dome (resolution, resolution, wire);
    }
# endif

  glPopMatrix();
  glEndList();

  /* construct the polygons of the latitude/longitude/axis lines.
   */
  gp->latlonglist = glGenLists(1);
  glNewList (gp->latlonglist, GL_COMPILE);
  glPushMatrix ();
  glRotatef (90, 1, 0, 0);  /* unit_sphere is off by 90 */
  glRotatef (8,  0, 1, 0);  /* line up the time zones */
  unit_sphere (12, 24, 1);
  unit_sphere (12, 24, 1);
  glBegin(GL_LINES);
  glVertex3f(0, -2, 0);
  glVertex3f(0,  2, 0);
  glEnd();
  glPopMatrix ();
  glEndList();
}
コード例 #17
0
ファイル: hypnowheel.c プロジェクト: BuBuaBu/bang-screensaver
ENTRYPOINT void 
init_hypnowheel (ModeInfo *mi)
{
  hypnowheel_configuration *bp;
  int wire = MI_IS_WIREFRAME(mi);
  int i;

  if (!bps) {
    bps = (hypnowheel_configuration *)
      calloc (MI_NUM_SCREENS(mi), sizeof (hypnowheel_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_hypnowheel (mi, MI_WIDTH(mi), MI_HEIGHT(mi));

  bp->rot = make_rotator (0, 0, 0, 0, speed * 0.0025, False);

  bp->ncolors = 1024;
  bp->colors = (XColor *) calloc(bp->ncolors, sizeof(XColor));
  make_smooth_colormap (0, 0, 0,
                        bp->colors, &bp->ncolors,
                        False, 0, False);

  if (MI_COUNT(mi) < 2) MI_COUNT(mi) = 2;
  if (nlayers < 1) nlayers = 1;
  bp->discs = (disc *) calloc (nlayers, sizeof (disc));

  for (i = 0; i < nlayers; i++)
    {
      double spin_speed   = speed * 0.2;
      double wander_speed = speed * 0.0012;
      double spin_accel   = 0.2;

      bp->discs[i].twist = 0;
      bp->discs[i].alpha = 1;
      bp->discs[i].color = i * bp->ncolors / nlayers;

      spin_speed   += frand (spin_speed   / 5);
      wander_speed += frand (wander_speed * 3);

      bp->discs[i].rot = make_rotator (spin_speed, spin_speed, spin_speed,
                                       spin_accel,
                                       (do_wander ? wander_speed : 0),
                                       True);
    }

  glDisable (GL_LIGHTING);
  glDisable (GL_DEPTH_TEST);
  glDepthMask (GL_FALSE);
  glDisable (GL_CULL_FACE);

  if (! wire)
    {
      glEnable (GL_BLEND);
      glBlendFunc (GL_ONE, GL_ONE);
    }
}
コード例 #18
0
ENTRYPOINT void 
init_lavalite (ModeInfo *mi)
{
  lavalite_configuration *bp;
  int wire = MI_IS_WIREFRAME(mi);

  if (!bps) {
    bps = (lavalite_configuration *)
      calloc (MI_NUM_SCREENS(mi), sizeof (lavalite_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);

  reshape_lavalite (mi, MI_WIDTH(mi), MI_HEIGHT(mi));

  {
    char *s = do_style;
    if (!s || !*s || !strcasecmp (s, "classic")) bp->style = CLASSIC;
    else if (!strcasecmp (s, "giant"))  bp->style = GIANT;
    else if (!strcasecmp (s, "cone"))   bp->style = CONE;
    else if (!strcasecmp (s, "rocket")) bp->style = ROCKET;
    else if (!strcasecmp (s, "random"))
      {
        if (random() & 1) bp->style = CLASSIC;  /* half the time */
        else bp->style = (random() % ((int) ROCKET+1));
      }
    else
      {
        fprintf (stderr,
         "%s: style must be Classic, Giant, Cone, or Rocket (not \"%s\")\n",
                 progname, s);
        exit (1);
      }
  }

  parse_color (mi, "lava",  lava_color_str,  lava_color);
  parse_color (mi, "fluid", fluid_color_str, fluid_color);
  parse_color (mi, "base",  base_color_str,  base_color);
  parse_color (mi, "table", table_color_str, table_color);

  if (!wire)
    {
      GLfloat amb[4]  = {0.0, 0.0, 0.0, 1.0};
      GLfloat dif[4]  = {1.0, 1.0, 1.0, 1.0};
      GLfloat spc0[4] = {0.0, 1.0, 1.0, 1.0};
      GLfloat spc1[4] = {1.0, 0.0, 1.0, 1.0};

      glEnable(GL_LIGHTING);
      glEnable(GL_LIGHT0);
      glEnable(GL_LIGHT1);
      glEnable(GL_DEPTH_TEST);
      glEnable(GL_CULL_FACE);
      glEnable(GL_NORMALIZE);
      glShadeModel(GL_SMOOTH);

      glLightfv(GL_LIGHT0, GL_AMBIENT,  amb);
      glLightfv(GL_LIGHT0, GL_DIFFUSE,  dif);
      glLightfv(GL_LIGHT0, GL_SPECULAR, spc0);

      glLightfv(GL_LIGHT1, GL_AMBIENT,  amb);
      glLightfv(GL_LIGHT1, GL_DIFFUSE,  dif);
      glLightfv(GL_LIGHT1, GL_SPECULAR, spc1);

      glLightfv(GL_LIGHT2, GL_AMBIENT,  amb);
      glLightfv(GL_LIGHT2, GL_DIFFUSE,  dif);
      glLightfv(GL_LIGHT2, GL_SPECULAR, spc0);
    }

  {
    Bool spinx=False, spiny=False, spinz=False;
    double spin_speed   = 0.4;
    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++;
      }

    bp->rot = make_rotator (spinx ? spin_speed : 0,
                            spiny ? spin_speed : 0,
                            spinz ? spin_speed : 0,
                            1.0,
                            do_wander ? wander_speed : 0,
                            False);
    bp->rot2 = make_rotator (spin_speed, 0, 0,
                             1, 0.1,
                             False);
    bp->trackball = gltrackball_init ();

    /* move initial camera position up by around 15 degrees:
       in other words, tilt the scene toward the viewer. */
    gltrackball_start (bp->trackball, 50, 50, 100, 100);
    gltrackball_track (bp->trackball, 50,  5, 100, 100);

    /* Oh, but if it's the "Giant" model, tilt the scene away: make it
       look like we're looking up at it instead of down at it! */
    if (bp->style == GIANT)
      gltrackball_track (bp->trackball, 50, -12, 100, 100);
    else if (bp->style == ROCKET)  /* same for rocket, but not as much */
      gltrackball_track (bp->trackball, 50, -4, 100, 100);
  }

  switch (bp->style)
    {
    case CLASSIC: bp->model = classic_lamp; break;
    case GIANT:   bp->model = giant_lamp;   break;
    case CONE:    bp->model = cone_lamp;    break;
    case ROCKET:  bp->model = rocket_lamp;  break;
    default: abort(); break;
    }

  bp->max_bottle_radius = max_bottle_radius (bp);

  bp->launch_chance = speed;
  bp->blobs_per_group = BLOBS_PER_GROUP;
  bp->just_started_p = True;

  bp->nballs = (((MI_COUNT (mi) + 1) * bp->blobs_per_group)
                + 2);
  bp->balls = (metaball *) calloc (sizeof(*bp->balls), bp->nballs+1);

  bp->bottle_list = glGenLists (1);
  bp->ball_list = glGenLists (1);

  generate_bottle (mi);
  generate_static_blobs (mi);
}
コード例 #19
0
ファイル: unicrud.c プロジェクト: Zygo/xscreensaver
ENTRYPOINT void 
init_unicrud (ModeInfo *mi)
{
  unicrud_configuration *bp;

  MI_INIT (mi, bps);

  bp = &bps[MI_SCREEN(mi)];

  bp->glx_context = init_GL(mi);

  reshape_unicrud (mi, MI_WIDTH(mi), MI_HEIGHT(mi));

  {
    double spin_speed   = 0.05;
    double wander_speed = 0.01;
    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);
  }

  bp->title_font = load_texture_font (mi->dpy, "titleFont");
  bp->char_font  = load_texture_font (mi->dpy, "font");
  bp->state = IN;
  bp->ratio = 0;
  bp->spin_direction = (random() & 1) ? 1 : -1;



  if (matches ("all", do_block))
    do_block = strdup("");

  {
    char *s;
    for (s = do_block; *s; s++)
      if (*s == '_') *s = ' ';
  }

  if (matches ("help", do_block))
    {
      int i;
      fprintf (stderr,
               "%s: --blocks must contain one or more of these,"
               " separated by commas:\n\n", progname);
      for (i = 0; i < countof(unicode_block_names); i++)
        {
          const char *n = unicode_block_names[i].name;
          if (*n == '*')
            continue;
          if (!strncmp (n, "Unassigned", 10) ||
              !strncmp (n, "Combining", 9))
            continue;
          fprintf (stderr, "\t%s\n", n);
        }
      fprintf (stderr, "\n");
      exit (1);
    }


  /* Make sure all elements in --block are valid.
   */
  if (*do_block)
    {
      char *token = strdup (do_block ? do_block : "");
      char *otoken = token;
      char *name;
      while ((name = strtok (token, ","))) {
        token = 0;
        name = strip (name);
        if (*name)
          {
            Bool match = False;
            int i;
            for (i = 0; i < countof(unicode_block_names); i++)
              {
                const char *n = unicode_block_names[i].name;
                if (*n == '*')
                  continue;
                if (!strncmp (n, "Unassigned", 10) ||
                    !strncmp (n, "Combining", 9))
                  continue;
                if (!strcasecmp (name, n))
                  {
                    match = True;
                    break;
                  }
              }
            if (! match)
              {
                fprintf (stderr, "%s: unknown block name: \"%s\"\n", 
                         progname, name);
                fprintf (stderr, "%s: use '--block help' for a list\n", 
                         progname);
                exit (1);
              }
          }
      }
      free (otoken);
    }

  pick_unichar (mi);
}
コード例 #20
0
ファイル: cubetwist.c プロジェクト: Zygo/xscreensaver
ENTRYPOINT void 
init_cube (ModeInfo *mi)
{
  cube_configuration *bp;
  int wire = MI_IS_WIREFRAME(mi);

  MI_INIT (mi, bps);

  bp = &bps[MI_SCREEN(mi)];

  bp->glx_context = init_GL(mi);

  reshape_cube (mi, MI_WIDTH(mi), MI_HEIGHT(mi));

  if (!wire && !do_flat)
    {
      GLfloat color[4] = {1, 1, 1, 1};
      GLfloat cspec[4] = {1, 1, 0, 1};
      static const GLfloat shiny = 30;

      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);

      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);
    }

  {
    double spin_speed   = 0.05;
    double wander_speed = 0.005;
    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,
                            True);
    bp->trackball = gltrackball_init (True);
  }

  if (thickness > 0.5)
    thickness = 0.5;
  if (displacement > 0.5)
    displacement = 0.5;

  if (thickness <= 0.0001)
    {
      if (random() & 1)
        {
          thickness = 0.03 + frand(0.02);
          displacement = (random() & 1) ? 0 : (thickness / 3);
        }
      else
        {
          thickness = 0.001 + frand(0.02);
          displacement = 0;
        }
    }

  make_cubes (mi);
}
コード例 #21
0
ファイル: skytentacles.c プロジェクト: Ro6afF/XScreenSaver
/* Initializes a new tentacle and stores it in the list.
 */
static tentacle *
make_tentacle (ModeInfo *mi, int which, int total)
{
    tentacles_configuration *tc = &tcs[MI_SCREEN(mi)];
    tentacle *t = (tentacle *) calloc (1, sizeof (*t));
    double brightness;
    int i;

    t->mi = mi;

    /* position tentacles on a grid */
    {
        int cols = (int) (sqrt(total) + 0.5);
        int rows = (total+cols-1) / cols;
        int xx = which % cols;
        int yy = which / cols;
        double spc = arg_thickness * 0.8;
        if (!intersect_p) cols = 1, xx = 0;
        t->x = (cols * spc / 2) - (spc * (xx + 0.5));
        t->y = (rows * spc / 2) - (spc * (yy + 0.5));
        t->z = 0;
    }

    /* Brighten or darken the colors of this tentacle from the default.
     */
    brightness = 0.6 + frand(3.0);
    memcpy (t->tentacle_color, tc->tentacle_color, 4 * sizeof(*t->tentacle_color));
    memcpy (t->stripe_color,   tc->stripe_color,   4 * sizeof(*t->stripe_color));
    memcpy (t->sucker_color,   tc->sucker_color,   4 * sizeof(*t->sucker_color));
# define FROB(X) \
    t->X[0] *= brightness; if (t->X[0] > 1) t->X[0] = 1; \
    t->X[1] *= brightness; if (t->X[1] > 1) t->X[1] = 1; \
    t->X[2] *= brightness; if (t->X[2] > 1) t->X[2] = 1
    FROB (tentacle_color);
    FROB (stripe_color);
    FROB (sucker_color);
# undef FROB

    t->nsegments = (arg_segments) + BELLRAND(arg_segments);

    t->segments = (segment *) calloc (t->nsegments+1, sizeof(*t->segments));
    for (i = 0; i < t->nsegments; i++)
    {
        double spin_speed   = 0;
        double spin_accel   = 0;
        double wander_speed = arg_speed * (0.02 + BELLRAND(0.1));
        t->segments[i].rot = make_rotator (spin_speed, spin_speed, spin_speed,
                                           spin_accel, wander_speed, True);
    }

    t->segments[0].thickness = (((arg_thickness * 0.5) +
                                 BELLRAND(arg_thickness * 0.6))
                                / 1.0);

    if (tc->tentacles_size <= tc->ntentacles)
    {
        tc->tentacles_size = (tc->tentacles_size * 1.2) + tc->ntentacles + 2;
        tc->tentacles = (tentacle **)
                        realloc (tc->tentacles, tc->tentacles_size * sizeof(*tc->tentacles));
        if (! tc->tentacles)
        {
            fprintf (stderr, "%s: out of memory (%d tentacles)\n",
                     progname, tc->tentacles_size);
            exit (1);
        }
    }

    tc->tentacles[tc->ntentacles++] = t;
    return t;
}
コード例 #22
0
ファイル: glplanet.c プロジェクト: katahiromz/XScreenSaverWin
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();
}
コード例 #23
0
ファイル: main.cpp プロジェクト: phelrine/NBTools
/*! solve */
int32_t gmres
(
 const CPPL::dgsmatrix& A,
 const CPPL::dcovector& b,
 CPPL::dcovector& x,
 const double& eps
 )
{
  ///////////////////////////////////////////////
  //////////////// preconditioner ///////////////
  ///////////////////////////////////////////////
  CPPL::dgbmatrix Minv(x.l, x.l, 0, 0);
  
  //////// no precondition ////////
  Minv.identity();
  
  ///////////////////////////////////////////////
  ///////////////// mid values //////////////////
  ///////////////////////////////////////////////
  long m(10);//restart number
  CPPL::dcovector r(b-A*x);
  CPPL::dcovector s(m+1), co(m+1), si(m+1), w;
  std::vector<CPPL::dcovector> v(m+1);
  CPPL::dgematrix H(m+1,m);
  //H.zero();
  //co.zero();
  //si.zero();
  //s.zero();
  
  //////// norm ////////
  double norm_r, norm_r_min(DBL_MAX);
  const double norm_r_ini(fabs(damax(r)));
  std::cerr << "[NOTE]@gmres: norm_r_ini=" << norm_r_ini << ", eps=" << eps<< std::endl;
  if( norm_r_ini<DBL_MIN ){
    std::cerr << "[NOTE]@gmres: already converged. v(^^)" << std::endl;
    return 0;
  }
  
  ///////////////////////////////////////////////
  //////////////////// loop /////////////////////
  ///////////////////////////////////////////////
  int itc(1);
  //int itmax(int(2.1*x.l));
  int itmax(int(1.1*x.l));
  //int itmax(int(0.6*x.l));
  do{
    std::cerr << "** itc=" << itc << " ********************************************" << std::endl;
    //////// 0 ////////
    v[0] =r/nrm2(r);
    s.zero();
    s(0) =nrm2(r);
    
    for(long i=0; i<m; i++){
      //std::cerr << "++++ i=" << i << " ++++" << std::endl;
      w =A*v[i];
      w =Minv*w;
      for(long k=0; k<i+1; k++){
        H(k,i) =w%v[k];
        w -=H(k,i)*v[k];
      }
      H(i+1,i) =nrm2(w);
      v[i+1] =w/H(i+1,i);
      
      //// J,s ////
      for(long k=0; k<i; k++){
        rotate(H(k,i), H(k+1,i), co(k), si(k));
      }
      make_rotator( H(i,i), H(i+1,i), co(i), si(i) );
      //std::cerr << "co = " << t(co) << std::endl; std::cerr << "si = " << t(si) << std::endl;
      rotate( H(i,i), H(i+1,i), co(i), si(i) );//necessary
      //std::cerr << "H =\n" << H << std::endl;
      rotate( s(i), s(i+1), co(i), si(i) );
      //std::cerr << "s = " << t(s) << std::endl;
    }
    //for(long i=0; i<m+1; i++){ for(long j=i+1; j<m+1; j++){ std::cerr << "vv = " << v[i]%v[j] << std::endl; } }// v check
    //std::cerr << "H =\n" << H << std::endl;
    //std::cerr << "s =" << t(s) << std::endl;
    //for(long i=0; i<m+1; i++){ std::cerr << "v["<<i<<"] =" << t(v[i]) << std::flush; }
    
    //////// y ////////
    CPPL::dcovector y(s);
    for(long i=m-1; i>=0; i--){
      y(i) /= H(i,i);
      for(long j=i-1; j>=0; j--){
        y(j) -= H(j,i) * y(i);
      }
    }
    //std::cerr << "H*y = " << t(H*y) << std::endl;    
    //std::cerr << "s   = " << t(s) << std::endl;
    //std::cerr << "y = " << t(s) << std::endl;
    
    //////// update ////////
    for(long i=0; i<m; i++){
      x += v[i] * y(i);
    }
    //std::cerr << "x = " << t(x) << std::endl;
    
    //////// residual ////////
    r =b-A*x;
    r =Minv*r;
    //std::cerr << "r = " << t(r) << std::endl;
    
    //////// convergence check ////////
    norm_r =fabs(damax(r));
    std::cerr << "norm_r = " << norm_r << std::endl;
    if( isnan(norm_r) ){ break; }//failed
    if( !std::isnormal(norm_r) ){ break; }//failed
    if( !std::isfinite(norm_r) ){ break; }//failed
    if( norm_r>1e3*norm_r_ini ){ break; }//failed (getting so worse)
    if( norm_r<=eps ){//r satistied
      std::cerr << "[NOTE]@gmres: converged. v(^^)  itc=" << itc << "/" << itmax << ", norm=" << norm_r << std::endl;
      return 0;
    }
  }while(++itc<itmax);
  
  //////// failed ////////
  std::cerr << "[NOTE]@gmres: itc=" << itc << ", norm=" << norm_r << ", r_satisfied=" << (norm_r<=eps) << std::endl;
  std::cerr << "[NOTE]@gmres: failed to converge. orz" << std::endl;
  return 1;
}
コード例 #24
0
ファイル: dymaxionmap.c プロジェクト: Ro6afF/XScreenSaver
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));
  }

  gp->state = STARTUP;
  gp->ratio = 0;
  gp->font_data = load_texture_font (mi->dpy, "labelFont");

  {
    double spin_speed	= 0.1;
    double wander_speed = 0.002;
    gp->rot = make_rotator (do_roll ? spin_speed : 0,
			    do_roll ? spin_speed : 0,
			    0, 1,
			    do_wander ? wander_speed : 0,
			    False);
    gp->trackball = gltrackball_init (True);
  }

  if (wire)
    do_texture = False;

  if (do_texture)
    setup_texture (mi);

  if (do_stars)
    init_stars (mi);

  glEnable (GL_DEPTH_TEST);
  glEnable (GL_NORMALIZE);
  glEnable (GL_CULL_FACE);

  if (!wire)
    {
      GLfloat pos[4] = {0.4, 0.2, 0.4, 0.0};
      GLfloat amb[4] = {0.4, 0.4, 0.4, 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);
      glLightfv(GL_LIGHT0, GL_POSITION, pos);
      glLightfv(GL_LIGHT0, GL_AMBIENT,	amb);
      glLightfv(GL_LIGHT0, GL_DIFFUSE,	dif);
      glLightfv(GL_LIGHT0, GL_SPECULAR, spc);
    }
}
コード例 #25
0
ENTRYPOINT void
init_carousel (ModeInfo *mi)
{
  int screen = MI_SCREEN(mi);
  carousel_state *ss;
  int wire = MI_IS_WIREFRAME(mi);
  
  if (sss == NULL) {
    if ((sss = (carousel_state *)
         calloc (MI_NUM_SCREENS(mi), sizeof(carousel_state))) == NULL)
      return;
  }
  ss = &sss[screen];

  if ((ss->glx_context = init_GL(mi)) != NULL) {
    reshape_carousel (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
  } else {
    MI_CLEARWINDOW(mi);
  }

  if (!tilt_str || !*tilt_str)
    ;
  else if (!strcasecmp (tilt_str, "0"))
    ;
  else if (!strcasecmp (tilt_str, "X"))
    tilt_x_p = 1;
  else if (!strcasecmp (tilt_str, "Y"))
    tilt_y_p = 1;
  else if (!strcasecmp (tilt_str, "XY"))
    tilt_x_p = tilt_y_p = 1;
  else
    {
      fprintf (stderr, "%s: tilt must be 'X', 'Y', 'XY' or '', not '%s'\n",
               progname, tilt_str);
      exit (1);
    }

  {
    double spin_speed   = speed * 0.2;    /* rotation of tube around axis */
    double spin_accel   = speed * 0.1;
    double wander_speed = speed * 0.001;  /* tilting of axis */

    spin_speed   *= 0.9 + frand(0.2);
    wander_speed *= 0.9 + frand(0.2);

    ss->rot = make_rotator (spin_speed, spin_speed, spin_speed,
                            spin_accel, wander_speed, True);

    ss->trackball = gltrackball_init ();
  }

  if (strstr ((char *) glGetString(GL_EXTENSIONS),
              "GL_EXT_texture_filter_anisotropic"))
    glGetFloatv (GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &ss->anisotropic);
  else
    ss->anisotropic = 0.0;

  glDisable (GL_LIGHTING);
  glEnable (GL_DEPTH_TEST);
  glDisable (GL_CULL_FACE);

  if (! wire)
    {
      glShadeModel (GL_SMOOTH);
      glEnable (GL_LINE_SMOOTH);
      /* This gives us a transparent diagonal slice through each image! */
      /* glEnable (GL_POLYGON_SMOOTH); */
      glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
      glEnable (GL_BLEND);
      glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glEnable (GL_ALPHA_TEST);

      glEnable (GL_POLYGON_OFFSET_FILL);
      glPolygonOffset (1.0, 1.0);

    }

  ss->texfont = load_texture_font (MI_DISPLAY(mi), "font");

  if (debug_p)
    hack_resources (MI_DISPLAY (mi));

  ss->nframes = 0;
  ss->frames_size = 10;
  ss->frames = (image_frame **)
    calloc (1, ss->frames_size * sizeof(*ss->frames));

  ss->mode = IN;
  ss->mode_tick = fade_ticks / speed;

  ss->awaiting_first_images_p = True;
}
コード例 #26
0
ファイル: splitflap.c プロジェクト: Zygo/xscreensaver
ENTRYPOINT void 
init_splitflap (ModeInfo *mi)
{
  splitflap_configuration *bp;
  int wire = MI_IS_WIREFRAME(mi);
  int i;
  MI_INIT (mi, bps);

  bp = &bps[MI_SCREEN(mi)];
  bp->glx_context = init_GL(mi);
  reshape_splitflap (mi, MI_WIDTH(mi), MI_HEIGHT(mi));

  bp->first_time_p = True;

  if (!mode_str || !*mode_str || !strcasecmp(mode_str, "text"))
    {
      bp->clock_p = 0;
    }
  else if (!strcasecmp (mode_str, "clock") ||
           !strcasecmp (mode_str, "clock12"))
    {
      bp->clock_p = 12;
      grid_width  = 8;
      grid_height = 1;
    }
  else if (!strcasecmp (mode_str, "clock24"))
    {
      bp->clock_p = 24;
      grid_width  = 6;
      grid_height = 1;
    }
  else
    {
      fprintf (stderr,
           "%s: `mode' must be text, clock12 or clock24: not `%s'\n",
               progname, mode_str);
      exit (1);
    }

  if (! bp->clock_p)
    {
      bp->tc = textclient_open (MI_DISPLAY (mi));
      bp->text[0] = 0;

      if (grid_width > 10)
        textclient_reshape (bp->tc, 
                            grid_width, grid_height,
                            grid_width, grid_height,
                            0);
    }

  if (bp->clock_p)
    speed /= 4;

  glShadeModel(GL_SMOOTH);

  glEnable(GL_DEPTH_TEST);
  glEnable(GL_NORMALIZE);
  glEnable(GL_CULL_FACE);

  if (!wire)
    {
      GLfloat pos[4] = {0.4, 0.2, 0.4, 0.0};
/*      GLfloat amb[4] = {0.0, 0.0, 0.0, 1.0};*/
      GLfloat amb[4] = {0.2, 0.2, 0.2, 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);

      glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    }


  {
    double spin_speed   = 0.5;
    double wander_speed = 0.005;
    double tilt_speed   = 0.001;
    double spin_accel   = 0.5;

    char *s = do_spin;
    while (*s)
      {
        if      (*s == 'x' || *s == 'X') bp->spinx = True;
        else if (*s == 'y' || *s == 'Y') bp->spiny = True;
        else if (*s == 'z' || *s == 'Z') bp->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++;
      }

    bp->rot = make_rotator (bp->spinx ? spin_speed : 0,
                            bp->spiny ? spin_speed : 0,
                            bp->spinz ? spin_speed : 0,
                            spin_accel,
                            do_wander ? wander_speed : 0,
                            False);
    bp->rot2 = (face_front_p
                ? make_rotator (0, 0, 0, 0, tilt_speed, True)
                : 0);
    bp->trackball = gltrackball_init (False);
  }

  bp->dlists = (GLuint *) calloc (countof(all_objs)+1, sizeof(GLuint));
  for (i = 0; i < countof(all_objs); i++)
    bp->dlists[i] = glGenLists (1);

  parse_color (mi, "textColor", bp->text_color);
  for (i = 0; i < countof(all_objs); i++)
    {
      const struct gllist *gll = *all_objs[i];
      char *key = 0;
      GLfloat spec[4] = {0.4, 0.4, 0.4, 1.0};
      GLfloat shiny = 80; /* 0-128 */

      glNewList (bp->dlists[i], GL_COMPILE);

      glMatrixMode(GL_MODELVIEW);
      glPushMatrix();
      glMatrixMode(GL_TEXTURE);
      glPushMatrix();
      glMatrixMode(GL_MODELVIEW);

      glRotatef (-90, 1, 0, 0);

      glBindTexture (GL_TEXTURE_2D, 0);

      switch (i) {
      case SPLITFLAP_QUARTER_FRAME:
        key = "frameColor";
        break;
      case SPLITFLAP_OUTER_FRAME:
        key = "caseColor";
        break;
      case SPLITFLAP_DISC_QUARTER:
        key = (wire ? "frameColor" : "discColor");
        break;
      case SPLITFLAP_FIN_EDGE_HALF:
      case SPLITFLAP_FIN_FACE_HALF:
        key = "finColor";
        break;
      default:
        abort();
      }

      parse_color (mi, key, bp->component_colors[i]);

      if (wire && i == SPLITFLAP_FIN_EDGE_HALF)
        bp->component_colors[i][0] = 
        bp->component_colors[i][1] = 
        bp->component_colors[i][2] = 0.7;

      glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR,  spec);
      glMaterialf  (GL_FRONT_AND_BACK, GL_SHININESS, shiny);

      switch (i) {
      case SPLITFLAP_OUTER_FRAME:
        if (! splitflap_obj_outer_frame)
          splitflap_obj_outer_frame =
            (struct gllist *) calloc (1, sizeof(*splitflap_obj_outer_frame));
        splitflap_obj_outer_frame->points = draw_outer_frame(mi);
        break;
      default:
        renderList (gll, wire);
        break;
      }

      glMatrixMode(GL_TEXTURE);
      glPopMatrix();
      glMatrixMode(GL_MODELVIEW);
      glPopMatrix();

      glEndList ();
    }

  if (grid_width < 1)  grid_width  = 1;
  if (grid_height < 1) grid_height = 1;
  bp->flappers = (flapper *) calloc (grid_width * grid_height,
                                     sizeof (flapper));

  for (i = 0; i < grid_width * grid_height; i++)
    {
      flapper *f = &bp->flappers[i];

      if (!bp->clock_p)
        {
          f->spool = ascii_spool;
          f->spool_size = countof (ascii_spool);
        }
      else
        {
          switch (i) {
          case 0:
            if (bp->clock_p == 12)
              {
                f->spool = digit_s1_spool;
                f->spool_size = countof (digit_s1_spool);
              }
            else
              {
                f->spool = digit_01_spool;
                f->spool_size = countof (digit_01_spool);
              }
            break;
          case 1: case 3: case 5:
            f->spool = digit_spool;
            f->spool_size = countof (digit_spool);
            break;
          case 2: case 4:
            f->spool = digit_05_spool;
            f->spool_size = countof (digit_05_spool);
            break;
          case 6:
            f->spool = ap_spool;
            f->spool_size = countof (ap_spool);
            break;
          case 7:
            f->spool = m_spool;
            f->spool_size = countof (m_spool);
            break;
          default:
            abort();
          }
        }

      f->target_index = random() % f->spool_size;
      /* f->target_index = 0; */
      f->current_index = f->target_index;
      f->missing = (((random() % 10) == 0)
                    ? (random() % f->spool_size)
                    : -1);
    }

  bp->font_data = load_texture_font (mi->dpy, "flapFont");
  init_textures (mi);

  reshape_splitflap (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
}
コード例 #27
0
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);
}
コード例 #28
0
ファイル: cubestorm.c プロジェクト: BuBuaBu/bang-screensaver
ENTRYPOINT void 
init_cube (ModeInfo *mi)
{
  cube_configuration *bp;
  int wire = MI_IS_WIREFRAME(mi);
  int i;

  if (!bps) {
    bps = (cube_configuration *)
      calloc (MI_NUM_SCREENS(mi), sizeof (cube_configuration));
    if (!bps) {
      fprintf(stderr, "%s: out of memory\n", progname);
      exit(1);
    }
  }

# ifdef HAVE_JWZGLES
  dbuf_p = True;
# endif

  bp = &bps[MI_SCREEN(mi)];

  bp->glx_context = init_GL(mi);

  if (MI_COUNT(mi) <= 0) MI_COUNT(mi) = 1;

  bp->trackball = gltrackball_init ();
  bp->subcubes = (subcube *) calloc (MI_COUNT(mi), sizeof(subcube));
  for (i = 0; i < MI_COUNT(mi); i++)
    {
      double wander_speed, spin_speed, spin_accel;

      if (i == 0)
        {
          wander_speed = 0.05 * speed;
          spin_speed   = 10.0 * speed;
          spin_accel   = 4.0  * speed;
        }
      else
        {
          wander_speed = 0;
          spin_speed   = 4.0 * speed;
          spin_accel   = 2.0 * speed;
        }

      bp->subcubes[i].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);
    }

  bp->colors = 0;
  new_cube_colors (mi);

  reshape_cube (mi, MI_WIDTH(mi), MI_HEIGHT(mi));

  if (!wire)
    {
      GLfloat pos[4] = {1.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] = {0.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);
    }

  bp->cube_list = glGenLists (1);
  glNewList (bp->cube_list, GL_COMPILE);
  draw_faces (mi);
  glEndList ();

  glDrawBuffer(dbuf_p ? GL_BACK : GL_FRONT);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
コード例 #29
0
ファイル: discoball.c プロジェクト: MaddTheSane/xscreensaver
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);
    }
}
コード例 #30
0
ファイル: antmaze.c プロジェクト: davehorner/XScreenSaverWin
ENTRYPOINT void init_antmaze(ModeInfo * mi) 
{
  double rot_speed = 0.3;
  int i;

  antmazestruct *mp;
  
  if (antmaze == NULL) {
	if ((antmaze = (antmazestruct *) calloc(MI_NUM_SCREENS(mi),
						sizeof (antmazestruct))) == NULL)
	  return;
  }
  mp = &antmaze[MI_SCREEN(mi)];
  mp->step = NRAND(90);
  mp->ant_position = NRAND(90);


  mp->antdirection[0] = PI/2.0;
  mp->antdirection[1] = PI/2.0;
  mp->antdirection[2] = 0;
  mp->antdirection[3] = PI/2.0;
  mp->antdirection[4] = PI/2.0;

  mp->antposition[0][0] = -4.0;
  mp->antposition[0][1] =  5.0;
  mp->antposition[0][1] =  0.15;

  mp->antposition[1][0] = -4.0;
  mp->antposition[1][1] =  3.0;
  mp->antposition[1][1] =  0.15;

  mp->antposition[2][0] = -1.0;
  mp->antposition[2][1] = -2.0;
  mp->antposition[2][1] =  0.15;

  mp->antposition[3][0] = -3.9;
  mp->antposition[3][1] =  6.0;
  mp->antposition[3][1] =  0.15;

  mp->antposition[4][0] =  2.0;
  mp->antposition[4][1] = -2.0;
  mp->antposition[4][1] =  0.15;

  

  for (i = 0; i < ANTCOUNT; i++) {
    mp->antvelocity[i] = 0.02;
    mp->antsize[i] = 1.0;
    mp->anton[i] = 0;
  }

  mp->bposition[0][0] = 0;
  mp->bposition[0][1] = 8;

  mp->bposition[1][0] = 9;
  mp->bposition[1][1] = 1;

  mp->bposition[2][0] = 1;
  mp->bposition[2][1] = 1;

  mp->bposition[3][0] = 4;
  mp->bposition[3][1] = 8;

  mp->bposition[4][0] = 2;
  mp->bposition[4][1] = 1;

  mp->part[0] = 0;
  mp->part[1] = 1;
  mp->part[2] = 5;
  mp->part[3] = 1;
  mp->part[4] = 3;

  mp->introduced = 0;
  mp->entroducing = 12;
  mp->fadeout = 1.0;
  mp->mag = 4.0;

  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_antmaze(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
    glDrawBuffer(GL_BACK);
    pinit(mp);
  } 
  else
    MI_CLEARWINDOW(mi);
}