Example #1
0
void ship::draw()
{
  double px = position.getX();
  double py = position.getY();
  double pz = position.getZ();

  speed.soft_scale();
  glPushMatrix();

  GLfloat  mycolor[]={0.0,0.5,1.0};
  GLfloat shiny[]={200.0};
  glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,shiny);
  glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,mycolor);
  glLineWidth(1);
  glTranslatef(px,py,pz);
  glRotatef(-90, 1.0, 0.0, 0.0); 
  glRotatef(-57.29578*angle, 0.0, 1.0, 0.0); 
  glRotatef(90, 0.0, 1.0, 0.0); 
  glRotatef(spini, 0.0, 0.0, 1.0); 
  glutWireCone(0.02,0.05,4,1);
  glLineWidth(1);
  //  glColor3ub(255,255,0);
  glutWireCone(0.03,0.02,4,1);

  glPopMatrix(); 
}
Example #2
0
void display(void)
{  
	glClear(GL_COLOR_BUFFER_BIT);
	glColor3f(153/255.0, 76/255.0, 0.0f);

	glPushMatrix();

	glutWireCube(0.75);

	glPopMatrix();
	
	glPushMatrix();
	glTranslatef(0.0,0.75, 0.0);
	glutWireCube(0.75);
	glPopMatrix();

	glPushMatrix();
	glTranslatef(0.0, 1.25, 0.0);
	glRotatef(-65.0, 1.0, 0.0, 0.0);
	glColor3f(0.0f, 1.0f, 0.0f);
	glutWireCone(1.0, 1.2, 20, 20);
	glPopMatrix();

	glPushMatrix();

	glColor3f(1.0f, 0.0f, 0.0f);
	glTranslatef(0.90, 0.0, 0.0);
	glRotatef(-180, 1.0, 0.0, 0.0);
	glutWireTeapot(0.25);

	glPopMatrix();

	glutSwapBuffers();
}
Example #3
0
void Game::DrawMap()
{
	glPushMatrix();
	glTranslatef(-(MAP_WIDTH * FIGURE_SIZE) / 2.0, -(MAP_HEIGHT * FIGURE_SIZE) / 2.0, 0);
	for(int i = 0; i < MAP_HEIGHT; i++) {
		for(int j = 0; j < MAP_WIDTH; j++) {
			glPushMatrix();
			setMatrixProperties(j, i);	// set the position and color
			switch(map.getTile(j, i)) {
			case Tile::SPHERE:
				glutWireSphere(FIGURE_SIZE/2.0, 10, 10);
				break;
			case Tile::CONE:
				glPushMatrix();
				glTranslatef(0, 0, -FIGURE_SIZE/2.0);
				glutWireCone(FIGURE_SIZE/2.0, FIGURE_SIZE, 10, 10);
				glPopMatrix();
				break;
			case Tile::CUBE:
				glutWireCube(FIGURE_SIZE);
				break;
			case Tile::EMPTY:
				glPushMatrix();
				glTranslatef(0, 0, -FIGURE_SIZE/8.0);
				glutSolidCube(FIGURE_SIZE/2.0);
				glPopMatrix();
				break;
			}
			glPopMatrix();
		}
	}
	glPopMatrix();
}
Example #4
0
static void display() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );  // Clear Color and Depth
    glPushMatrix();              		// Begin drawing image
        glRotatef( x,0.0,1.0,0.0);  	// Rotate
        glColor3f(1.0,0.0, 0.0);		// Set Drawing Color to Red
        glutWireTorus(0.4,0.7,30,20);		// Draw glutWireTorus(innerRadius, outerRadius, nsides, rings);
        glPushMatrix();			  // Draw orbiting sphere
            glTranslatef(0.5,0.0,-1.0);	  // Move away from origin
            glColor3f(1.0,1.0,0.0);             // Set color to yellow
            glutWireSphere(0.3,20,16);	  // Draw Sphere
            glPushMatrix();			     // Draw glutWireTeapot orbiting around the sphere
                glRotatef( x, 0.0, 1.0, 0.0);	     // Rotate
                glTranslatef(0.3,0.0,-0.5);	     // Move reference point
                glColor3f(0.0,0.0,1.0);		     // Color Blue
                glutWireTeapot(0.2);	     // Draw teapot
            glPopMatrix();			  // Return to former reference
        glPopMatrix();			// Return to first refernce
        glPushMatrix();			  // Draw orbiting cone
            glTranslatef(-0.5,0.0,1.0);	  // Move reference poit
            glColor3f(0.0,1.0,0.0);		  // Set color to green
            glutWireCone(0.3,0.5,20,16);	  // Draw cone
        glPopMatrix();			// Return to first reference
    glPopMatrix();		      // Return to base reference
    glFlush();			      // Flush drawing routines
    glutSwapBuffers();		      // Swap buffers
}
Example #5
0
//*********************************************************    
// Função que desenha
// Executada sempre que ocorre qualquer evento de janela
void Desenhacone(void)
{
	//glClear(GL_COLOR_BUFFER_BIT);
   	glColor3f(0.0f, 0.0f, 1.0f);          // determina a cor corrente de desenho
	glutWireCone(0.1,0.1 , 20, 10);     // Desenha cone modelado em wireframe
  // 	glutSwapBuffers();                    // Executa os comandos OpenGL
}
Example #6
0
static void display(void)
{
    const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
    const double a = t*90.0;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor3d(0,1,0);

    glPushMatrix();
        glTranslated(-2.75,1.75,-6);
        glRotated(60,1,0,0);
        glRotated(a,0,0,1);
        glutWireSphere(1,slices,stacks);
    glPopMatrix();

    glPushMatrix();
        glTranslated(0,-1.2,-6);
        glRotated(60,20,0,0);
        glRotated(a,0,0,1);
        glutWireCone(1,1,slices,stacks);
    glPopMatrix();

    glPushMatrix();
        glTranslated(-0,1.75,-6);
        glRotated(80,75,180,90);
        glRotated(a,0,0,1);
        glutWireTorus(0.2,0.8,slices,stacks);
    glPopMatrix();

    glutSwapBuffers();
}
Example #7
0
//
// To display onto window using OpenGL commands
//
void display()
{
	
	glClearColor( 0, 0 , 0 , 0 );
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

	glLoadIdentity();
	cam1.LookAt() ;
	
	glColor3f(1,1,0);
	glPushMatrix();
	glTranslatef( (current-1) * 5, 2, -10) ;
	glScalef(0.2, 0.2, 0.2) ;
	WireArrow() ;
	glPopMatrix();

	glColor3f( colors[0].r, colors[0].g, colors[0].b );
	glPushMatrix();
	glTranslatef(-5, 0, -10) ;
	glScalef( size[0], size[0], size[0] ); 
	glutWireTeapot(1) ;
	glPopMatrix();


	glColor3f( colors[1].r, colors[1].g, colors[1].b );
	glPushMatrix();
	glTranslatef(0, 0, -10) ;
	glRotatef( 45, 1,1,1 ) ;
	glScalef( size[1], size[1], size[1] ); 
	glutWireCube(1.5) ;
	glPopMatrix();

	glColor3f( colors[2].r, colors[2].g, colors[2].b );
	glPushMatrix();
	glTranslatef(5, 0, -10) ;
	glScalef( size[2], size[2], size[2] ); 
	glutWireCone(1, 1, 10, 10) ;
	glPopMatrix();

	glColor3f(1,1,1);
	// Text Part
	glPushMatrix();
	glTranslatef(-6, -2, -10) ;
	vprint2(0,0, 0.005, "Teapot");
	glPopMatrix();

	glPushMatrix();
	glTranslatef(-1, -2, -10) ;
	vprint2(0,0, 0.005, "Cube");
	glPopMatrix();

	glPushMatrix();
	glTranslatef(4.5, -2, -10) ;
	vprint2(0,0, 0.005, "Cone");
	glPopMatrix();

	glutSwapBuffers();

}
Example #8
0
void DrawWheelDents()
{
	//Dent1
	glPushMatrix();
	
	glColor3f(0,1,1);
	glTranslated(485,390,320);
	glRotated(-90,0,1,0);
	glScaled(3,3,25);
	glutWireCone(1,2,20,20);
	
	glPopMatrix();

	//Dent2
	glPushMatrix();
	
	glColor3f(0,1,1);
	glTranslated(485,390,80);
	glRotated(-90,0,1,0);
	glScaled(3,3,25);
	glutWireCone(1,2,20,20);
	
	glPopMatrix();

	//Dent3
	glPushMatrix();
	
	glColor3f(0,1,1);
	glTranslated(795,390,320);
	glRotated(90,0,1,0);
	glScaled(3,3,25);
	glutWireCone(1,2,20,20);
	
	glPopMatrix();

	//Dent4
	glPushMatrix();
	
	glColor3f(0,1,1);
	glTranslated(795,390,80);
	glRotated(90,0,1,0);
	glScaled(3,3,25);
	glutWireCone(1,2,20,20);
	
	glPopMatrix();
}
void zeichneSzene(void)
{
	//Löschen des Framebuffers
	glClear(GL_COLOR_BUFFER_BIT);
	
	// Malfarbe ist Blau
	glColor3f(0.0, 0.0, 1.0);
	
	
	/*
		Sphere
	------------------------------------------------------ */
		// Festlegung, in welchen Festerabschnitt gemalt wird
		// params are (x, y, width, height). the origin is the lower left corner
		glViewport(0, 0, 200, 200);
	
		// Zeichnen des Glut-Grundkörpers Kugel
		// params are (radius, slices, stacks)
		glutWireSphere(70.0, 30, 30);
	
		// Rotation um die x- und y-Achse um jeweils 45 Grad
		// params are (angle, x, y, z). x/y/z defines a vector
		glRotatef(-5.0, 1.0, 1.0, 0.0);
	
	/*
		Cube
	 ------------------------------------------------------ */
		// Festlegung des neuen Festerabschnitts
		glViewport(200, 200, 200, 200);
	
		// Zeichnen des Glut-Grundkörpers Würfel
		// param is (size)
		glutWireCube(60.0);
	
	/*
		Cone
	 ------------------------------------------------------ */
		// Festlegung des neuen Festerabschnitts
		glViewport(0, 200, 200, 200);
	
		// Zeichnen des Glut-Grundkörpers Kegel
		// params are (base, height, slices, stacks)
		glutWireCone(30.0, 70.0, 30,30);
	
	/*
		Torus
	 ------------------------------------------------------ */
		// Festlegung des neuen Festerabschnitts
		glViewport(200, 0, 200, 200);
	
		// Zeichnen des Glut-Grundkörpers Ring
		// params are (innerRadius, outerRadius, sides, rings)
		glutWireTorus(30.0, 50.0, 30, 30);
	
	
	// Ausgabe auf dem Bildschirm
	glFlush();
}
void transform_render() {

	glClear(GL_COLOR_BUFFER_BIT); // clear the screen
	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();

	camera->Update();

	glPushMatrix();

		//transform entire scene
		doTransform( pTransInfo[0] );

		glutWireCube(1.0);

		glPushMatrix();	
			doTransform( pTransInfo[1] );
			glutWireSphere(0.50, 10, 8);
		glPopMatrix();
		
		glPushMatrix();	
			doTransform( pTransInfo[2] );
			glutWireCone(0.2, 0.5, 10, 8);
		glPopMatrix();
		
		glPushMatrix();
			doTransform( pTransInfo[3] );
			glutSolidTeapot(0.2);
		glPopMatrix();

		glPushMatrix();
			doTransform( pTransInfo[4] );
			glutWireTorus(0.1, 0.3, 10,10);
		glPopMatrix();

		glPushMatrix();
			doTransform( pTransInfo[5] );
			glutWireDodecahedron();
		glPopMatrix();

		glPushMatrix();
			doTransform( pTransInfo[6] );
			glutWireCube(0.25);
		glPopMatrix();

		glPushMatrix();
			doTransform( pTransInfo[7] );
			gluCylinder(qobj, 0.2, 0.2, 0.4, 8,8);
		glPopMatrix();

	glPopMatrix();

	// refresh image
	glutSwapBuffers();

	glutPostRedisplay();
	
}
Example #11
0
void drawWiredRoof()
{
    glPushMatrix();                   // roof
    glColor3f(1,0,0);
    glRotatef(45,0,1,0);
    glRotatef(-90,1,0,0);
    glutWireCone(1.65,1.5,4,8);
    glPopMatrix();
}
Example #12
0
void desenha_img(){
     glColor3f(1,0,0);
    glLineWidth(2);
	//glTranslatef(0,30,0);
	//glRotatef(-90,1,0,0);
	glutWireCone(30, 30, 10, 8);
	//glTranslatef(0,-50,0);
	glutWireCube(30);
}
Example #13
0
/*
 * Uses glut to draw a cone.  Must render in either solid and wire
 * frame modes, based on the value of the variable disp_style.
 */
void draw_cone_glut(void) {
	/* ADD YOUR CODE HERE */
	glColor3f(0.0f, 0.0f, 1.0f);
	if (disp_style == DS_SOLID) {
		glutSolidCone(1.0f,1.0f,20,20);
	} else if (disp_style == DS_WIRE) {
		glutWireCone(1.0f,1.0f,20,20);
	}

}
Example #14
0
/** WireCone (base, height, slices, stacks) -> none
 */
static int glut_wire_cone(lua_State *L) {
  /* test argument type */
  if (lua_isnumber(L, 1) && lua_isnumber(L, 2) &&
     lua_isnumber(L, 3) && lua_isnumber(L, 4)) {

     /* call GLUT functions */
     glutWireCone((GLdouble)lua_tonumber(L, 1), (GLdouble)lua_tonumber(L, 2),
                   (GLint)lua_tonumber(L, 3), (GLint)lua_tonumber(L, 4));
  } else {
    luaL_error(L, "incorrect argument to function 'glut.WireCone'");
  }

  return 0;
}
Example #15
0
static void hugsprim_glutWireCone_13(HugsStackPtr hugs_root)
{
    HsDouble arg1;
    HsDouble arg2;
    HsInt32 arg3;
    HsInt32 arg4;
    arg1 = hugs->getDouble();
    arg2 = hugs->getDouble();
    arg3 = hugs->getInt32();
    arg4 = hugs->getInt32();
    glutWireCone(arg1, arg2, arg3, arg4);
    
    hugs->returnIO(hugs_root,0);
}
Example #16
0
void View::DrawCoords()
{
    GLfloat length = 2.0;
    glLoadIdentity();
    glTranslated(0.0, 0.0, zoom);
    glLineWidth(3.0);
    glBegin(GL_LINES);
    {
        glColor3f(1.0, 0.0, 0.0);
        glVertex3f(0.0, 0.0, 0.0);
        glVertex3f(length, 0.0, 0.0);

        glColor3f(0.0, 1.0, 0.0);
        glVertex3f(0.0, 0.0, 0.0);
        glVertex3f(0.0, length, 0.0);

        glColor3f(0.0, 0.0, 1.0);
        glVertex3f(0.0, 0.0, 0.0);
        glVertex3f(0.0, 0.0, length);
    }
    glEnd();

    glPushMatrix();
    glTranslatef(length, 0.0, 0.0);
    glRotatef(90.0, 0.0, 1.0, 0.0);
    glColor3f(1.0, 0.0, 0.0);
    glutWireCone(0.027,0.09,10,10);
    glPopMatrix();

    glPushMatrix();
    glTranslatef(0.0, length, 0.0);
    glRotatef(-90.0, 1.0, 0.0, 0.0);
    glColor3f(0.0, 1.0, 0.0);
    glutWireCone(0.027,0.09,10,10);
    glPopMatrix();
}
Example #17
0
//------------------------------------------------------------------------------
void npGlutPrimitive (int primitive)
{
	switch (primitive)
	{
	case kNPgeoCubeWire :
		glScalef (0.6f, 0.6f, 0.6f); 
		glutWireCube(2.0f);
		glScalef (1.666667f, 1.666667f, 1.666667f);
		break;
	case kNPgeoCube :
		glScalef (0.6f, 0.6f, 0.6f);
		glutSolidCube(2.0f);
		glScalef (1.666667f, 1.666667f, 1.666667f);
		break;
	case kNPgeoSphereWire : glutWireSphere( 1.0f, 24, 12); break;//15, 15 ); break;
	case kNPgeoSphere : glutSolidSphere( 1.0f, 24, 12 ); break;

	case kNPgeoConeWire : glutWireCone( 1.0f, 2.0f, 24, 1 ); break;
	case kNPgeoCone : glutSolidCone( 1.0f, 2.0f, 24, 1 ); break;

	case kNPgeoTorusWire : glutWireTorus(kNPtorusRadius * 0.1f, kNPtorusRadius, 7, 16); break;
	case kNPgeoTorus : glutSolidTorus(kNPtorusRadius * 0.1f, kNPtorusRadius, 7, 16); break;

	case kNPgeoDodecahedronWire :
		glScalef (0.6f, 0.6f, 0.6f);
		glutWireDodecahedron();
		glScalef (1.666667f, 1.666667f, 1.666667f);
		break;
	case kNPgeoDodecahedron :
		glScalef (0.6f, 0.6f, 0.6f);
		glutSolidDodecahedron();
		glScalef (1.666667f, 1.666667f, 1.666667f);
		break;
	case kNPgeoOctahedronWire : glutWireOctahedron(); break;
	case kNPgeoOctahedron : glutSolidOctahedron(); break;
	case kNPgeoTetrahedronWire : glutWireTetrahedron(); break;
	case kNPgeoTetrahedron : glutSolidTetrahedron(); break;
	case kNPgeoIcosahedronWire : glutWireIcosahedron(); break;
	case kNPgeoIcosahedron : glutSolidIcosahedron(); break;

//	case kNPglutWireTeapot : glutWireTeapot( 2.0f ); break;
//	case kNPglutSolidTeapot : glutSolidTeapot( 2.0f ); break;

	default : glutWireTetrahedron(); break;
	}
}
Example #18
0
void ada(){
     glPushMatrix();
        glTranslatef(0,0,0.5);
         glRotatef(qwe,0,0,1);
         glColor3f(2.0,1.0,1.1);
        glutSolidCone(5,3,50,4);                
   qwe+=0.5;
    glPopMatrix();
    glPushMatrix();
        glTranslatef(0,0,-0.5);
         glRotatef(180,0,0,0);
         glRotatef(qwe,0,0,1);
         glColor3f(0.0,1.0,1.0);
        glutWireCone(5,3,50,4);                
  qwe+=0.5;
    glPopMatrix();
    }
Example #19
0
void display1(void)
{
	glClear(GL_COLOR_BUFFER_BIT);
	glColor3d(0.0, 1.0, 1.0);
	glBegin(GL_QUADS);
	glVertex3d(-0.9, -0.9, -5.0);
	glVertex3d(0.9, -0.9, -5.0);
	glVertex3d(0.9, 0.9, -5.0);
	glVertex3d(-0.9, 0.9, -5.0);
	glEnd();
	glColor3d(0.5, 0.5, 0.0);
	glPushMatrix();
		glRotatef(-90.0, 0.0, 0.0, 1.0);
		glTranslatef(1.0, 3.0, -5.0);
		glutWireCone(0.4, 1.0, 10, 10);
	glPopMatrix();
	glutSwapBuffers();
}
Example #20
0
void Player::Draw(){
	glPushMatrix();
	{
		glRotatef(m_yaw, 0, 1, 0);
		glTranslatef(m_pos.x, m_pos.y, m_pos.z);
		glColor4f(1, 1, 1, isNot_damaged);

		/* モデルに変更予定 */
		glutWireCone(0.5, 0.5, 100, 20);
		glBegin(GL_LINE);
		{
			glVertex3f(0, 1, 0);
			glVertex3f(0, 1, -1);
		}
		glEnd();
	}
	glPopMatrix();
}
Example #21
0
	void Light::draw() {
	
		glPushMatrix();
			glCallList(_lightDL);
		glPopMatrix();

		if (isDebug()) {

			glDisable(GL_LIGHTING);

			glPushMatrix();
				glTranslated(_position[0],_position[1],_position[2]);
				glColor3f(0.9f,0.9f,0.9f);
				glutWireCone(2.0f,2.0f,10,10);
			glPopMatrix();

			glEnable(GL_LIGHTING);
		}
	}
Example #22
0
void tree(int x, int y, int z) {
	float ratio = 0.2;
	int i;
	float angle;
	/* TRONC Arbre */
	glColor3f(0.95, 0.7, 0.05);
	glPushMatrix();
		glTranslatef(x, y, 0);
		glBegin(GL_LINE_LOOP);
		glVertex3f(-(z*ratio), 0, 0);
		glVertex3f((z*ratio), 0, 0);
		glVertex3f((z*ratio), 0, z);
		glVertex3f(-(z*ratio), 0, z);
		glEnd();

		/* Ligne milieu TRONC */
		glBegin(GL_LINE_STRIP);
		glVertex3f(0, 0, 0);
		glVertex3f(0, 0, z);
		glEnd();

		/* Génération Arbre TRONC */
		glBegin(GL_LINE_LOOP);
		glVertex3f(0, -(z*ratio), 0);
		glVertex3f(0, (z*ratio), 0);
		glVertex3f(0, (z*ratio), z);
		glVertex3f(0, -(z*ratio), z); 		
		glEnd();

		/* Sapin les murs */
		glColor3f(0, 1, 0);
		glTranslatef(0, 0, z); 
		/*glutWireCone(Largeur Base, Hauteur Cone, Nombre de Facette, Nombre de Facette) */
		glutWireCone(z, 3 * z, z, z);

		/*glutSolidCone(10., 25., 10, 10);
		glutWireSphere(10., 10, 10);*/
	glPopMatrix();
}
Example #23
0
void menu (int valor)
{
  switch (valor)
    {
    case 1:
      {
	glutWireTorus(0.5, 1.0, 20, 20);
	break;
      }
    case 2:
    {
      glutWireTeapot(1);
      break;
    }
    case 3:
      {
	glutWireIcosahedron();
	break;
      }
    case 4:
    {
      glutWireCone(1.0, 1.0, 10, 10);
      break;
    }
    case 5:
    {
      glutWireOctahedron();
      break;
    }
    case 6:
      {
	glutWireTetrahedron();
	break;
      }
    case 7:
      exit(0);
    }
}
Example #24
0
void fire::draw()
{

  double px = position.getX();
  double py = position.getY();
  double pz = position.getZ();

  glPushMatrix();
  GLfloat  mycolor[]={1.0,0.5,1.0};
  GLfloat shiny[]={256.0};
  GLfloat diff[] = {0.9,0.9,0.9,0};
  glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diff);
  glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,shiny);
  glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,mycolor);
  glLineWidth(1);
  glTranslatef(px,py,pz);
  glRotatef(-90, 1.0, 0.0, 0.0); 
  glRotatef(-57.29578*angle, 0.0, 1.0, 0.0); 
  glRotatef(90, 0.0, 1.0, 0.0); 
  glRotatef(spini, 0.0, 0.0, 1.0);
  glutWireCone(0.01,0.03,2,1);
  glPopMatrix(); 
}
// Funktion zum Zeichnen der Grundkörper
void zeichneSzene(void)
{
	glClear(GL_COLOR_BUFFER_BIT );
	
	// Sphere
	glViewport(0, 0, W_H_C, H_H_C);
	glutWireSphere(70.0, 30, 30);
	glRotatef(-45.0, 1.0, 1.0, 0.0);

	// Cube
	glViewport(W_H_C, H_H_C, W_H_C, H_H_C);
	glutWireCube(60.0);

	// Cone
	glViewport(0, H_H_C, W_H_C, H_H_C);
	glutWireCone(30.0, 70.0, 30, 30);

	// Torus
	glViewport(W_H_C, 0, W_H_C, H_H_C);
	glutWireTorus(30.0, 50.0, 30, 30); 

	glFlush();
}
Example #26
0
void display_2(void)
{
char *p;
 
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  //Clear the screen
 
glMatrixMode (GL_PROJECTION);  // Tell opengl that we are doing project matrix work
glLoadIdentity();  // Clear the matrix
glOrtho(-8.0, 8.0, -8.0, 8.0, 0.0, 30.0);  // Setup an Ortho view
glMatrixMode(GL_MODELVIEW);  // Tell opengl that we are doing model matrix work. (drawing)
glLoadIdentity(); // Clear the model matrix
 
 
glColor3f(1.0, 1.0, 1.0);
if (shape == 0) Sprint(-3, -7 ,"Wire Cube");
if (shape == 1) Sprint(-3, -7 ,"Wire Cone");
if (shape == 2) Sprint(-3, -7 ,"Wire Sphere");
if (shape == 3) Sprint(-3, -7 ,"Wire Torus");
if (shape == 4) Sprint(-3, -7 ,"Wire Dodecahedron");
if (shape == 5) Sprint(-3, -7 ,"Wire Octahedron");
if (shape == 6) Sprint(-3, -7 ,"Wire Tetrahedron");
if (shape == 7) Sprint(-3, -7 ,"Wire Icosahedron");
if (shape == 8) Sprint(-3, -7 ,"Wire Teapot");
 
// Setup view, and print view state on screen
if (view_state == 1)
	{
    glColor3f( 1.0, 1.0, 1.0);
    Sprint(-2, 4, "Perspective view");
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60, 1, 1, 30);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    }else
	{
	glColor3f( 1.0, 1.0, 1.0);
    Sprint(-2, 4, "Ortho view");
    }
 
glColor3f( 0.0, 0.0, 1.0);  // Cube color
 
// Lighting on/off
if (light_state == 1)
	{
	glDisable(GL_LIGHTING);  // Turn off lighting
    glDisable(GL_COLOR_MATERIAL); // Turn off material, which needs lighting to work
    }else
	{
    glEnable(GL_LIGHTING); // Turn on lighting
    glEnable(GL_COLOR_MATERIAL); // Turn on material settings
    glColorMaterial(GL_FRONT, GL_AMBIENT);
    glColor4f(0.65, 0.65, 0.65, 0.4);
    glColorMaterial(GL_FRONT, GL_EMISSION);
    glColor4f(0.10, 0.10, 0.10, 0.0);
    glColorMaterial(GL_FRONT, GL_SPECULAR);
    glColor4f(0.5, 0.5, 0.5, 0.4);
    glColorMaterial(GL_FRONT, GL_DIFFUSE);
    glColor4f(0.85, 0.85, 0.85, 0.4);
    }
 
gluLookAt( 0, 0, 20, 0, 0, 0, 0, 1, 0);
 
//glRotatef( 45, 1.0, 1.0, 0.0); // rotate cube
glRotatef( spin++, 1.0, 1.0, 1.0); // spin cube
 
if (shape == 0) glutWireCube(10); // Draw a cube
if (shape == 1) glutWireCone(5,10, 16,16);  // Draw a Cone
if (shape == 2) glutWireSphere(5, 16,16 );  // Draw a Sphere
if (shape == 3) glutWireTorus( 2.5, 5, 16, 16);
if (shape == 4)
   {
	glScalef( 3.5, 3.5, 3.5);
	glutSolidDodecahedron();
   }
 
if (shape == 5)
   {
	glScalef( 5.0, 5.0, 5.0);
	glutWireOctahedron();
   }
if (shape == 6)
   {
	glScalef( 5.0, 5.0, 5.0);
	glutWireTetrahedron();
   }
 
if (shape == 7)
   {
	glScalef( 5.0, 5.0, 5.0);
	glutWireIcosahedron();
   }
if (shape == 8) glutWireTeapot( 5 );
 
glutSwapBuffers();
}
Example #27
0
void display(void) {
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(60.0, ratio, 5, 450);

	Vtx = Vx + step*cos(Vtheta);
	Vtz = Vz + step*sin(Vtheta);
	gluLookAt(Vx,Vy,Vz,  Vtx,Vy,Vtz, 0.0,1.0,0.0);
	
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glPushMatrix();

	//room
	glCallList(Lroom);

	//castillo
	glPopMatrix();
	glPushMatrix();
	glTranslatef(0.0, 25.0, -100.0);
	glRotatef(alpha, 1.0f, 0.0f, 0.0f);
	glRotatef(beta, 0.0f, 1.0f, 0.0f);
	glRotatef(gamma, 0.0f, 0.0f, 1.0f);
	glCallList(Lcastle);

	//jet
	glPopMatrix();
	glPushMatrix();
	glTranslatef(0.0, 25.0, 100.0);
	glScalef(0.3, 0.3, 0.3);
	glRotatef(alpha, 1.0f, 0.0f, 0.0f);
	glRotatef(beta, 0.0f, 1.0f, 0.0f);
	glCallList(Ljet);

	//esfera
	glPopMatrix();
	glPushMatrix();
	glRotatef(esfBeta, 0.0,1.0,0.0);
	glTranslatef(170, 15.0, 0.0);
	glRotatef(90, 0.0,1.0,0.0);
	glRotatef(-2*gamma, 0.0,0.0,1.0);
	glColor3f(0.7,0.0,0.0);
	glutWireSphere(10.0, 10,10);

	//cono
	glPopMatrix();
	glPushMatrix();
	glRotatef(esfBeta-120, 0.0,1.0,0.0);
	glTranslatef(170, 15.0, 0.0);
	//glRotatef(90, 0.0,1.0,0.0);
	glRotatef(-2*gamma, 0.0,0.0,1.0);
	glColor3f(0.0,0.7,0.0);
	glutWireCone(10.0, 10.0, 10,10);

	//cubo
	glPopMatrix();
	glPushMatrix();
	glRotatef(esfBeta-240, 0.0,1.0,0.0);
	glTranslatef(170.0, 25.0, 0.0);
	glRotatef(45, -1.0,-1.0,1.0);
	glRotatef(-2*gamma, 1.0,1.0,1.0);
	glColor3f(0.0,0.0,1.0);
	glutSolidCube(20.0);

	glPopMatrix();
	glutSwapBuffers();
}
Example #28
0
/*
 * These one-liners draw particular objects, fetching appropriate
 * information from the above globals.  They are just thin wrappers
 * for the FreeGLUT objects.
 */
static void drawSolidTetrahedron(void)         { glutSolidTetrahedron ();                        }
static void drawWireTetrahedron(void)          { glutWireTetrahedron ();                         }
static void drawSolidCube(void)                { glutSolidCube(orad);                            }  /* orad doubles as size input */
static void drawWireCube(void)                 { glutWireCube(orad);                             }  /* orad doubles as size input */
static void drawSolidOctahedron(void)          { glutSolidOctahedron ();                         }
static void drawWireOctahedron(void)           { glutWireOctahedron ();                          }
static void drawSolidDodecahedron(void)        { glutSolidDodecahedron ();                       }
static void drawWireDodecahedron(void)         { glutWireDodecahedron ();                        }
static void drawSolidRhombicDodecahedron(void) { glutSolidRhombicDodecahedron ();                }
static void drawWireRhombicDodecahedron(void)  { glutWireRhombicDodecahedron ();                 }
static void drawSolidIcosahedron(void)         { glutSolidIcosahedron ();                        }
static void drawWireIcosahedron(void)          { glutWireIcosahedron ();                         }
static void drawSolidSierpinskiSponge(void)    { glutSolidSierpinskiSponge (depth, offset, orad);}  /* orad doubles as size input */
static void drawWireSierpinskiSponge(void)     { glutWireSierpinskiSponge (depth, offset, orad); }  /* orad doubles as size input */
static void drawSolidTorus(void)               { glutSolidTorus(irad,orad,slices,stacks);        }
static void drawWireTorus(void)                { glutWireTorus (irad,orad,slices,stacks);        }
static void drawSolidSphere(void)              { glutSolidSphere(orad,slices,stacks);            }  /* orad doubles as size input */
static void drawWireSphere(void)               { glutWireSphere(orad,slices,stacks);             }  /* orad doubles as size input */
static void drawSolidCone(void)                { glutSolidCone(orad,orad,slices,stacks);         }  /* orad doubles as size input */
static void drawWireCone(void)                 { glutWireCone(orad,orad,slices,stacks);          }  /* orad doubles as size input */
Example #29
0
void
displayFunc(void)
{
  static int shape = 1;

  fprintf(stderr, " %d", shape);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  switch (shape) {
  case 1:
    glutWireSphere(1.0, 20, 20);
    break;
  case 2:
    glutSolidSphere(1.0, 20, 20);
    break;
  case 3:
    glutWireCone(1.0, 1.0, 20, 20);
    break;
  case 4:
    glutSolidCone(1.0, 1.0, 20, 20);
    break;
  case 5:
    glutWireCube(1.0);
    break;
  case 6:
    glutSolidCube(1.0);
    break;
  case 7:
    glutWireTorus(0.5, 1.0, 15, 15);
    break;
  case 8:
    glutSolidTorus(0.5, 1.0, 15, 15);
    break;
  case 9:
    glutWireDodecahedron();
    break;
  case 10:
    glutSolidDodecahedron();
    break;
  case 11:
    glutWireTeapot(1.0);
    break;
  case 12:
    glutSolidTeapot(1.0);
    break;
  case 13:
    glutWireOctahedron();
    break;
  case 14:
    glutSolidOctahedron();
    break;
  case 15:
    glutWireTetrahedron();
    break;
  case 16:
    glutSolidTetrahedron();
    break;
  case 17:
    glutWireIcosahedron();
    break;
  case 18:
    glutSolidIcosahedron();
    break;
  default:
    printf("\nPASS: test16\n");
    exit(0);
  }
  glutSwapBuffers();
  shape += 1;
  sleep(1);
  glutPostRedisplay();
}
Example #30
0
void display()
{
	// Funcion que atiende al evento de display (render)
	
	// Obtenemos el tiempo actual
	time(&ltime);
	newtime = localtime(&ltime); // Conversion a tiempo local

	// Color de borrado Blanco
	glClearColor(1.0,1.0,1.0,1.0); 
	
	// Borra la pantalla y buffer de profundidad
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	// Inicializa matriz compuesta de la MV
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	gluLookAt(0,3,6, 0,0,0, 0,1,0); // subimos la cámara
	//gluLookAt(0,0,6.5, 0,0,0, 0,1,0); // Cámara normal

	/** Esfera exterior **/
	glLineWidth(1.0f);
	glColor3f(0.3,0.6,0.6);
	glutWireSphere(1.0,10,10);

	/** Puntos reloj **/;
	glPushMatrix();
	glColor3f(0.0,0.0,0.0);
	glCallList(puntos);
	glPopMatrix();

	/** Esfera horas reloj **/
	int rot = 0; // Inicialmente 0º
	for (int i = 0; i<12; i++){
		glPushMatrix();
		glColor3f(0,0.6,0.4); // Color Verde
		glRotatef(rot,0,0,1); // Rotacion sobre eje z
		glTranslatef(0,0.9,0);
		glutSolidSphere(0.05,10,10);
		glPopMatrix();
		rot += 30;
	}

	/** Estrellas rotatorias interiores **/
	glPushMatrix();
	glScalef(0.25,0.25,0.25); // Diametro 1/10
	glRotatef(beta,0,1,0); // Rotacion constante sobre eje y
	FPS(); // Muertra FPS a los que giran las estrellas

	int pos = 0; // Inicialmente 0º
	for (int i=0; i<4; i++){ // Dibuja 4 estrellas
		glPushMatrix();
		glRotatef(pos,0,1,0); // Rotacion sobre eje y
		glColor3f(0.2 + 0.2/4 *i, 0.9 - 0.5/4 *i, 0.9 - 0.9/4 *i); // Color degradado
		glCallList(triangulo1);
		glCallList(triangulo2);
		glPopMatrix();
		pos += 40;
	}
	glPopMatrix();
	
	/** Linea marca segundos **/
	glColor3f(0.4,0,1);
    glLineWidth(6.0);
    glPushMatrix();
    glRotatef((360/60) * newtime->tm_sec,0.0,0.0,-1.0);
    glBegin(GL_LINES);
    glVertex2f(0,0.1);
    glVertex2f(0,0.85);
    glEnd();
	glPopMatrix();

	/** Cono marca minutos **/
    glColor3f(0,0,0);
	glLineWidth(2.0);
    glPushMatrix();
	glRotatef(90,-1,0,0);
    glRotatef((360/60) * newtime->tm_min,0,1,0);
	glTranslatef(0,0,0.25); // Lo trasladamos hacia arriba (eje y)
    glutWireCone(0.075,0.5,10,10);
    glPopMatrix();

	/** Triangulo marca horas **/
	glPushMatrix();
	glColor3f(0.7,0,0); // Color Rojo
	glScalef(0.1,0.1,0.1); // Diametro 1/10
	glRotatef((360/12) * newtime->tm_hour, 0.0, 0.0, -1.0);
	glTranslatef(0,6,0); // Lo trasladamos hacia arriba (eje y)
	glScalef(gamma,gamma,gamma); // Rotacion sobre eje y
	glCallList(triangulo1);
	//FPS(); // Muertra FPS a los que cambia de tamaño
	glPopMatrix();

	// Intercambiar el buffer back por el front
	glutSwapBuffers();
}