Пример #1
0
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);
  }
}
Пример #2
0
int init()
{
    //Initialize SDL
    if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )
    {
        return 0;    
    }
    
    //Create Window
    if( SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_OPENGL ) == NULL )
    {
        return 0;
    }
    
    //Initialize OpenGL
    if( init_GL() == 0 )
    {
        return 0;    
    }
    
    //Set caption
    SDL_WM_SetCaption( "OpenGL Test", NULL );
    
    return 1;    
}
Пример #3
0
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));
}
Пример #4
0
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);
}
Пример #5
0
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);
  }
}
Пример #6
0
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! */
}
Пример #7
0
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);
}
Пример #8
0
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);
}
Пример #9
0
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 ();
  }
}
Пример #10
0
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);
}
Пример #11
0
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);
   }
}
Пример #12
0
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);
}
Пример #13
0
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);
  }
}
Пример #14
0
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;
}
Пример #15
0
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);
	}
}
Пример #16
0
ENTRYPOINT void 
init_voronoi (ModeInfo *mi)
{
  voronoi_configuration *vp;

  MI_INIT (mi, vps);

  vp = &vps[MI_SCREEN(mi)];

  vp->glx_context = init_GL(mi);

  vp->point_size = point_size;
  if (vp->point_size < 0) vp->point_size = 10;

  if (MI_WIDTH(mi) > 2560) vp->point_size *= 2;  /* Retina displays */

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

  reshape_voronoi (mi, MI_WIDTH(mi), MI_HEIGHT(mi));

  vp->mode = MODE_ADDING;
  vp->adding = npoints * 2;
  vp->last_time = 0;
}
Пример #17
0
/* 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);
  }

}
Пример #18
0
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);
	}
}
Пример #19
0
ENTRYPOINT void 
init_noof (ModeInfo *mi)
{
  int i;
  noof_configuration *bp;

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

  bp = &bps[MI_SCREEN(mi)];

  bp->glx_context = init_GL(mi);

  glDrawBuffer(GL_FRONT);
  glClearColor(0.0, 0.0, 0.0, 1.0);
  glEnable(GL_LINE_SMOOTH);
  glShadeModel(GL_FLAT);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  for (i = 0; i < N_SHAPES; i++)
    initshapes(bp, i);
  reshape_noof (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
}
Пример #20
0
ENTRYPOINT void 
init_voronoi (ModeInfo *mi)
{
  voronoi_configuration *vp;

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

    vp = &vps[MI_SCREEN(mi)];
  }

  vp = &vps[MI_SCREEN(mi)];

  vp->glx_context = init_GL(mi);

  if (point_size < 0) point_size = 10;

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

  reshape_voronoi (mi, MI_WIDTH(mi), MI_HEIGHT(mi));

  vp->mode = MODE_ADDING;
  vp->adding = npoints * 2;
  vp->last_time = 0;
}
Пример #21
0
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);
}
Пример #22
0
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);
    }
}
Пример #23
0
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);
}
Пример #24
0
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);

}
Пример #25
0
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);
}
Пример #26
0
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);
}
Пример #27
0
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);
	}
}
Пример #28
0
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);
  }
}
Пример #29
0
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);
  }
}
Пример #30
0
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;
}