Exemplo n.º 1
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);
}
Exemplo n.º 2
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);
}
Exemplo n.º 3
0
static void
pinit(ModeInfo *mi)
{
	int status;

	glClearDepth(1.0);
	glClearColor(0.0, 0.0, 0.0, 1.0);

    if (MI_IS_WIREFRAME(mi))
      return;

	glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
	glLightfv(GL_LIGHT0, GL_POSITION, position0);
	glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
	glLightfv(GL_LIGHT1, GL_POSITION, position1);
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
	glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glEnable(GL_LIGHT1);
	glEnable(GL_NORMALIZE);
	glFrontFace(GL_CCW);
	glCullFace(GL_BACK);

	/* cage */
	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialWhite);
	glShadeModel(GL_FLAT);
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_CULL_FACE);

	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

	clear_gl_error();
	if (MI_IS_MONO(mi))
      status = 0;
    else
      status = gluBuild2DMipmaps(GL_TEXTURE_2D, 3,
                                 WoodTextureWidth, WoodTextureHeight,
                                 GL_RGB, GL_UNSIGNED_BYTE, WoodTextureData);
	if (status)
	  {
		const char *s = (char *) gluErrorString (status);
		fprintf (stderr, "%s: error mipmapping texture: %s\n",
				 progname, (s ? s : "(unknown)"));
		exit (1);
	  }
	check_gl_error("mipmapping");

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

	glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_shininess);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular);
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
0
static void
MakeValve(ModeInfo * mi, int newdir)
{
	pipesstruct *pp = &pipes[MI_SCREEN(mi)];

	/* There is a glPopMatrix() right after this subroutine returns. */
	switch (newdir) {
		case dirUP:
		case dirDOWN:
			glRotatef(90.0, 1.0, 0.0, 0.0);
			glRotatef(NRAND(3) * 90.0, 0.0, 0.0, 1.0);
			break;
		case dirLEFT:
		case dirRIGHT:
			glRotatef(90.0, 0.0, -1.0, 0.0);
			glRotatef((NRAND(3) * 90.0) - 90.0, 0.0, 0.0, 1.0);
			break;
		case dirNEAR:
		case dirFAR:
			glRotatef(NRAND(4) * 90.0, 0.0, 0.0, 1.0);
			break;
	}
	glFrontFace(GL_CW);
	glCallList(pp->betweenbolts);
    mi->polygon_count += LWO_PipeBetweenBolts.num_pnts/3;
	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
	glCallList(pp->bolts);
    mi->polygon_count += LWO_Bolts3D.num_pnts/3;
	if (!MI_IS_MONO(mi)) {
		if (pp->system_color == MaterialRed) {
			glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, NRAND(2) ? MaterialYellow : MaterialBlue);
		} else if (pp->system_color == MaterialBlue) {
			glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, NRAND(2) ? MaterialRed : MaterialYellow);
		} else if (pp->system_color == MaterialYellow) {
			glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, NRAND(2) ? MaterialBlue : MaterialRed);
		} else {
			switch ((NRAND(3))) {
				case 0:
					glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialRed);
					break;
				case 1:
					glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialBlue);
					break;
				case 2:
					glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialYellow);
			}
		}
	}
	glRotatef((GLfloat) (NRAND(90)), 1.0, 0.0, 0.0);
	glCallList(pp->valve);
    mi->polygon_count += LWO_BigValve.num_pnts/3;
	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pp->system_color);
	glFrontFace(GL_CCW);
}
Exemplo n.º 6
0
static void init_gl(ModeInfo *mi) 
{
  cubicgrid_conf *cp = &cubicgrid[MI_SCREEN(mi)];
  int x, y, z;
  float tf = ticks;

  glDrawBuffer(GL_BACK);
  if(bigdots) {
    glPointSize(2.0);
  }
  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  glShadeModel(GL_FLAT);

  cp->list = glGenLists(1);
  glNewList(cp->list, GL_COMPILE);
  if(MI_IS_MONO(mi)) {
    glColor3f(1.0, 1.0, 1.0);
    glBegin(GL_POINTS);
    for(x = 0; x < ticks; x++) {
      for(y = 0; y < ticks; y++) {
        for(z = 0; z < ticks; z++) {
          glVertex3f(x, y, z);
          cp->npoints++;
        }
      }
    }
    glEnd();
  }
  else
  {
    glBegin(GL_POINTS);
    for(x = 0; x < ticks; x++) {
      for(y = 0; y < ticks; y++) {
        for(z = 0; z < ticks; z++) {
          glColor3f(x/tf, y/tf, z/tf);
          glVertex3f(x, y, z);
          cp->npoints++;
        }
      }
    }
    glEnd();
  }
  glEndList();
}
ENTRYPOINT void
init_superquadrics(ModeInfo * mi)
{
	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);
	int         screen = MI_SCREEN(mi);

	superquadricsstruct *sp;

	if (superquadrics == NULL) {
		if ((superquadrics = (superquadricsstruct *) calloc(MI_NUM_SCREENS(mi),
				      sizeof (superquadricsstruct))) == NULL)
			return;
	}
	sp = &superquadrics[screen];
	sp->mono = (MI_IS_MONO(mi) ? 1 : 0);

    sp->pats[1][1] = 1;
    sp->pats[1][3] = 1;
    sp->pats[2][2] = 1;
    sp->pats[2][3] = 1;
    sp->pats[3][1] = 1;
    sp->pats[3][2] = 1;

/*		{0, 0, 0, 0},
		{0, 1, 0, 1},
		{0, 0, 1, 1},
		{0, 1, 1, 0}
 */

	if ((sp->glx_context = init_GL(mi)) != NULL) {

		InitSuperquadrics(MI_IS_WIREFRAME(mi), 0,
				  MI_COUNT(mi), MI_CYCLES(mi), spinspeed, sp);
		ReshapeSuperquadrics(MI_WIDTH(mi), MI_HEIGHT(mi));

		DisplaySuperquadrics(sp);
		glFinish();
		glXSwapBuffers(display, window);
	} else {
		MI_CLEARWINDOW(mi);
	}
}
Exemplo n.º 8
0
static Bool
draw_moebius_strip(ModeInfo * mi)
{
	GLfloat     Phi, Theta;
	GLfloat     cPhi, sPhi;
	moebiusstruct *mp = &moebius[MI_SCREEN(mi)];
	int         i, j;
	int         mono = MI_IS_MONO(mi);

	float       Cx, Cy, Cz;

#ifdef HAVE_JWZGLES /* #### glPolygonMode other than GL_FILL unimplemented */
    solidmoebius = True;
#endif

	if (solidmoebius) {
		glBegin(GL_QUAD_STRIP);
		Phi = 0;
		i = 0;
		while (i < (MoebiusDivisions * 2 + 1)) {
			Theta = Phi / 2;
			cPhi = cos(Phi);
			sPhi = sin(Phi);

			i++;
			if (mono)
				glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialWhite);
			else if (i % 2)
				glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialRed);
			else
				glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);

			RotateAaroundU(cPhi, sPhi, 0, -sPhi, cPhi, 0, &Cx, &Cy, &Cz, Theta);
			glNormal3f(Cx, Cy, Cz);
			RotateAaroundU(0, 0, 1, -sPhi, cPhi, 0, &Cx, &Cy, &Cz, Theta);
			glVertex3f(cPhi * 3 + Cx, sPhi * 3 + Cy, +Cz);
			glVertex3f(cPhi * 3 - Cx, sPhi * 3 - Cy, -Cz);

			Phi += Pi / MoebiusDivisions;
		}
		glEnd();
	} else {
		for (j = -MoebiusTransversals; j < MoebiusTransversals; j++) {
			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
			glBegin(GL_QUAD_STRIP);
			Phi = 0;
			i = 0;
			while (i < (MoebiusDivisions * 2 + 1)) {
				Theta = Phi / 2;
				cPhi = cos(Phi);
				sPhi = sin(Phi);

				RotateAaroundU(cPhi, sPhi, 0, -sPhi, cPhi, 0, &Cx, &Cy, &Cz, Theta);
				glNormal3f(Cx, Cy, Cz);
				RotateAaroundU(0, 0, 1, -sPhi, cPhi, 0, &Cx, &Cy, &Cz, Theta);
				j++;
				if (j == MoebiusTransversals || mono)
					glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialWhite);
				else if (i % 2)
					glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialRed);
				else
					glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
				glVertex3f(cPhi * 3 + Cx / MoebiusTransversals * j, sPhi * 3 + Cy / MoebiusTransversals * j, +Cz / MoebiusTransversals * j);
				j--;
				if (j == -MoebiusTransversals || mono)
					glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialWhite);
				else if (i % 2)
					glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialRed);
				else
					glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
				glVertex3f(cPhi * 3 + Cx / MoebiusTransversals * j, sPhi * 3 + Cy / MoebiusTransversals * j, +Cz / MoebiusTransversals * j);

				Phi += Pi / MoebiusDivisions;
				i++;
			}
			glEnd();
		}
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	}

	if (drawants) {
		/* DRAW BLUE ANT */
		glPushMatrix();
		glRotatef(mp->ant_position + 180, 0, 0, 1);
		glTranslatef(3, 0, 0);
		glRotatef(mp->ant_position / 2 + 90, 0, 1, 0);
		glTranslatef(0.28, 0, -0.45);
		if (!draw_moebius_ant(mp, MaterialYellow, mono))
			return False;
		glPopMatrix();

		/* DRAW YELLOW ANT */
		glPushMatrix();
		glRotatef(mp->ant_position, 0, 0, 1);
		glTranslatef(3, 0, 0);
		glRotatef(mp->ant_position / 2, 0, 1, 0);
		glTranslatef(0.28, 0, -0.45);
		if (!draw_moebius_ant(mp, MaterialBlue, mono))
			return False;
		glPopMatrix();

		/* DRAW GREEN ANT */
		glPushMatrix();
		glRotatef(-mp->ant_position, 0, 0, 1);
		glTranslatef(3, 0, 0);
		glRotatef(-mp->ant_position / 2, 0, 1, 0);
		glTranslatef(0.28, 0, 0.45);
		glRotatef(180, 1, 0, 0);
		if (!draw_moebius_ant(mp, MaterialGreen, mono))
			return False;
		glPopMatrix();

		/* DRAW CYAN ANT */
		glPushMatrix();
		glRotatef(-mp->ant_position + 180, 0, 0, 1);
		glTranslatef(3, 0, 0);
		glRotatef(-mp->ant_position / 2 + 90, 0, 1, 0);
		glTranslatef(0.28, 0, 0.45);
		glRotatef(180, 1, 0, 0);
		if (!draw_moebius_ant(mp, MaterialCyan, mono))
			return False;
		glPopMatrix();
	}
	mp->ant_position += 1;
	return True;
}
Exemplo n.º 9
0
static void
pinit(ModeInfo * mi, int zera)
{
	pipesstruct *pp = &pipes[MI_SCREEN(mi)];
	int         X, Y, Z;

	if (zera) {
		pp->system_number = 1;
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		(void) memset(pp->Cells, 0, sizeof (pp->Cells));
		for (X = 0; X < HCELLS; X++) {
			for (Y = 0; Y < VCELLS; Y++) {
				pp->Cells[X][Y][0] = 1;
				pp->Cells[X][Y][HCELLS - 1] = 1;
				pp->Cells[0][Y][X] = 1;
				pp->Cells[HCELLS - 1][Y][X] = 1;
			}
		}
		for (X = 0; X < HCELLS; X++) {
			for (Z = 0; Z < HCELLS; Z++) {
				pp->Cells[X][0][Z] = 1;
				pp->Cells[X][VCELLS - 1][Z] = 1;
			}
		}
		(void) memset(pp->usedcolors, 0, sizeof (pp->usedcolors));
	}
	pp->counter = 0;
	pp->turncounter = 0;

	if (!MI_IS_MONO(mi)) {
		int         collist[DEFINEDCOLORS];
		int         i, j, lower = 1000;

		/* Avoid repeating colors on the same screen unless necessary */
		for (i = 0; i < DEFINEDCOLORS; i++) {
			if (lower > pp->usedcolors[i])
				lower = pp->usedcolors[i];
		}
		for (i = 0, j = 0; i < DEFINEDCOLORS; i++) {
			if (pp->usedcolors[i] == lower) {
				collist[j] = i;
				j++;
			}
		}
		i = collist[NRAND(j)];
		pp->usedcolors[i]++;
		switch (i) {
			case 0:
				pp->system_color = MaterialRed;
				break;
			case 1:
				pp->system_color = MaterialGreen;
				break;
			case 2:
				pp->system_color = MaterialBlue;
				break;
			case 3:
				pp->system_color = MaterialCyan;
				break;
			case 4:
				pp->system_color = MaterialYellow;
				break;
			case 5:
				pp->system_color = MaterialMagenta;
				break;
			case 6:
				pp->system_color = MaterialWhite;
				break;
		}
	} else {
		pp->system_color = MaterialGray;
	}

	do {
		pp->PX = NRAND((HCELLS - 1)) + 1;
		pp->PY = NRAND((VCELLS - 1)) + 1;
		pp->PZ = NRAND((HCELLS - 1)) + 1;
	} while (pp->Cells[pp->PX][pp->PY][pp->PZ] ||
		 (pp->Cells[pp->PX + 1][pp->PY][pp->PZ] && pp->Cells[pp->PX - 1][pp->PY][pp->PZ] &&
		  pp->Cells[pp->PX][pp->PY + 1][pp->PZ] && pp->Cells[pp->PX][pp->PY - 1][pp->PZ] &&
		  pp->Cells[pp->PX][pp->PY][pp->PZ + 1] && pp->Cells[pp->PX][pp->PY][pp->PZ - 1]));
	pp->Cells[pp->PX][pp->PY][pp->PZ] = 1;
	pp->olddir = dirNone;

	FindNeighbors(mi);

	pp->nowdir = SelectNeighbor(mi);
}
Exemplo n.º 10
0
/* draw the scene */
static Bool draw_antinspect_strip(ModeInfo * mi) 
{
  antinspectstruct *mp = &antinspect[MI_SCREEN(mi)];
  int         i, j;
  int         mono = MI_IS_MONO(mi);

  int ro = (((int)antposition[1])/(360/(2*ANTCOUNT))) % (2*ANTCOUNT);

  glEnable(GL_TEXTURE_2D);
  position0[1] = 9.6;
  glLightfv(GL_LIGHT0, GL_POSITION, position0);

  glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray5);
  glRotatef(-30.0, 0.0, 1.0, 0.0);

  glDisable(GL_TEXTURE_2D);
  glDisable(GL_BLEND);

  /* render ground plane */
  glBegin(GL_TRIANGLES);
  glColor4fv(MaterialShadow);
  glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialBlack);
  glNormal3f(0.0, 1.0, 0.0);

  /* middle tri */
  glVertex3f(0.0, 0.0, -1.0);
  glVertex3f(-sqrt(3.0)/2.0, 0.0, 0.5);
  glVertex3f(sqrt(3.0)/2.0, 0.0, 0.5);
  mi->polygon_count++;
  glEnd();

  /* rotate */
  for(i = 0; i < 3; ++i) {
    glRotatef(120.0, 0.0, 1.0, 0.0);
    glBegin(GL_TRIANGLES);
    glVertex3f(0.0, 0.0, 1.0 + 3.0);
    glVertex3f(sqrt(3.0)/2.0, 0.0, -0.5 + 3.0);
    glVertex3f(-sqrt(3.0)/2.0, 0.0, -0.5 + 3.0);
    mi->polygon_count++;
    glEnd();
  }

  /* first render shadows -- no depth required */
  if(shadows) {
    GLfloat m[4][4];
    shadowmatrix(m, ground, position0);
    
    glColor4fv(MaterialShadow);
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialShadow);
    
    glDisable(GL_BLEND);
    glDisable(GL_LIGHTING);
    
    /* display ant shadow */
    glPushMatrix();
    glTranslatef(0.0, 0.001, 0.0);
    glMultMatrixf(m[0]);

    for(i = 0; i < ANTCOUNT; ++i) {

      /* draw ant */
      glPushMatrix();

      /* center */
      glRotatef(antposition[i], 0.0, 1.0, 0.0);
      glTranslatef(2.4, 0.0, 0.0);
      glTranslatef(0.0, antsphere[i], 0.0);
      glRotatef(90.0, 0.0, 1.0, 0.0);

      /* orient ant */
      glRotatef(10.0, 0.0, 1.0, 0.0);
      glRotatef(40.0, 0.0, 0.0, 1.0);
      glTranslatef(0.0, -0.8, 0.0);
      glRotatef(180.0, 0.0, 1.0, 0.0);
      glRotatef(90.0, 0.0, 0.0, 1.0);

      /* set colour */
      glColor4fv(MaterialShadow);
      glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialShadow);

      if(antposition[i] > 360.0)
	antposition[i] = 0.0;
      draw_antinspect_ant(mi, mp, MaterialShadow, mono, mySphere2, myCone2);

      glDisable(GL_BLEND);
      glDisable(GL_LIGHTING);

      /* draw sphere */
      glRotatef(-20.0, 1.0, 0.0, 0.0);
      glRotatef(-mp->ant_step*2, 0.0, 0.0, 1.0);
      glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialShadow);
      mySphere2(1.2);

      glPopMatrix();
    }
  
    glPopMatrix();
  }

  glEnable(GL_LIGHTING);

  /* truants */
  for(j = 0; j < ANTCOUNT; ++j) {
    /* determine rendering order */
    i = antorder[ro][j];

    glPushMatrix();
    
    /* center */
    glRotatef(antposition[i], 0.0, 1.0, 0.0);
    glTranslatef(2.4, 0.0, 0.0);
    glTranslatef(0.0, antsphere[i], 0.0);    
    glRotatef(90.0, 0.0, 1.0, 0.0);

    /* draw ant */
    glPushMatrix();
    glRotatef(10.0, 0.0, 1.0, 0.0);
    glRotatef(40.0, 0.0, 0.0, 1.0);
    glTranslatef(0.0, -0.8, 0.0);
    glRotatef(180.0, 0.0, 1.0, 0.0);
    glRotatef(90.0, 0.0, 0.0, 1.0);
    if(antposition[i] > 360.0)
      antposition[i] = 0.0;
    glEnable(GL_BLEND);
    draw_antinspect_ant(mi, mp, antmaterial[i], mono, mySphere2, myCone2);
    glDisable(GL_BLEND);
    glPopMatrix();

    /* draw sphere */
    glRotatef(-20.0, 1.0, 0.0, 0.0);
    glRotatef(-mp->ant_step*2, 0.0, 0.0, 1.0);
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mono ? MaterialGray5 : antmaterial[i]);
    mySphere2(1.2);
    glEnable(GL_BLEND);
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialBlack);
    mySphere(1.16);
    glDisable(GL_BLEND);
        
    glPopMatrix();

    /* finally, evolve */
    antposition[i] += antvelocity[i];
  }

  /* but the step size is the same! */
  mp->ant_step += 0.2;
  
  mp->ant_position += 1;
  return True;
}
Exemplo n.º 11
0
static void init_gl(ModeInfo *mi) 
{
  cube21_conf *cp = &cube21[MI_SCREEN(mi)];
#ifdef MIPMAP
  int status;
#endif
  parse_colmode();
  cp->wire = MI_IS_WIREFRAME(mi);
  cp->cmat = !cp->wire && (colmode != CUBE21_COLOR_WHITE);
  if(MI_IS_MONO(mi)) {
    tex = False;
    cp->cmat = False;
  }
  if(cp->wire) {
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    return;
  }
  if(!tex)
    cp->color_inner[0] = cp->color_inner[1] = cp->color_inner[2] = 0.4;
  else
    cp->color_inner[0] = cp->color_inner[1] = cp->color_inner[2] = 1.0;

  glClearDepth(1.0);
  glClearColor(0.0, 0.0, 0.0, 1.0);
  glDrawBuffer(GL_BACK);
  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  glShadeModel(GL_FLAT);
  glDepthFunc(GL_LESS);
  glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
  glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
  glLightfv(GL_LIGHT0, GL_POSITION, position0);
  glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
  glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
  glLightfv(GL_LIGHT1, GL_POSITION, position1);
  glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
  glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_LIGHT0);
  glEnable(GL_LIGHT1);
  glEnable(GL_LIGHTING);
  glEnable(GL_NORMALIZE);
  glEnable(GL_COLOR_MATERIAL);
  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, material_ambient);
  glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, material_diffuse);
  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, material_specular);
  glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
  if(!tex) return;
  glEnable(GL_TEXTURE_2D);
#ifdef MIPMAP
  clear_gl_error();
  status = gluBuild2DMipmaps(GL_TEXTURE_2D, 1, TEX_WIDTH, TEX_HEIGHT,
      GL_LUMINANCE, GL_UNSIGNED_BYTE, texture);
  if (status) {
    const char *s = gluErrorString(status);
    fprintf (stderr, "%s: error mipmapping texture: %s\n", progname, (s?s:"(unknown)"));
    exit (1);
  }
  check_gl_error("mipmapping");
#else    
  glTexImage2D(GL_TEXTURE_2D, 0, 1, TEX_WIDTH, TEX_HEIGHT,
      0, GL_LUMINANCE, GL_UNSIGNED_BYTE, cp->texture);
#endif  
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
#ifdef MIPMAP
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
#else
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
#endif
}
Exemplo n.º 12
0
static Bool draw_antmaze_strip(ModeInfo * mi) 
{
  antmazestruct *mp = &antmaze[MI_SCREEN(mi)];
  int i;
  int mono = MI_IS_MONO(mi);

/*   glMatrixMode(GL_MODELVIEW); */
/*   glLoadIdentity(); */
/*   glPushMatrix(); */

  glEnable(GL_LIGHTING);
/*   glDisable(GL_BLEND); */
  glEnable(GL_LIGHT0);
  glEnable(GL_LIGHT1);

  /* set light */
/*   double l1 = 1.0 - (elevator < 1.0 ? elevator : 2.0 - elevator); */
/*   GLfloat df[4] = {0.8*l1, 0.8*l1, 0.8*l1, 1.0}; */
/*   glLightfv(GL_LIGHT0, GL_DIFFUSE, df); */
/*   glLightfv(GL_LIGHT1, GL_DIFFUSE, df); */

  /* draw board */
  if(mp->elevator < 1.0) {
    glEnable(GL_TEXTURE_2D);
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray6);
    glTranslatef(-(BOARDSIZE-1)/2.0, 0.0, -(BOARDSIZE-1)/2.0);
    draw_board(mi, mp);
    glTranslatef(BOARDSIZE/2.0, 0.0, BOARDSIZE/2.0);
    glDisable(GL_TEXTURE_2D);
  }

  mp->introduced--;

  glTranslatef(0.0, -0.1, 0.0);

  for(i = 0; i < ANTCOUNT; ++i) {

/*     glLightfv(GL_LIGHT0, GL_DIFFUSE, df); */
/*     glLightfv(GL_LIGHT1, GL_DIFFUSE, df); */

    if(!mp->anton[i]) { continue; }

    /* determine location, move to goal */
    glPushMatrix();
    glTranslatef(0.0, 0.01, 0.0);
    glTranslatef(mp->antposition[i][0], mp->antposition[i][2], mp->antposition[i][1]);
/*     glScalef(1.0, 0.01, 1.0); */
    glScalef(0.6, 0.01, 0.6);
    glRotatef(180.0 + mp->antdirection[i]*180.0/PI, 0.0, 1.0, 0.0);
    glRotatef(90.0, 0.0, 0.0, 1.0);
    glDisable(GL_LIGHTING);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glColor4fv(MaterialGrayB);

    glScalef(mp->antsize[i], mp->antsize[i], mp->antsize[i]);

    /* slow down first ant */
    if(i == 0 && mp->part[i] == mp->antpathlength[i])
      draw_ant(mi, mp, MaterialGrayB, mono, 1, mp->first_ant_step, mySphere, myCone);
    else
      draw_ant(mi, mp, MaterialGrayB, mono, 1, mp->ant_step, mySphere, myCone);

    glPopMatrix();

    glDisable(GL_BLEND);
    glEnable(GL_LIGHTING);
    
    glPushMatrix();
/*     glTranslatef(0.0, 0.18, 0.0); */
    glTranslatef(0.0, 0.12, 0.0);
    glTranslatef(mp->antposition[i][0], mp->antposition[i][2], mp->antposition[i][1]);
    glRotatef(180.0 + mp->antdirection[i]*180.0/PI, 0.0, 1.0, 0.0);
    glRotatef(90.0, 0.0, 0.0, 1.0);
    glScalef(0.6, 0.6, 0.6);

    glScalef(mp->antsize[i], mp->antsize[i], mp->antsize[i]);

/*     glEnable(GL_TEXTURE_2D); */
/*     glBindTexture(GL_TEXTURE_2D, brushedtexture); */

/*     glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialRed); */

    /* slow down first ant */    
    if(i == 0 && mp->part[i] == mp->antpathlength[i] && mp->elevator > 0.0) {
      glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
      glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
      draw_ant(mi, mp, antmaterial[i], mono, 1, mp->first_ant_step, mySphere, myCone);
    }
    else {
/*       glLightfv(GL_LIGHT0, GL_DIFFUSE, df); */
/*       glLightfv(GL_LIGHT1, GL_DIFFUSE, df); */

      glEnable(GL_TEXTURE_2D);
      glBindTexture(GL_TEXTURE_2D, mp->brushedtexture);
      draw_ant(mi, mp, antmaterial[i], mono, 1, mp->ant_step, mySphereTex, myCone);
      glDisable(GL_TEXTURE_2D);
    }


/*     draw_ant(mi, antmaterial[i], mono, 0, ant_step, mySphereTex, myCone); */
/*     glDisable(GL_TEXTURE_2D); */
    glPopMatrix();
  }

/*   glPopMatrix(); */

/*   /\* now draw overlay *\/ */
/*   glDisable(GL_LIGHTING); */
/*   glDisable(GL_BLEND); */

/*   /\* go to ortho mode *\/ */
/*   glMatrixMode(GL_PROJECTION); */
/*   glPushMatrix(); */
/*   glLoadIdentity(); */
/*   glOrtho(-4.0, 4.0, -3.0, 3.0, -100.0, 100.0); */
  
/*   /\* translate to corner *\/ */
/*   glTranslatef(4.0-1.2, 3.0-1.2, 0.0); */

/*   glDisable(GL_LIGHTING); */
/*   glEnable(GL_BLEND); */

/*   /\* draw the 2d board *\/ */
/*   glBegin(GL_QUADS); */
/*   { */
/*     int i, j; */
/*     double sz = 1.0; */
/*     for(i = 0; i < BOARDSIZE; ++i) */
/*       for(j = 0; j < BOARDSIZE; ++j) { */
/* 	int par = board[i][j]; */
/* 	glColor4f(par ? 0.4 : 0.6, */
/* 		  par ? 0.4 : 0.6, */
/* 		  par ? 0.4 : 0.6, */
/* 		  0.5); */
/* 	glNormal3f(0.0, 0.0, 1.0); */
/* 	glVertex3f((sz*(i+1))/BOARDSIZE,     (sz*(j+1))/BOARDSIZE, 0.0); */
/* 	glVertex3f((sz*i)/BOARDSIZE, (sz*(j+1))/BOARDSIZE, 0.0); */
/* 	glVertex3f((sz*i)/BOARDSIZE, (sz*j)/BOARDSIZE, 0.0); */
/* 	glVertex3f((sz*(i+1))/BOARDSIZE, (sz*j)/BOARDSIZE, 0.0); */
/*      mi->polygon_count++; */
/*       } */
/*   } */
/*   glEnd(); */
  
/*   glPopMatrix(); */


  /* but the step size is the same! */
  mp->ant_step += 0.18;
/*   if(ant_step > 2*Pi) { */
/*     ant_step = 0.0; */
/*   } */

  if(mp->ant_step > 5*Pi)
    mp->started = 1;

  mp->ant_position += 1;
  return True;
}
Exemplo n.º 13
0
static void 
init_gl(ModeInfo *mi) 
{
  rubikblocks_conf *cp = &rubikblocks[MI_SCREEN(mi)];
#ifdef MIPMAP
  int status;
#endif
  cp->wire = MI_IS_WIREFRAME(mi);

# ifdef HAVE_JWZGLES /* #### glPolygonMode other than GL_FILL unimplemented */
  cp->wire = 0;
# endif

  if(MI_IS_MONO(mi))
    tex = False;
  if(cp->wire) {
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    return;
  }

  glClearDepth(1.0);
  glDrawBuffer(GL_BACK);
  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  glShadeModel(GL_FLAT);
  glDepthFunc(GL_LESS);
  glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
  glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
  glLightfv(GL_LIGHT0, GL_POSITION, position0);
  glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
  glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
  glLightfv(GL_LIGHT1, GL_POSITION, position1);
  glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
  glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_LIGHT0);
  glEnable(GL_LIGHT1);
  glEnable(GL_LIGHTING);
  glEnable(GL_NORMALIZE);
  glEnable(GL_COLOR_MATERIAL);
  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, material_ambient);
  glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, material_diffuse);
  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, material_specular);
  glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
  if (!tex) return;
  glEnable(GL_TEXTURE_2D);
#ifdef MIPMAP
  clear_gl_error();
  status = gluBuild2DMipmaps(GL_TEXTURE_2D, 1, TEX_WIDTH, TEX_HEIGHT,
      GL_LUMINANCE, GL_UNSIGNED_BYTE, cp->texture);
  if (status) {
    const char *s = (char *)gluErrorString(status);
    fprintf (stderr, "%s: error mipmapping texture: %s\n", progname, (s?s:"(unknown)"));
    exit (1);
  }
  check_gl_error("mipmapping");
#else    
  glTexImage2D(GL_TEXTURE_2D, 0, 1, TEX_WIDTH, TEX_HEIGHT,
      0, GL_LUMINANCE, GL_UNSIGNED_BYTE, cp->texture);
#endif  
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
#ifdef MIPMAP
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
#else
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
#endif
}
Exemplo n.º 14
0
static void new_ship(ModeInfo *mi)
{
  commander_conf *cp = &commander[MI_SCREEN(mi)];
  int i;
  GLfloat *this_v;
  GLint *p;
  /*GLfloat *this_n;*/
  int count;
#if 0
  int wire = MI_IS_WIREFRAME(mi);

  GLfloat bcolor[4] = {0.2, 0.2, 0.2, 0.2};
  GLfloat bspec[4]  = {0.1, 0.1, 0.1, 0.1};
  GLfloat bshiny    = 32.0;
  GLfloat pos[4] = {-8.0, -8.0, -16.0, 0.0}; /* -6 -6 -16 */
  GLfloat amb[4] = {0.2, 0.2, 0.2, 0.4};
  GLfloat dif[4] = {0.2, 0.2, 0.2, 0.2};
  GLfloat spc[4] = {0.0, 0.0, 0.0, 0.0};

	if(!wire) {
		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);

		glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, bcolor);
		glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, bspec);
		glMateriali  (GL_FRONT_AND_BACK, GL_SHININESS, bshiny);
	}
#endif

  cp->list = glGenLists(1);
  glNewList(cp->list, GL_COMPILE);
  if(MI_IS_MONO(mi)) {
    /* FIXME support mono display */
    abort();
  }

	/* wireframe strategy: use stencil buffer, not polygon offset,
	 * because it's impossible to get the right parameters for
	 * glPolygonOffset() reliably */
  
	/* hidden-line removal as per
	 * http://glprogramming.com/red/chapter14.html#name16
	 */

	/* TODO:
		 - reinstate choice of wireframe vs filled
		 - rationalise some of the duplicated code below
	 */

	glEnable(GL_STENCIL_TEST);
	glEnable(GL_DEPTH_TEST);
	glClear(GL_STENCIL_BUFFER_BIT);
	glStencilFunc(GL_ALWAYS, 0, 1);
	glStencilOp(GL_INVERT, GL_INVERT, GL_INVERT);

	glColor3f(1.0, 1.0, 1.0);

	p=ship_f[cp->which];
	this_v=ship_v[cp->which];

	/* for debugging - draw axes */
#if 0
	glLineWidth(1); 
	glBegin(GL_LINES); glVertex3f(0,0,0); glVertex3f(10,0,0); glEnd();
	glBegin(GL_LINES); glVertex3f(0,0,0); glVertex3f(0,10,0); glEnd();
	glBegin(GL_LINES); glVertex3f(0.1,0,0); glVertex3f(0.1,10,0); glEnd();
	glBegin(GL_LINES); glVertex3f(0,0,0); glVertex3f(0,0,10); glEnd();
	glBegin(GL_LINES); glVertex3f(0,0.1,0); glVertex3f(0,0.1,10); glEnd();
	glBegin(GL_LINES); glVertex3f(0,0.2,0); glVertex3f(0,0.2,10); glEnd();
#endif

	/* draw the wireframe shape */
	while(*p != 0) {
		count=*p; p++;

		/* draw outline polygon */

		if(count==1) { glBegin(GL_POINTS); }
		else if(count==2) {
			/* chunky lines :-) */
			glLineWidth(2); 
			glBegin(GL_LINES);
		}
		else {
			glLineWidth(2); 
			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
			glBegin(GL_POLYGON); 
			do_normal(this_v[p[0]*3], this_v[p[0]*3+1], this_v[p[0]*3+2],
				this_v[p[1]*3], this_v[p[1]*3+1], this_v[p[1]*3+2],
				this_v[p[2]*3], this_v[p[2]*3+1], this_v[p[2]*3+2]);
		}
		for (i = 0 ; i < count ; i++) {
			glVertex3f(this_v[p[i]*3], this_v[p[i]*3+1], this_v[p[i]*3+2]);
		}
		glEnd();

		glColor3f(0.0, 0.0, 0.0);

		glStencilFunc(GL_EQUAL, 0, 1);
		glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);

		/* draw filled polygon */

		if(count>=3) {
			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
			glBegin(GL_POLYGON); 
			do_normal(this_v[p[0]*3], this_v[p[0]*3+1], this_v[p[0]*3+2],
				this_v[p[1]*3], this_v[p[1]*3+1], this_v[p[1]*3+2],
				this_v[p[2]*3], this_v[p[2]*3+1], this_v[p[2]*3+2]);
			for (i = 0 ; i < count ; i++) {
				glVertex3f(this_v[p[i]*3], this_v[p[i]*3+1], this_v[p[i]*3+2]);
			}
			glEnd();
		}

		glColor3f(1.0, 1.0, 1.0);

		glStencilFunc(GL_ALWAYS, 0, 1);
		glStencilOp(GL_INVERT, GL_INVERT, GL_INVERT);

		/* draw outline polygon */

		if(count==1) { glBegin(GL_POINTS); }
		else if(count==2) {
			/* chunky lines :-) */
			glLineWidth(2); 
			glBegin(GL_LINES);
		}
		else {
			glLineWidth(2); 
			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
			glBegin(GL_POLYGON); 
			do_normal(this_v[p[0]*3], this_v[p[0]*3+1], this_v[p[0]*3+2],
				this_v[p[1]*3], this_v[p[1]*3+1], this_v[p[1]*3+2],
				this_v[p[2]*3], this_v[p[2]*3+1], this_v[p[2]*3+2]);
		}
		for (i = 0 ; i < count ; i++) {
			glVertex3f(this_v[p[i]*3], this_v[p[i]*3+1], this_v[p[i]*3+2]);
		}
		glEnd();

		cp->npoints++;
		p+=count;
	}

  glEndList();
}
Exemplo n.º 15
0
static void
pinit(ModeInfo * mi)
{
	morph3dstruct *mp = &morph3d[MI_SCREEN(mi)];

	glClearDepth(1.0);
	glClearColor(0.0, 0.0, 0.0, 1.0);
	glColor3f(1.0, 1.0, 1.0);

	glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
	glLightfv(GL_LIGHT0, GL_POSITION, position0);
	glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
	glLightfv(GL_LIGHT1, GL_POSITION, position1);
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
	glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glEnable(GL_LIGHT1);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_NORMALIZE);

	glShadeModel(GL_SMOOTH);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_shininess);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular);

	switch (mp->object) {
		case 2:
			mp->draw_object = draw_cube;
			mp->MaterialColor[0] = MaterialRed;
			mp->MaterialColor[1] = MaterialGreen;
			mp->MaterialColor[2] = MaterialCyan;
			mp->MaterialColor[3] = MaterialMagenta;
			mp->MaterialColor[4] = MaterialYellow;
			mp->MaterialColor[5] = MaterialBlue;
			mp->edgedivisions = cubedivisions;
			mp->Magnitude = 2.0;
			break;
		case 3:
			mp->draw_object = draw_octa;
			mp->MaterialColor[0] = MaterialRed;
			mp->MaterialColor[1] = MaterialGreen;
			mp->MaterialColor[2] = MaterialBlue;
			mp->MaterialColor[3] = MaterialWhite;
			mp->MaterialColor[4] = MaterialCyan;
			mp->MaterialColor[5] = MaterialMagenta;
			mp->MaterialColor[6] = MaterialGray;
			mp->MaterialColor[7] = MaterialYellow;
			mp->edgedivisions = octadivisions;
			mp->Magnitude = 2.5;
			break;
		case 4:
			mp->draw_object = draw_dodeca;
			mp->MaterialColor[0] = MaterialRed;
			mp->MaterialColor[1] = MaterialGreen;
			mp->MaterialColor[2] = MaterialCyan;
			mp->MaterialColor[3] = MaterialBlue;
			mp->MaterialColor[4] = MaterialMagenta;
			mp->MaterialColor[5] = MaterialYellow;
			mp->MaterialColor[6] = MaterialGreen;
			mp->MaterialColor[7] = MaterialCyan;
			mp->MaterialColor[8] = MaterialRed;
			mp->MaterialColor[9] = MaterialMagenta;
			mp->MaterialColor[10] = MaterialBlue;
			mp->MaterialColor[11] = MaterialYellow;
			mp->edgedivisions = dodecadivisions;
			mp->Magnitude = 2.0;
			break;
		case 5:
			mp->draw_object = draw_icosa;
			mp->MaterialColor[0] = MaterialRed;
			mp->MaterialColor[1] = MaterialGreen;
			mp->MaterialColor[2] = MaterialBlue;
			mp->MaterialColor[3] = MaterialCyan;
			mp->MaterialColor[4] = MaterialYellow;
			mp->MaterialColor[5] = MaterialMagenta;
			mp->MaterialColor[6] = MaterialRed;
			mp->MaterialColor[7] = MaterialGreen;
			mp->MaterialColor[8] = MaterialBlue;
			mp->MaterialColor[9] = MaterialWhite;
			mp->MaterialColor[10] = MaterialCyan;
			mp->MaterialColor[11] = MaterialYellow;
			mp->MaterialColor[12] = MaterialMagenta;
			mp->MaterialColor[13] = MaterialRed;
			mp->MaterialColor[14] = MaterialGreen;
			mp->MaterialColor[15] = MaterialBlue;
			mp->MaterialColor[16] = MaterialCyan;
			mp->MaterialColor[17] = MaterialYellow;
			mp->MaterialColor[18] = MaterialMagenta;
			mp->MaterialColor[19] = MaterialGray;
			mp->edgedivisions = icodivisions;
			mp->Magnitude = 2.5;
			break;
		default:
			mp->draw_object = draw_tetra;
			mp->MaterialColor[0] = MaterialRed;
			mp->MaterialColor[1] = MaterialGreen;
			mp->MaterialColor[2] = MaterialBlue;
			mp->MaterialColor[3] = MaterialWhite;
			mp->edgedivisions = tetradivisions;
			mp->Magnitude = 2.5;
			break;
	}
	if (MI_IS_MONO(mi)) {
		int         loop;

		for (loop = 0; loop < 20; loop++)
			mp->MaterialColor[loop] = MaterialGray;
	}
}
Exemplo n.º 16
0
ENTRYPOINT void init_berlinuhr (ModeInfo *mi)
{
    float tempradius;
/*    int loop;*/
    berlinuhr_configuration *lp;
  GLint buf, samples;
    GLfloat fogColor[4] = {0,0,0,1};
/*  GLfloat light_color[] = {1.0, 1.0, 1.0, 1.0};*/
  GLfloat light_position[] = {0.0, 1.0, 1.0, 0.0};
  GLfloat lightmodel_amb[] = {0.7, 0.7, 0.7, 1.0};


    if (!lps) {
      lps = (berlinuhr_configuration *)
        calloc (MI_NUM_SCREENS(mi), sizeof (berlinuhr_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->sizefactor = (size >= 0 && size <= 10) ? 2.0 - (size * 0.1): 1.0;

/*    lp-> radius = ((random() % 10) + 25) * lp->sizefactor;*/
    tempradius = (random() % 10) + 25;
    lp->radius = tempradius * lp->sizefactor;
    lp->radiusincrement = (random() % 2) ? 0.1 : -0.1;
    lp->inclination = ((random() % 120) + 30) * M_PI/180;
    lp->inclinationincrement = (random() % 2) ? 0.005 : -0.005;
    lp->azimuth = ((float)(random() % 60) - 30) * M_PI/180;
    lp->azimuthincrement =  (random() % 2) ? 0.002 : -0.002;

    /* kick on the fog machine */
    lp-> fogdepth = 50.;
    if (do_fog) {
      glEnable(GL_FOG);
      glFogi(GL_FOG_MODE, GL_LINEAR);
      glFogf(GL_FOG_DENSITY, 0.02);
      glHint(GL_FOG_HINT, GL_NICEST);
      glFogf(GL_FOG_START, lp->fogdepth * 0.3 * lp->sizefactor);
     glFogf(GL_FOG_END, lp->fogdepth * lp->sizefactor);
      glFogfv(GL_FOG_COLOR, fogColor);
      glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    }

    glShadeModel(GL_SMOOTH);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE); 
     glCullFace(GL_BACK);  
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClearDepth(1.0f);
/* this still isn't enough factor to eliminate the artifacts,
   but more just makes the aliasing and rippling worse */
    glPolygonOffset(-2., -1.);

   glGetIntegerv(GL_SAMPLE_BUFFERS, &buf);
   glGetIntegerv(GL_SAMPLES, &samples);
/*   printf("Testing for multisampling: %d, %d\n", buf, samples);*/
   if ((1 == buf) && (samples > 1))
     {
/*       printf("Multisampling on!\n");*/
       glEnable(GL_MULTISAMPLE);
     }

   lp->housingindex = makebclockhousing();
   lp->lamplistindex = makelampdlists(MI_IS_MONO(mi));
   glListBase(lp->lamplistindex);

 glLightfv(GL_LIGHT0, GL_POSITION, light_position);
  glLightModelfv (GL_LIGHT_MODEL_AMBIENT, lightmodel_amb);
   glEnable (GL_LIGHTING);
   glEnable (GL_LIGHT0);

    handleGLerrors("init");
    reshape_berlinuhr(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
    glFlush();
}
Exemplo n.º 17
0
ENTRYPOINT void init_soma (ModeInfo *mi)
{
    int loop;
    int colorincrement;
    GLfloat fogColor[4] = {0., 0., 0., 1.};
     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] = {0.4, 0.4, 0.4, 1.0};
    GLfloat shininess[] = {75.};
    GLfloat specular[] = {1., 1., 1., 1.};
    soma_configuration *lp;

    if (!lps) {
      lps = (soma_configuration *)
        calloc (MI_NUM_SCREENS(mi), sizeof (soma_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->currentfigure = malloc (sizeof (figure));
    lp->basefigure = malloc (sizeof (figure));

    lp->fduration = ((duration > 0 && duration <= 5000) ? duration : 500);
    lp->cduration = ((colorchangerate > 0 && colorchangerate <= 1000) ? colorchangerate: 10);
    lp->tduration = ((changerate > 0 && changerate <= 500) ? changerate : 100);
    lp->viewangle = 0.;
     lp->vanglestep = ((spinrate >= -100 && spinrate <= 100) ? (spinrate / 500.0) : 0.02);
     if (do_clockwise) lp->vanglestep *= -1;
   lp->dstate = exploding;

     makedlists(lp->piecedlists);


     if(!MI_IS_MONO(mi))
      {
	lp->numcolors = ((ncolors > 0 && ncolors < 2049) ? 
                          ncolors : 256);
    lp->colors = calloc ( lp->numcolors,  sizeof (*lp->colors));
    make_smooth_colormap (MI_DISPLAY(mi),MI_VISUAL(mi), MI_COLORMAP(mi),
                            lp->colors, &lp->numcolors, False, 0, True);
     }
     if( (MI_IS_MONO(mi)) || (lp->numcolors < 1))
      {
/* 	GLfloat white[] = {1., 1., 1., 1.}; */
	lp->numcolors = 1;
        lp->colors = calloc (1, sizeof (*lp->colors));
        lp->colors[0].pixel = MI_WHITE_PIXEL(mi);
        XQueryColor( MI_DISPLAY(mi), MI_COLORMAP(mi), &lp->colors[0]);
/*          glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, white); */
     } 
    colorincrement = (int)lp->numcolors / 7;
    for (loop = 1; loop < 8; loop++)
      {
	if (do_multicolors && lp->numcolors > 6)
	  {
	    lp->colorindices[loop] = colorincrement * loop;
          }
	else
          {
	    lp->colorindices[loop] = 0;
          }
      }
    lp->ftimer = lp->ctimer = 1;
    if (lp->numcolors < 2) reset_color(lp, lp->currentfigure);

      glEnable(GL_FOG);
      glFogi(GL_FOG_MODE, GL_LINEAR);
      glFogf(GL_FOG_DENSITY, 0.50);
      glHint(GL_FOG_HINT, GL_NICEST);
      glFogf(GL_FOG_START, 15);
      glFogf(GL_FOG_END, 25);
      glFogfv(GL_FOG_COLOR, fogColor);
      glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

    glShadeModel(GL_SMOOTH);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE); 
    glCullFace(GL_BACK);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClearDepth(1.0f);


      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);
   glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
   glMaterialfv(GL_FRONT, GL_SHININESS, shininess);

    handleGLerrors("init");
    reshape_soma(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
    glFlush();
}