• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ MI_HEIGHT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MI_HEIGHT函数的典型用法代码示例。如果您正苦于以下问题:C++ MI_HEIGHT函数的具体用法?C++ MI_HEIGHT怎么用?C++ MI_HEIGHT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MI_HEIGHT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: init_antmaze

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);
}
开发者ID:katahiromz,项目名称:XScreenSaverWin,代码行数:88,代码来源:antmaze.c


示例2: init_rotor

ENTRYPOINT void
init_rotor (ModeInfo * mi)
{
	int         x;
	elem       *pelem;
	unsigned char wasiconified;
	rotorstruct *rp;

	if (rotors == NULL) {
		if ((rotors = (rotorstruct *) calloc(MI_NUM_SCREENS(mi),
					      sizeof (rotorstruct))) == NULL)
			return;
	}
	rp = &rotors[MI_SCREEN(mi)];

#ifdef HAVE_COCOA
    jwxyz_XSetAntiAliasing (MI_DISPLAY(mi), MI_GC(mi),  False);
#endif

	rp->prevcenterx = rp->centerx;
	rp->prevcentery = rp->centery;

	rp->centerx = MI_WIDTH(mi) / 2;
	rp->centery = MI_HEIGHT(mi) / 2;

	rp->redrawing = 0;
	/*
	 * sometimes, you go into iconified view, only to see a really whizzy pattern
	 * that you would like to look more closely at. Normally, clicking in the
	 * icon reinitializes everything - but I don't, cuz I'm that kind of guy.
	 * HENCE, the wasiconified stuff you see here.
	 */

	wasiconified = rp->iconifiedscreen;
	rp->iconifiedscreen = MI_IS_ICONIC(mi);

	if (wasiconified && !rp->iconifiedscreen)
		rp->firsttime = True;
	else {

		/* This is a fudge is needed since prevcenter may not be set when it comes
		   from the the random mode and return is pressed (and its not the first
		   mode that was running). This assumes that the size of the lock screen
		   window / size of the icon window = 12 */
		if (!rp->prevcenterx)
			rp->prevcenterx = rp->centerx * 12;
		if (!rp->prevcentery)
			rp->prevcentery = rp->centery * 12;

		rp->num = MI_COUNT(mi);
		if (rp->num < 0) {
			rp->num = NRAND(-rp->num) + 1;
			if (rp->elements != NULL) {
				(void) free((void *) rp->elements);
				rp->elements = (elem *) NULL;
			}
		}
		if (rp->elements == NULL)
			if ((rp->elements = (elem *) calloc(rp->num,
					sizeof (elem))) == NULL) {
				free_rotor(rp);
				return;
			}
		rp->nsave = MI_CYCLES(mi);
		if (rp->nsave <= 1)
			rp->nsave = 2;
		if (rp->save == NULL)
			if ((rp->save = (XPoint *) malloc(rp->nsave *
					sizeof (XPoint))) == NULL) {
				free_rotor(rp);
				return;
			}
		for (x = 0; x < rp->nsave; x++) {
			rp->save[x].x = rp->centerx;
			rp->save[x].y = rp->centery;
		}

		pelem = rp->elements;

		for (x = rp->num; --x >= 0; pelem++) {
			pelem->radius_drift_max = 1.0;
			pelem->radius_drift_now = 1.0;

			pelem->end_radius = 100.0;

			pelem->ratio_drift_max = 1.0;
			pelem->ratio_drift_now = 1.0;
			pelem->end_ratio = 10.0;
		}
		if (MI_NPIXELS(mi) > 2)
			rp->pix = NRAND(MI_NPIXELS(mi));

		rp->rotor = 0;
		rp->prev = 1;
		rp->lastx = rp->centerx;
		rp->lasty = rp->centery;
		rp->angle = (float) NRAND((long) MAXANGLE) / 3.0;
		rp->forward = rp->firsttime = True;
	}
	rp->linewidth = MI_SIZE(mi);
//.........这里部分代码省略.........
开发者ID:davehorner,项目名称:XScreenSaverWin,代码行数:101,代码来源:rotor.c


示例3: init_flow


//.........这里部分代码省略.........
        break;
    case 3:
        /*
          x' = -z + b sin(y)
          y' = c
          z' = 0.7x + az(0.1 - x^2)
         */
        name = "Birkhoff";
        sp->par2[Z].x = -1;
        sp->par2[SINY].x = 0.35 + balance_rand(0.25); /* b */
        sp->par2[C].y = 1.57; /* c */
        sp->par2[X].z = 0.7;
        sp->par2[Z].z = 1 + balance_rand(0.5); /* a/10 */
        sp->par2[XXZ].z = -10 * sp->par2[Z].z; /* -a */
        sp->yperiod = 2 * M_PI;
        break;
    default:
        /*
          x' = -ax - z/2 - z^3/8 + b sin(y)
          y' = c
          z' = 2x
         */
        name = "Duffing";
        sp->par2[X].x = -0.2 + balance_rand(0.1); /* a */
        sp->par2[Z].x = -0.5;
        sp->par2[ZZZ].x = -0.125;
        sp->par2[SINY].x = 27.0 + balance_rand(3.0); /* b */
        sp->par2[C].y = 1.33; /* c */
        sp->par2[X].z = 2;
        sp->yperiod = 2 * M_PI;
        break;

    }

    sp->range.x = 5;
    sp->range.z = 5;

    if(sp->yperiod > 0) {
        sp->ODE = Periodic;
        /* periodic flows show either uniform distribution or a
           snapshot on the 'time' axis */
        sp->range.y = NRAND(2)? sp->yperiod : 0;
    } else {
        sp->range.y = 5;
        sp->ODE = Cubic;
    }

    /* Run discoverer to set up bounding box, etc.  Lyapunov will
       probably be innaccurate, since we're only running it once, but
       we're using known strange attractors so it should be ok. */
    discover(mi);
    if(MI_IS_VERBOSE(mi))
        fprintf(stdout,
                "flow: Lyapunov exponent: %g, step: %g, size: %g (%s)\n",
                sp->lyap2, sp->step2, sp->size2, name);
    /* Install new params */
    sp->lyap = sp->lyap2;
    sp->size = sp->size2;
    sp->mid = sp->mid2;
    sp->step = sp->step2;
    memcpy(sp->par, sp->par2, sizeof(sp->par2));

    sp->count2 = 0; /* Reset search */

    free_flow(sp);
    sp->beecount = MI_COUNT(mi);
    if (sp->beecount < 0) {	/* random variations */
        sp->beecount = NRAND(-sp->beecount) + 1; /* Minimum 1 */
    }

# ifdef HAVE_COCOA	/* Don't second-guess Quartz's double-buffering */
    dbufp = False;
# endif

    if(dbufp) { /* Set up double buffer */
        if (sp->buffer != None)
            XFreePixmap(MI_DISPLAY(mi), sp->buffer);
        sp->buffer = XCreatePixmap(MI_DISPLAY(mi), MI_WINDOW(mi),
                                   MI_WIDTH(mi), MI_HEIGHT(mi), MI_DEPTH(mi));
    } else {
        sp->buffer = MI_WINDOW(mi);
    }
    /* no "NoExpose" events from XCopyArea wanted */
    XSetGraphicsExposures(MI_DISPLAY(mi), MI_GC(mi), False);

    /* Make sure we're using 'thin' lines */
    XSetLineAttributes(MI_DISPLAY(mi), MI_GC(mi), 0, LineSolid, CapNotLast,
                       JoinMiter);

    /* Clear the background (may be slow depending on user prefs). */
    MI_CLEARWINDOW(mi);

    /* Allocate memory. */
    if (sp->csegs == NULL) {
        allocate(sp->csegs, XSegment,
                 (sp->beecount + BOX_L) * MI_NPIXELS(mi) * sp->taillen);
        allocate(sp->cnsegs, int, MI_NPIXELS(mi));
        allocate(sp->old_segs, XSegment, sp->beecount * sp->taillen);
        allocate(sp->p, dvector, sp->beecount * sp->taillen);
    }
开发者ID:rivy,项目名称:XScreenSaverWin,代码行数:101,代码来源:flow.c


示例4: init_tik_tak

void
init_tik_tak(ModeInfo * mi)
{
	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);
	int         i, max_objects, size_object;
	tik_takstruct *tiktak;

/* initialize */
	if (tik_taks == NULL) {
		if ((tik_taks = (tik_takstruct *) calloc(MI_NUM_SCREENS(mi),
				sizeof (tik_takstruct))) == NULL)
			return;
	}
	tiktak = &tik_taks[MI_SCREEN(mi)];
	tiktak->mi = mi;

	if (tiktak->gc == None) {
		if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) {
			XColor      color;

#ifndef STANDALONE
			tiktak->fg = MI_FG_PIXEL(mi);
			tiktak->bg = MI_BG_PIXEL(mi);
#endif
			tiktak->blackpixel = MI_BLACK_PIXEL(mi);
			tiktak->whitepixel = MI_WHITE_PIXEL(mi);
			if ((tiktak->cmap = XCreateColormap(display, window,
					MI_VISUAL(mi), AllocNone)) == None) {
				free_tik_tak(display, tiktak);
				return;
			}
			XSetWindowColormap(display, window, tiktak->cmap);
			(void) XParseColor(display, tiktak->cmap, "black", &color);
			(void) XAllocColor(display, tiktak->cmap, &color);
			MI_BLACK_PIXEL(mi) = color.pixel;
			(void) XParseColor(display, tiktak->cmap, "white", &color);
			(void) XAllocColor(display, tiktak->cmap, &color);
			MI_WHITE_PIXEL(mi) = color.pixel;
#ifndef STANDALONE
			(void) XParseColor(display, tiktak->cmap, background, &color);
			(void) XAllocColor(display, tiktak->cmap, &color);
			MI_BG_PIXEL(mi) = color.pixel;
			(void) XParseColor(display, tiktak->cmap, foreground, &color);
			(void) XAllocColor(display, tiktak->cmap, &color);
			MI_FG_PIXEL(mi) = color.pixel;
#endif
			tiktak->colors = (XColor *) NULL;
			tiktak->ncolors = 0;
		}
		if ((tiktak->gc = XCreateGC(display, MI_WINDOW(mi),
			     (unsigned long) 0, (XGCValues *) NULL)) == None) {
			free_tik_tak(display, tiktak);
			return;
		}
	}
/* Clear Display */
	MI_CLEARWINDOW(mi);
	tiktak->painted = False;
	XSetFunction(display, tiktak->gc, GXxor);


/*Set up tik_tak data */
	tiktak->direction = (LRAND() & 1) ? 1 : -1;
	tiktak->win_width = MI_WIDTH(mi);
	tiktak->win_height = MI_HEIGHT(mi);
	tiktak->num_object = MI_COUNT(mi);
        tiktak->x0 = tiktak->win_width / 2;
        tiktak->y0 = tiktak->win_height / 2;
	max_objects = MI_COUNT(mi);
	if (tiktak->num_object == 0) {
		tiktak->num_object = DEF_NUM_OBJECT;
		max_objects = DEF_NUM_OBJECT;
	} else if (tiktak->num_object < 0) {
		max_objects = -tiktak->num_object;
		tiktak->num_object = NRAND(-tiktak->num_object) + 1;
	}
	if (tiktak->object == NULL)
		if ((tiktak->object = (tik_takobject *) calloc(max_objects,
				sizeof (tik_takobject))) == NULL) {
			free_tik_tak(display, tiktak);
			return;
		}
	size_object = MIN( tiktak->win_width , tiktak->win_height) / 3;
	if ( abs( MI_SIZE(mi) ) > size_object) {
	   if ( MI_SIZE( mi ) < 0 )
	     {
		size_object = -size_object;
	     }
	}
   else
     {
	size_object = MI_SIZE(mi);
     }
	if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) {
/* Set up colour map */
		if (tiktak->colors != NULL) {
			if (tiktak->ncolors && !tiktak->no_colors)
				free_colors(display, tiktak->cmap, tiktak->colors, tiktak->ncolors);
			free(tiktak->colors);
//.........这里部分代码省略.........
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:101,代码来源:tik_tak.c


示例5: init_planet

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);
//.........这里部分代码省略.........
开发者ID:davehorner,项目名称:XScreenSaverWin,代码行数:101,代码来源:glplanet.c


示例6: init_laser

ENTRYPOINT void
init_laser(ModeInfo * mi)
{
    Display *display = MI_DISPLAY(mi);
    int         i, c = 0;
    lasersstruct *lp;

    if (lasers == NULL) {
        if ((lasers = (lasersstruct *) calloc(MI_NUM_SCREENS(mi),
                                              sizeof (lasersstruct))) == NULL)
            return;
    }
    lp = &lasers[MI_SCREEN(mi)];

    lp->width = MI_WIDTH(mi);
    lp->height = MI_HEIGHT(mi);
    lp->time = 0;

    lp->ln = MI_COUNT(mi);
    if (lp->ln < -MINLASER) {
        /* if lp->ln is random ... the size can change */
        if (lp->laser != NULL) {
            (void) free((void *) lp->laser);
            lp->laser = (laserstruct *) NULL;
        }
        lp->ln = NRAND(-lp->ln - MINLASER + 1) + MINLASER;
    } else if (lp->ln < MINLASER)
        lp->ln = MINLASER;

    if (lp->laser == NULL) {
        if ((lp->laser = (laserstruct *) malloc(lp->ln *
                                                sizeof (laserstruct))) == NULL) {
            free_laser(display, lp);
            return;
        }
    }
    if (lp->stippledGC == None) {
        XGCValues   gcv;

        gcv.foreground = MI_WHITE_PIXEL(mi);
        gcv.background = MI_BLACK_PIXEL(mi);
        lp->gcv_black.foreground = MI_BLACK_PIXEL(mi);
        if ((lp->stippledGC = XCreateGC(display, MI_WINDOW(mi),
                                        GCForeground | GCBackground, &gcv)) == None) {
            free_laser(display, lp);
            return;
        }
# ifdef HAVE_JWXYZ
        jwxyz_XSetAntiAliasing (MI_DISPLAY(mi), lp->stippledGC, False);
# endif
    }
    MI_CLEARWINDOW(mi);

    if (MINDIST < lp->width - MINDIST)
        lp->cx = RANGE_RAND(MINDIST, lp->width - MINDIST);
    else
        lp->cx = RANGE_RAND(0, lp->width);
    if (MINDIST < lp->height - MINDIST)
        lp->cy = RANGE_RAND(MINDIST, lp->height - MINDIST);
    else
        lp->cy = RANGE_RAND(0, lp->height);
    lp->lw = RANGE_RAND(MINWIDTH, MAXWIDTH);
    lp->lr = RANGE_RAND(MINREDRAW, MAXREDRAW);
    lp->sw = 0;
    lp->so = 0;

    if (MI_NPIXELS(mi) > 2)
        c = NRAND(MI_NPIXELS(mi));

    for (i = 0; i < lp->ln; i++) {
        laserstruct *l = &lp->laser[i];

        l->bn = (border) NRAND(4);

        switch (l->bn) {
        case TOP:
            l->bx = NRAND(lp->width);
            l->by = 0;
            break;
        case RIGHT:
            l->bx = lp->width;
            l->by = NRAND(lp->height);
            break;
        case BOTTOM:
            l->bx = NRAND(lp->width);
            l->by = lp->height;
            break;
        case LEFT:
            l->bx = 0;
            l->by = NRAND(lp->height);
        }

        l->dir = (int) (LRAND() & 1);
        l->speed = ((RANGE_RAND(MINSPEED, MAXSPEED) * lp->width) / 1000) + 1;
        if (MI_NPIXELS(mi) > 2) {
            l->gcv.foreground = MI_PIXEL(mi, c);
            c = (c + COLORSTEP) % MI_NPIXELS(mi);
        } else
            l->gcv.foreground = MI_WHITE_PIXEL(mi);
    }
//.........这里部分代码省略.........
开发者ID:Ro6afF,项目名称:XScreenSaver,代码行数:101,代码来源:laser.c


示例7: init_blocktube

ENTRYPOINT void init_blocktube (ModeInfo *mi)
{
    int loop;
    GLfloat fogColor[4] = {0,0,0,1};
    blocktube_configuration *lp;
    int wire = MI_IS_WIREFRAME(mi);

    if (!lps) {
        lps = (blocktube_configuration *)
              calloc (MI_NUM_SCREENS(mi), sizeof (blocktube_configuration));
        if (!lps) {
            fprintf(stderr, "%s: out of memory\n", progname);
            exit(1);
        }
        lp = &lps[MI_SCREEN(mi)];
    }

    lp = &lps[MI_SCREEN(mi)];
    lp->glx_context = init_GL(mi);

    lp->zoom = 30;
    lp->tilt = 4.5;
    lp->tunnelLength = 200;
    lp->tunnelWidth = 5;

    if (wire) {
        do_fog = False;
        do_texture = False;
        glLineWidth(2);
    }

    lp->block_dlist = glGenLists (1);
    glNewList (lp->block_dlist, GL_COMPILE);
    lp->polys = cube_vertices(0.15, 1.2, 5.25, wire);
    glEndList ();

#if defined( I_HAVE_XPM )
    if (do_texture) {
        if (!LoadGLTextures(mi)) {
            fprintf(stderr, "%s: can't load textures!\n", progname);
            exit(1);
        }
        glEnable(GL_TEXTURE_2D);
    }
#endif

    /* kick on the fog machine */
    if (do_fog) {
        glEnable(GL_FOG);
        glFogi(GL_FOG_MODE, GL_LINEAR);
        glHint(GL_FOG_HINT, GL_NICEST);
        glFogf(GL_FOG_START, 0);
        glFogf(GL_FOG_END, lp->tunnelLength/1.8);
        glFogfv(GL_FOG_COLOR, fogColor);
        glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    }
    glShadeModel(GL_SMOOTH);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClearDepth(1.0f);

    if (!do_texture && !wire) {
        /* If there is no texture, the boxes don't show up without a light.
           Though I don't understand why all the blocks come out gray.
         */
        GLfloat pos[4] = {0.0, 1.0, 1.0, 0.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};
        glLightfv(GL_LIGHT0, GL_POSITION, pos);
        glLightfv(GL_LIGHT0, GL_AMBIENT,  amb);
        glLightfv(GL_LIGHT0, GL_DIFFUSE,  dif);
        glLightfv(GL_LIGHT0, GL_SPECULAR, spc);
        glEnable(GL_LIGHTING);
        glEnable(GL_LIGHT0);
    }

    lp->counter = holdtime;
    lp->currentR = random() % 256;
    lp->currentG = random() % 256;
    lp->currentB = random() % 256;
    newTargetColor(lp);
    for (loop = 0; loop < MAX_ENTITIES; loop++)
    {
        randomize_entity(lp, &lp->entities[loop]);
    }
    reshape_blocktube(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
    glFlush();
}
开发者ID:guerrerocarlos,项目名称:deb-xscreensaver,代码行数:90,代码来源:blocktube.c


示例8: init_knot

ENTRYPOINT void 
init_knot (ModeInfo *mi)
{
  knot_configuration *bp;
  int wire = MI_IS_WIREFRAME(mi);

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

  if (thickness <= 0) thickness = 0.001;
  else if (thickness > 1) thickness = 1;

  if (segments < 10) segments = 10;

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

  {
    Bool spinx=False, spiny=False, spinz=False;
    double spin_speed   = 2.0;
    double wander_speed = 0.05;
    double spin_accel   = 0.2;

    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,
                            spin_accel,
                            do_wander ? wander_speed : 0,
                            (spinx && spiny && spinz));
    bp->trackball = gltrackball_init ();
  }

  bp->knot_list = glGenLists (1);
  new_knot(mi);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
开发者ID:RazZziel,项目名称:pongclock,代码行数:83,代码来源:glknots.c


示例9: init_ball

ENTRYPOINT void 
init_ball (ModeInfo *mi)
{
  ball_configuration *bp;
  int wire = MI_IS_WIREFRAME(mi);

  if (!bps) {
    bps = (ball_configuration *)
      calloc (MI_NUM_SCREENS(mi), sizeof (ball_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_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 ();
  }

  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);
}
开发者ID:katahiromz,项目名称:XScreenSaverWin,代码行数:76,代码来源:dangerball.c


示例10: init_molecule

void
init_molecule (ModeInfo *mi)
{
  molecule_configuration *mc;
  int wire;

#ifndef STANDALONE
  timeout = MI_CYCLES(mi);
#endif
  if (!mcs) {
    mcs = (molecule_configuration *)
      calloc (MI_NUM_SCREENS(mi), sizeof (molecule_configuration));
    if (!mcs) {
       return;
    }
  }

  mc = &mcs[MI_SCREEN(mi)];
  if (mc->glx_context) {
	/* Free font stuff */
	free_fonts (mi);
  }

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

  if (!load_fonts (mi)) {
	release_molecule(mi);
	return;
  }
  if (firstcall)
  startup_blurb (mi);
  cur_wire = MI_IS_WIREFRAME(mi);
  wire = cur_wire;

  mc->rotx = FLOATRAND(1.0) * RANDSIGN();
  mc->roty = FLOATRAND(1.0) * RANDSIGN();
  mc->rotz = FLOATRAND(1.0) * RANDSIGN();

  /* bell curve from 0-6 degrees, avg 3 */
  mc->dx = (FLOATRAND(0.1) + FLOATRAND(0.1) + FLOATRAND(0.1)) / (360/2);
  mc->dy = (FLOATRAND(0.1) + FLOATRAND(0.1) + FLOATRAND(0.1)) / (360/2);
  mc->dz = (FLOATRAND(0.1) + FLOATRAND(0.1) + FLOATRAND(0.1)) / (360/2);

  mc->d_max = mc->dx * 8;

  mc->ddx = 0.00006 + FLOATRAND(0.00003);
  mc->ddy = 0.00006 + FLOATRAND(0.00003);
  mc->ddz = 0.00006 + FLOATRAND(0.00003);

  {
    char *s = do_spin;
    while (*s)
      {
        if      (*s == 'x' || *s == 'X') mc->spin_x = 1;
        else if (*s == 'y' || *s == 'Y') mc->spin_y = 1;
        else if (*s == 'z' || *s == 'Z') mc->spin_z = 1;
        else
          {
            (void) fprintf (stderr,
         "molecule: spin must contain only the characters X, Y, or Z (not \"%s\")\n",
                     do_spin);
            /* exit (1); */
          }
        s++;
      }
  }

  mc->molecule_dlist = glGenLists(1);

  load_molecules (mi);
  mc->which =  NRAND(mc->nmolecules);

#ifdef STANDALONE
  mc->no_label_threshold = get_float_resource ("noLabelThreshold",
                                               "NoLabelThreshold");
  mc->wireframe_threshold = get_float_resource ("wireframeThreshold",
                                                "WireframeThreshold");
#else
  mc->no_label_threshold = 30;
  mc->wireframe_threshold = 150;
#endif

  if (wire)
    do_bonds = 1;
}
开发者ID:Gelma,项目名称:xlockmore-for-13.04,代码行数:90,代码来源:molecule.c


示例11: build_molecule


//.........这里部分代码省略.........
      glEnable(GL_CULL_FACE);
    }

  if (!wire)
    set_atom_color (mi, 0, False);

  if (do_bonds)
    for (i = 0; i < m->nbonds; i++)
      {
        molecule_bond *b = &m->bonds[i];
        molecule_atom *from = get_atom(m->atoms, m->natoms, b->from,
		MI_IS_VERBOSE(mi));
        molecule_atom *to   = get_atom(m->atoms, m->natoms, b->to,
		MI_IS_VERBOSE(mi));

        if (wire)
          {
            glBegin(GL_LINES);
            glVertex3f(from->x, from->y, from->z);
            glVertex3f(to->x,   to->y,   to->z);
            glEnd();
          }
        else
          {
            int faces = (scale_down ? TUBE_FACES_2 : TUBE_FACES);
# ifdef SMOOTH_TUBE
            int smooth = True;
# else
            int smooth = False;
# endif
            GLfloat thickness = 0.07 * b->strength;
            GLfloat cap_size = 0.03;
            if (thickness > 0.3)
              thickness = 0.3;

            tube (from->x, from->y, from->z,
                  to->x,   to->y,   to->z,
                  thickness, cap_size,
                  faces, smooth, !do_atoms, wire);
          }
      }

  for (i = 0; i < m->natoms; i++)
    {
      molecule_atom *a = &m->atoms[i];
      int i;

      if (!wire && do_atoms)
        {
          GLfloat size = atom_size (a);
          set_atom_color (mi, a, False);
          sphere (a->x, a->y, a->z, size, wire);
        }

      if (do_labels)
        {
          glPushAttrib (GL_LIGHTING_BIT | GL_DEPTH_BUFFER_BIT);
          glDisable (GL_LIGHTING);
          glDisable (GL_DEPTH_TEST);

          if (!wire)
            set_atom_color (mi, a, True);

          glRasterPos3f (a->x, a->y, a->z);

          {
            GLdouble mm[17], pm[17];
            GLint vp[5];
            GLdouble wx=-1, wy=-1, wz=-1;
            glGetDoublev (GL_MODELVIEW_MATRIX, mm);
            glGetDoublev (GL_PROJECTION_MATRIX, pm);
            glGetIntegerv (GL_VIEWPORT, vp);

            /* Convert 3D coordinates to window coordinates */
            gluProject (a->x, a->y, a->z, mm, pm, vp, &wx, &wy, &wz);

            /* Fudge the window coordinates to center the string */
            wx -= string_width (mc->xfont1, a->label) / 2;
            wy -= mc->xfont1->descent;

            /* Convert new window coordinates back to 3D coordinates */
            gluUnProject (wx, wy, wz, mm, pm, vp, &wx, &wy, &wz);
            glRasterPos3f (wx, wy, wz);
          }

          for (i = 0; i < (int) strlen(a->label); i++)
            glCallList (mc->font1_dlist + (int)(a->label[i]));

          glPopAttrib();
        }
    }

  if (do_bbox)
    draw_bounding_box (mi);

  if (do_titles && m->label && *m->label)
    print_title_string (mi, m->label,
                        10, MI_HEIGHT(mi) - 10,
                        mc->xfont2->ascent + mc->xfont2->descent);
}
开发者ID:Gelma,项目名称:xlockmore-for-13.04,代码行数:101,代码来源:molecule.c


示例12: randomize_sprite

/* Pick random starting and ending positions for the given sprite.
 */
static void
randomize_sprite (ModeInfo *mi, sprite *sp)
{
  int vp_w = MI_WIDTH(mi);
  int vp_h = MI_HEIGHT(mi);
  int img_w = sp->img->geom.width;
  int img_h = sp->img->geom.height;
  int min_w, max_w;
  double ratio = (double) img_h / img_w;

  if (letterbox_p)
    {
      min_w = img_w;
    }
  else
    {
      if (img_w < vp_w)
        min_w = vp_w;
      else
        min_w = img_w * (float) vp_h / img_h;
    }

  max_w = min_w * 100 / zoom;

  sp->from.w = min_w + frand ((max_w - min_w) * 0.4);
  sp->to.w   = max_w - frand ((max_w - min_w) * 0.4);
  sp->from.h = sp->from.w * ratio;
  sp->to.h   = sp->to.w   * ratio;

  if (zoom == 100)	/* only one box, and it is centered */
    {
      sp->from.x = (sp->from.w > vp_w
                    ? -(sp->from.w - vp_w) / 2
                    :  (vp_w - sp->from.w) / 2);
      sp->from.y = (sp->from.h > vp_h
                    ? -(sp->from.h - vp_h) / 2
                    :  (vp_h - sp->from.h) / 2);
      sp->to = sp->from;
    }
  else			/* position both boxes randomly */
    {
      sp->from.x = (sp->from.w > vp_w
                    ? -frand (sp->from.w - vp_w)
                    :  frand (vp_w - sp->from.w));
      sp->from.y = (sp->from.h > vp_h
                    ? -frand (sp->from.h - vp_h)
                    :  frand (vp_h - sp->from.h));
      sp->to.x   = (sp->to.w > vp_w
                    ? -frand (sp->to.w - vp_w)
                    :  frand (vp_w - sp->to.w));
      sp->to.y   = (sp->to.h > vp_h
                    ? -frand (sp->to.h - vp_h)
                    :  frand (vp_h - sp->to.h));
    }

  if (random() & 1)
    {
      rect swap = sp->to;
      sp->to = sp->from;
      sp->from = swap;
    }

  /* Make sure the aspect ratios are within 0.001 of each other.
   */
  {
    int r1 = 0.5 + (sp->from.w * 1000 / sp->from.h);
    int r2 = 0.5 + (sp->to.w   * 1000 / sp->to.h);
    if (r1 < r2-1 || r1 > r2+1)
      {
        fprintf (stderr,
                 "%s: botched aspect: %f x %f (%d) vs  %f x %f (%d): %s\n",
                 progname, 
                 sp->from.w, sp->from.h, r1,
                 sp->to.w, sp->to.h, r2,
                 (sp->img->title ? sp->img->title : "[null]"));
        abort();
      }
  }

  sp->from.x /= vp_w;
  sp->from.y /= vp_h;
  sp->from.w /= vp_w;
  sp->from.h /= vp_h;
  sp->to.x   /= vp_w;
  sp->to.y   /= vp_h;
  sp->to.w   /= vp_w;
  sp->to.h   /= vp_h;
}
开发者ID:MaddTheSane,项目名称:xscreensaver,代码行数:90,代码来源:glslideshow.c


示例13: image_loaded_cb

/* Callback that tells us that the texture has been loaded.
 */
static void
image_loaded_cb (const char *filename, XRectangle *geom,
                 int image_width, int image_height,
                 int texture_width, int texture_height,
                 void *closure)
{
  image *img = (image *) closure;
  ModeInfo *mi = img->mi;
  /* slideshow_state *ss = &sss[MI_SCREEN(mi)]; */

  int wire = MI_IS_WIREFRAME(mi);

  if (wire)
    {
      img->w = MI_WIDTH (mi) * (0.5 + frand (1.0));
      img->h = MI_HEIGHT (mi);
      img->geom.width  = img->w;
      img->geom.height = img->h;
      goto DONE;
    }

  if (image_width == 0 || image_height == 0)
    exit (1);

  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
                   mipmap_p ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);

  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

  img->w  = image_width;
  img->h  = image_height;
  img->tw = texture_width;
  img->th = texture_height;
  img->geom = *geom;
  img->title = (filename ? strdup (filename) : 0);

  /* If the image's width doesn't come back as the width of the screen,
     then the image must have been scaled down (due to insufficient
     texture memory.)  Scale up the coordinates to stretch the image
     to fill the window.
   */
  if (img->w != MI_WIDTH(mi))
    {
      double scale = (double) MI_WIDTH(mi) / img->w;
      img->w  *= scale;
      img->h  *= scale;
      img->tw *= scale;
      img->th *= scale;
      img->geom.x      *= scale;
      img->geom.y      *= scale;
      img->geom.width  *= scale;
      img->geom.height *= scale;
    }

  /* xscreensaver-getimage returns paths relative to the image directory
     now, so leave the sub-directory part in.  Unless it's an absolute path.
  */
  if (img->title && img->title[0] == '/')
    {
      /* strip filename to part between last "/" and last ".". */
      char *s = strrchr (img->title, '/');
      if (s) strcpy (img->title, s+1);
      s = strrchr (img->title, '.');
      if (s) *s = 0;
    }

  if (debug_p)
    fprintf (stderr, "%s: loaded   img %2d: \"%s\"\n",
             blurb(), img->id, (img->title ? img->title : "(null)"));
 DONE:

  img->loaded_p = True;
}
开发者ID:MaddTheSane,项目名称:xscreensaver,代码行数:77,代码来源:glslideshow.c


示例14: draw_antmaze

ENTRYPOINT void draw_antmaze(ModeInfo * mi) 
{
  double h = (GLfloat) MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi);

  antmazestruct *mp;
  
  Display    *display = MI_DISPLAY(mi);
  Window      window = MI_WINDOW(mi);
  
  if(!antmaze)
	return;
  mp = &antmaze[MI_SCREEN(mi)];
  
  MI_IS_DRAWN(mi) = True;
  
  if(!mp->glx_context)
	return;
  
  mi->polygon_count = 0;
  glXMakeCurrent(display, window, *(mp->glx_context));

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  /* first panel */
  glPushMatrix();
/*   h = ((GLfloat) MI_HEIGHT(mi)/2) / (3*(GLfloat)MI_WIDTH(mi)/4); */
  glViewport(MI_WIDTH(mi)/32, MI_HEIGHT(mi)/8, (9*MI_WIDTH(mi))/16, 3*MI_HEIGHT(mi)/4);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();

/*   h = (3*MI_HEIGHT(mi)/4) / (3*MI_WIDTH(mi)/4); */
  gluPerspective(45, 1/h, 1, 25.0);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  device_rotate(mi);

  glPushMatrix();

  /* follow focused ant */
  glTranslatef(0.0, 0.0, -mp->mag - 5.0);
  glRotatef(20.0+5.0*sin(mp->ant_step/40.0), 1.0, 0.0, 0.0);
/*   glTranslatef(0.0,  */
/* 	       started ? -mag : -8.0 + 4.0*fabs(sin(ant_step/10.0)),  */
/* 	       started ? -mag : -8.0 + 4.0*fabs(sin(ant_step/10.0))); */

  gltrackball_rotate(mp->trackball);

  glRotatef(mp->ant_step*0.6, 0.0, 1.0, 0.0);

/*   glRotatef(90.0, 0.0, 0.0, 1.0); */

/*   glTranslatef(-antposition[0][0]-0.5, 0.0, -antposition[focus][1]); */
  /*-elevator*/

  /* sync */
  if(!draw_antmaze_strip(mi)) {
    release_antmaze(mi);
    return;
  }

  glPopMatrix();
  glPopMatrix();

  h = (GLfloat) (3*MI_HEIGHT(mi)/8) / (GLfloat) (MI_WIDTH(mi)/2);

  /* draw overhead */
  glPushMatrix();
  glViewport((17*MI_WIDTH(mi))/32, MI_HEIGHT(mi)/2, MI_WIDTH(mi)/2, 3*MI_HEIGHT(mi)/8);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  device_rotate(mi);
  gluPerspective(45, 1/h, 1, 25.0);
  glMatrixMode(GL_MODELVIEW);
    
  /* twist scene */
  glTranslatef(0.0, 0.0, -16.0);
  glRotatef(60.0, 1.0, 0.0, 0.0);
  glRotatef(-15.0 + mp->ant_step/10.0, 0.0, 1.0, 0.0);
  gltrackball_rotate(mp->trackball);

  /* sync */
  if(!draw_antmaze_strip(mi)) {
    release_antmaze(mi);
    return;
  }

  glPopMatrix();

  /* draw ant display */
  glPushMatrix();
  glViewport((5*MI_WIDTH(mi))/8, MI_HEIGHT(mi)/8, (11*MI_WIDTH(mi))/32, 3*MI_HEIGHT(mi)/8);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  device_rotate(mi);
  gluPerspective(45, 1/h, 1, 25.0);
  glMatrixMode(GL_MODELVIEW);
    
  /* twist scene */
  glTranslatef(0.0, 0.0, -1.6);
//.........这里部分代码省略.........
开发者ID:katahiromz,项目名称:XScreenSaverWin,代码行数:101,代码来源:antmaze.c


示例15: reshape_pulsar

/* Standard reshape function */
ENTRYPOINT void
reshape_pulsar(ModeInfo *mi, int width, int height)
{
  glViewport( 0, 0, MI_WIDTH(mi), MI_HEIGHT(mi) );
  resetProjection();
}
开发者ID:RazZziel,项目名称:pongclock,代码行数:7,代码来源:pulsar.c


示例16: init_quasicrystal

ENTRYPOINT void 
init_quasicrystal (ModeInfo *mi)
{
  quasicrystal_configuration *bp;
  int wire = MI_IS_WIREFRAME(mi);
  unsigned char *tex_data = 0;
  int tex_width;
  int i;

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

  glDisable (GL_DEPTH_TEST);
  glEnable (GL_CULL_FACE);

  bp->count = MI_COUNT(mi);
  if (bp->count < 1) bp->count = 1;

  if (! wire)
    {
      unsigned char *o;
      tex_width = 4096;
      tex_data = (unsigned char *) calloc (4, tex_width);
      o = tex_data;
      for (i = 0; i < tex_width; i++)
        {
          unsigned char y = 255 * (1 + sin (i * M_PI * 2 / tex_width)) / 2;
          *o++ = y;
          *o++ = y;
          *o++ = y;
          *o++ = 255;
        }
    }

  bp->symmetric_p =
    get_boolean_resource (MI_DISPLAY (mi), "symmetry", "Symmetry");

  bp->contrast = get_float_resource (MI_DISPLAY (mi), "contrast", "Contrast");
  if (bp->contrast < 0 || bp->contrast > 100) 
    {
      fprintf (stderr, "%s: contrast must be between 0 and 100%%.\n", progname);
      bp->contrast = 0;
    }

  {
    Bool spinp   = get_boolean_resource (MI_DISPLAY (mi), "spin", "Spin");
    Bool wanderp = get_boolean_resource (MI_DISPLAY (mi), "wander", "Wander");
    double spin_speed   = 0.01;
    double wander_speed = 0.0001;
    double spin_accel   = 10.0;
    double scale_speed  = 0.005;

    bp->planes = (plane *) calloc (sizeof (*bp->planes), bp->count);

    bp->ncolors = 256;  /* ncolors affects color-cycling speed */
    bp->colors = (XColor *) calloc (bp->ncolors, sizeof(XColor));
    make_smooth_colormap (0, 0, 0, bp->colors, &bp->ncolors,
                          False, 0, False);
    bp->ccolor = 0;

    for (i = 0;  i < bp->count; i++)
      {
        plane *p = &bp->planes[i];
        p->rot = make_rotator (0, 0,
                               spinp ? spin_speed : 0,
                               spin_accel,
                               wanderp ? wander_speed : 0,
                               True);
        p->rot2 = make_rotator (0, 0,
                                0, 0,
                               scale_speed,
                               True);
        if (! wire)
          {
            clear_gl_error();

            glGenTextures (1, &p->texid);
            glBindTexture (GL_TEXTURE_1D, p->texid);
            glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
            glTexImage1D (GL_TEXTURE_1D, 0, GL_RGBA,
                          tex_width, 0,
                          GL_RGBA,
                          /* GL_UNSIGNED_BYTE, */
                          GL_UNSIGNED_INT_8_8_8_8_REV,
                          tex_data);
            check_gl_error("texture");

            glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT);
//.........这里部分代码省略.........
开发者ID:adaydreaming,项目名称:xscreensaver,代码行数:101,代码来源:quasicrystal.c


示例17: draw_stairs

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MI_NPIXELS函数代码示例发布时间:2022-05-30
下一篇:
C++ MI_GC函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap