void scene::compileDonut() { glNewList(donut_id, GL_COMPILE); GLfloat jaune[] = {1.f, 0.7843f, 0.3725f, 1.f}; GLfloat white[] = {0.8f, 0.8f, 0.8f, 1.0f}; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, jaune); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white); GLfloat shininess[] = {50}; glMaterialfv(GL_FRONT, GL_SHININESS, shininess); glutSolidTorus(0.1, 0.3, 50, 50); glEndList(); }
// Called to draw scene objects void DrawModels(GLboolean drawBasePlane) { if (drawBasePlane) { // Draw plane that the objects rest on glColor3f(0.0f, 0.0f, 0.90f); // Blue glNormal3f(0.0f, 1.0f, 0.0f); glBegin(GL_QUADS); glVertex3f(-100.0f, -25.0f, -100.0f); glVertex3f(-100.0f, -25.0f, 100.0f); glVertex3f(100.0f, -25.0f, 100.0f); glVertex3f(100.0f, -25.0f, -100.0f); glEnd(); } // Draw red cube glColor3f(1.0f, 0.0f, 0.0f); glutSolidCube(48.0f); // Draw green sphere glColor3f(0.0f, 1.0f, 0.0f); glPushMatrix(); glTranslatef(-60.0f, 0.0f, 0.0f); glutSolidSphere(25.0f, 50, 50); glPopMatrix(); // Draw yellow cone glColor3f(1.0f, 1.0f, 0.0f); glPushMatrix(); glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); glTranslatef(60.0f, 0.0f, -24.0f); glutSolidCone(25.0f, 50.0f, 50, 50); glPopMatrix(); // Draw magenta torus glColor3f(1.0f, 0.0f, 1.0f); glPushMatrix(); glTranslatef(0.0f, 0.0f, 60.0f); glutSolidTorus(8.0f, 16.0f, 50, 50); glPopMatrix(); // Draw cyan octahedron glColor3f(0.0f, 1.0f, 1.0f); glPushMatrix(); glTranslatef(0.0f, 0.0f, -60.0f); glScalef(25.0f, 25.0f, 25.0f); glutSolidOctahedron(); glPopMatrix(); }
//Disegno il cannone void Cannone::draw(void) { glPushMatrix(); rotateX(xRot); rotateY(yRot); rotateZ(zRot); applyTransform(); glColor3f(0.6, 0.6, 0.6); glutSolidSphere(0.35, 25, 43); switch (getCityPosition()) { case 0: glPushMatrix(); glTranslatef(0, 0, -28); drawMirino(); glPopMatrix(); glTranslatef(0, 0, -0.6); glScalef(1, 1, 2.5); break; case 1: glPushMatrix(); glTranslatef(28, 0, 0); glRotatef(90, 0, 1, 0); drawMirino(); glPopMatrix(); glTranslatef(0.6, 0, 0); glScalef(2.5, 1, 1); glRotatef(90, 0, 1, 0); break; case 2: glPushMatrix(); glTranslatef(0, 0, 28); drawMirino(); glPopMatrix(); glTranslatef(0, 0, 0.6); glScalef(1, 1, 2.5); break; case 3: glPushMatrix(); glTranslatef(-28, 0, 0); glRotatef(90, 0, 1, 0); drawMirino(); glPopMatrix(); glTranslatef(-0.6, 0, 0); glScalef(2.5, 1, 1); glRotatef(90, 0, 1, 0); break; } glutSolidTorus(0.25, 0.30, 25, 43); glPopMatrix(); }
void robotLight(double height, double radius,double outerRadius){ glPushMatrix(); glEnable(GL_CLIP_PLANE0); glTranslated(outerRadius,height,0); glClipPlane(GL_CLIP_PLANE0,robotClipPlane); glutSolidTorus(radius,outerRadius,20,20); glDisable(GL_CLIP_PLANE0); glPopMatrix(); glPushMatrix(); glRotated(-90,1,0,0); gluCylinder(glQ,radius,radius,height,20,20); glPopMatrix(); }
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Donut redraw * Handles actually drawing the Donut object with the OpenGL * framework. * * The Donut is defined by positions relative to it's location * stored in the points array. * * The scale factor applies to the relative offset of each coordinate * from the origin (xLoc,yLoc,zLoc) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ void Donut::redraw(){ if( texture != NULL ) textureRedraw(); else{ glPushMatrix(); glColor3f( colors[0]->r, colors[0]->g, colors[0]->b ); glTranslatef( xLoc, yLoc, zLoc ); glRotatef( angle, dxRot, dyRot, dzRot ); glScalef( xSize, ySize, zSize ); material->activate(); glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR ); glutSolidTorus( xSize/4, xSize/2, 10, 50 ); glPopMatrix(); } }
void objects() { glPushMatrix(); glEnable(GL_LIGHTING); glRotatef(rotation, 2., 0., 1.); glColor4d(0.2, 0.2, 0.9, 0.2); if(teapot == GL_TRUE){ glutSolidTeapot(0.7); } else{ glutSolidTorus(0.3, 0.6, 20, 20); } glDisable(GL_LIGHTING); glPopMatrix(); }
// Public Methods void Cheerio::draw() { glPushMatrix(); GameObject::draw(); // Apply material glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, MATERIAL_AMB); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MATERIAL_DIFF); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, MATERIAL_SPEC); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, MATERIAL_SHININESS); glTranslatef(0, 0, .1); glColor3f(CHEERIO_COLOR_R, CHEERIO_COLOR_G, CHEERIO_COLOR_B); glutSolidTorus(0.1, 0.2, 8, 10); glPopMatrix(); }
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glScalef(1.3, 1.3, 1.3); glRotatef(20.0, 1.0, 0.0, 0.0); glPushMatrix(); glTranslatef(-0.65, 0.7, 0.0); glRotatef(90.0, 1.0, 0.0, 0.0); glCallList(TORUS_MATERIAL); glutSolidTorus(0.275, 0.85, 10, 15); glPopMatrix(); glPushMatrix(); glTranslatef(-0.75, -0.8, 0.0); glCallList(TEAPOT_MATERIAL); glutSolidTeapot(0.7); glPopMatrix(); glPushMatrix(); glTranslatef(1.0, 0.0, -1.0); glCallList(ICO_MATERIAL); glutSolidIcosahedron(); glPopMatrix(); glPopMatrix(); glPushAttrib(GL_ENABLE_BIT); glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(0, 3000, 0, 3000); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); output(80, 2800, "Torus: %s", torus_material); output(80, 2650, "Icosahedron: %s", ico_material); output(80, 2500, "Teapot: %s", teapot_material); output(80, 250, "Left light: %s", left_light); output(1700, 250, "Right light: %s", right_light); output(850, 100, "Shade model: %s", shade_model == GL_SMOOTH ? "smooth" : "flat"); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glPopAttrib(); glutSwapBuffers(); }
/* Transformation matrix should be set before calling this. So this draws it at the current location*/ void drawShape(ShapeInfo* si) { /* initialize colour matrices */ GLfloat blue[] = {0.0, 0.0, 1.0, 1.0}; GLfloat red[] = {1.0, 0.0, 0.0, 1.0}; GLfloat green[] = {0.0, 1.0, 0.0, 1.0}; GLfloat white[] = {1.0, 1.0, 1.0, 1.0}; /* Switch over colour */ switch(si->colour) { case(COLOUR_BLUE): glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); break; case(COLOUR_RED): glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); break; case(COLOUR_GREEN): glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); break; case(COLOUR_WHITE): glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, white); break; default: printf("Colour not supported\n"); } /* Switch over shape */ switch(si->shape) { case(SHAPE_SPHERE): glutSolidSphere (si->size, 30, 30); break; case(SHAPE_CUBE): glutSolidCube(si->size); break; case(SHAPE_TORUS): glutSolidTorus(si->size/2.0f, si->size, 10, 10); break; case(SHAPE_CONE): glutSolidCone(si->size, si->size, 30, 30); break; default: printf("Shape not supported\n"); } return; }
void cylinder(float alas,float atas,float tinggi) { float i; glPushMatrix(); glTranslatef(1.0,0.0,-alas/8); glutSolidCone(alas,0,32,4); for(i=0;i<=tinggi;i+=alas/24) { glTranslatef(0.0,0.0,alas/24); glutSolidTorus(alas/4,alas-((i*(alas-atas))/tinggi),16,16); } glTranslatef(0.0,0.0,alas/4); glutSolidCone(atas,0,20,1); glColor3f(1.,0.,0.); glPopMatrix(); }
/* * Draws the ring in the lower portion of the stool. * * Note: Inner radius of the ring actually specifies the thickness of the ring. * Outer radius specifies the radius of the ring itself */ void Stool::drawRing(MatrixStack &mViewStack) { mViewStack.push(); // perform transformations on the torus mViewStack.active = glm::translate(mViewStack.active, glm::vec3(0.0f, -(STOOL_HEIGHT - RING_HEIGHT), 0.0f)); mViewStack.active = glm::rotate(mViewStack.active, 90.0f, glm::vec3(1.0f, 0.0f, 0.0f)); glLoadMatrixf(glm::value_ptr(mViewStack.active)); GLUquadric *q = gluNewQuadric(); glColor4f(0.7f, 0.7f, 1.0f, 1.0f); glutSolidTorus(RING_THICKNESS, RING_OUTER_RAD, 10, 20); gluDeleteQuadric(q); mViewStack.pop(); }
void kerucut(float ngisor, float nduwur, float dowo) { float i; glPushMatrix(); glTranslatef(1.0,0.0,ngisor/24); glutSolidCone(ngisor,0,32,4); for(i=0;i<=dowo;i+=ngisor/24) { glTranslatef(0.0,0.0,ngisor/24); glutSolidTorus(ngisor/4,ngisor-((i*(ngisor-nduwur))/dowo),16,16); } glTranslatef(0.0,0.0,ngisor/4); glutSolidCone(nduwur,0,20,1); glColor3f(0.,1.,1.); glPopMatrix(); }
// Gets called by the engine. // Renders the maze, player and1 "portal" void MazeGame::RenderSelf(void) { for (int i = 0; i < this->maze_size_; ++i) for (int j = 0; j < this->maze_size_; ++j) { glPushMatrix(); // Height of all objects is set to a default // (except from floors which have a negative height) GLdouble y_coord = cube_size_ / 2; glColor3f(ORANGE); // Floors have a different height and color if (this->actual_maze_[i][j] == '.') { y_coord *= -1; glColor3f(PURPLE); } glTranslatef(i * cube_size_, y_coord, j * cube_size_); glutSolidCube(cube_size_ - fine_spacing_); // Draw the black "lines" glColor3f(BLACK); glutWireCube(cube_size_); glPopMatrix(); } // Draw the player // Dimensions are kept as magic numbers // (too lazy to keep them in a proper way) glPushMatrix(); glTranslatef(player_->x, player_->y, player_->z); glColor3f(BLACK); glutSolidSphere(cube_size_ / 5, 20, 20); glPopMatrix(); // Draw the portal // Dimensions are also magic numbers glPushMatrix(); glTranslatef(portal_->x, portal_->y, portal_->z); glColor3f(PORTAL_RED); glutSolidTorus(cube_size_ / 10, cube_size_ / 3, 30, 20); glPopMatrix(); }
void MakeDisplayLists(void) { glNewList(STUFF, GL_COMPILE); glPushMatrix(); glutSolidCube(1.0); glTranslatef(2, 0, 0); glutSolidSphere(0.5, 10, 10); glTranslatef(-2, 0, 3); glRotatef(-90, 1, 0, 0); glutSolidCone(0.5, 1.0, 8, 8); glPopMatrix(); glEndList(); glNewList(RING, GL_COMPILE); glutSolidTorus(0.1, 0.5, 8, 15); glEndList(); }
void Donut::textureRedraw(){ float x2yAspect = texture->getWidth() / (float)texture->getHeight(); glMatrixMode( GL_MODELVIEW ); texture->enable(); // glBegin( GL_QUADS ); glTranslatef( xLoc, yLoc, zLoc ); glRotatef( angle, dxRot, dyRot, dzRot ); // glScalef( xSize, ySize, zSize ); float yscale = ySize * x2yAspect; float xscale = yscale * x2yAspect; glScalef( xscale * xSize, yscale * ySize, 1.0 ); glutSolidTorus( xscale * xSize, yscale * ySize, 10, 50 ); // glEnd(); texture->disable(); glutSwapBuffers(); }
//=========================================================================== void cShapeTorus::render(const int a_renderMode) { // render material properties m_material.render(); // render texture property if defined if (m_texture != NULL) { m_texture->render(); } // draw sphere glutSolidTorus(m_innerRadius, m_outerRadius, 32, 32); // turn off texture rendering if it has been used glDisable(GL_TEXTURE_2D); }
void display(void){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //glPushMatrix(); glLoadIdentity(); gluLookAt(0,0,-5, 0, 0, 0, 0, 1, 0); glPushMatrix(); glRotatef(angle, 1, 0, 0); glutSolidTorus(0.278, 0.85, 40, 50); glPopMatrix(); glPushMatrix(); glRotatef(angle, 0, 1, 0); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glPopMatrix(); //glPopMatrix(); glFlush(); }
void Cheerio::draw(){ glPushMatrix(); glTranslatef(getPosition()->getX(), getPosition()->getY(), getPosition()->getZ()); glScalef(0.8f, 0.8f, 0.8f); if(COLISION_SPHERE){ glColor3f(1.0f, 1.0f, 1.0f); glutWireSphere(getRadius(), 10, 10); } if(glIsEnabled(GL_LIGHTING)) material(amb, diffuse, specular, &shine); glColor3f(1.0f, 0.5f, 0.0f); glutSolidTorus(.2f, 0.4f, 10.0, 100.0f); glPopMatrix(); };
void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f(1.0,0.0,1.0); glLoadIdentity(); //gluLookAt(0, 10, 10, 0,0,0,0, 1,0); //glRotatef(45.0,0.0,0.0,1.0); glTranslatef(0.0,0.0,-20.0); glRotatef(90.0,1.0,0.0,0); glPushMatrix(); //绘制太阳 glColor3f(1.0,0.0,0.0); glutSolidSphere(2.0,32,32); //绘制地球 glPushMatrix(); glColor3f(0.0,0.0,1.0); // 绘制辅助轨道 glRotatef(90,1.0,0,0.0); glutSolidTorus(0.02, 5.0, 10, 64); glRotatef(-90,1.0,0,0.0); // 设置地球公转速度 glRotatef(rot0,0.0,1.0,0.0); // 设置地球半径 glTranslatef(5.0,0.0,0.0); // 设置地球自转速度 //glRotatef(rot1,0.0,1.0,0.0); // 绘制地球 glutSolidSphere(0.4,32,32); // 绘制地球的卫星-月亮 glColor3f(0.5,0.6,0.5); // 抵消地球自转影响 //glRotatef(-rot1,0.0,1.0,0.0); // 绘制辅助轨道 glRotatef(90,1.0,0,0.0); glRotatef(-90,1.0,0,0.0); // 设置月亮公转速度 glRotatef(rot9,0.0,1.0,0.0); // 设置月亮公转半径 glTranslatef(0.6,0.0,0.0); // 绘制月亮 glutSolidSphere(0.1,10,8); glPopMatrix(); glutSwapBuffers(); glFlush(); }
void drawMouth(glm::mat4 modelMatrix, glm::vec3 color, float timeParameter) { Sphere *sphereMiddle = new Sphere(); // this time send the shader a non-identity transform to move in world space glUniformMatrix4fv(PhongShade.worldSpaceMoveMatrixUnif, 1, GL_FALSE, glm::value_ptr(moveObjMouth(timeParameter))); modelMatrix = glm::translate(modelMatrix, glm::vec3(0.0f, -0.4f, 0.57f)); modelMatrix = glm::rotate(modelMatrix, 190.0f, glm::vec3(1,0,0)); modelMatrix = glm::scale(modelMatrix, glm::vec3(0.05f, 0.05f, 0.05f)); // scale is different from the marker glUniformMatrix4fv(PhongShade.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix)); glUniform4f(PhongShade.diffuseColorUnif, color[0], color[1], color[2], 1.0f); // color is different from the marker glUniform4f(PhongShade.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f); glUniform1f(PhongShade.shininessFactorUnif, 20.0f); glutSolidTorus(2,4 , 100, 100); }
//------------------------------------------------------------------------------ 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; } }
static void draw_saw(void){ glTranslatef(80.0, 0.0, 0.0); glutSolidTorus(10.0, 120.0, 8, 20); glTranslatef(-80.0, 0.0, 0.0); // glBegin(GL_POINTS); for (int i = 0; i<181; i++) { float a = 90.0; float x = (float)i; float y = 80.0 * (2 / a) * (x - a * floor(x / a + 0.5)) * pow((-1), floor(x / a + 0.5)); glVertex2f(x, y); } glEnd(); }
void display( void ) { int width, height; double finishtime, delta_t; static float angle = 0; width = glutGet(GLUT_WINDOW_WIDTH); height = glutGet(GLUT_WINDOW_HEIGHT); glClearColor( 0.5, 0.5, 0.5, 1.0 ); /* combine the clearing flags for more efficient operation */ glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT ); glViewport(0, 0, width, height); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 90, (float)width/(float)height, 1, 12 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); gluLookAt( 0, 4, 4, 0, 0, 0, 0, 1, 0 ); glEnable( GL_DEPTH_TEST ); glRotated( angle, 1, 0, 0 ); glColor3f( 1, 0, 0 ); glutSolidSphere( 1, 20, 20 ); glColor3f( 0.8, 0.8, 0 ); glutWireSphere( 1, 20, 20 ); glColor3f( 0, 0, 1 ); glutSolidTorus( 1, 2, 40, 40 ); glDisable( GL_DEPTH_TEST ); glutSwapBuffers(); finishtime = getftime(); delta_t = finishtime - lasttime; angle = fmodf(angle + 10*delta_t, 360); lasttime = finishtime; }
void redraw(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glPushMatrix(); drawXform(&xform, TRUE); glEnable(GL_STENCIL_TEST); if(whichSurface < 2) glStencilFunc(GL_EQUAL, whichSurface, 0xff); else glStencilFunc(GL_ALWAYS, 0, 0); glutSolidTorus(2, 4, 20, 20); /* glDisable(GL_STENCIL_TEST); */ /* glDisable(GL_LIGHTING); */ /* glColor3f(1, 1, 1); */ /* glutWireTorus(2, 4, 20, 20); */ /* glEnable(GL_LIGHTING); */ glPopMatrix(); switch(bufferInterest) { case COLOR: break; /* color already in back buffer */ case STENCIL: copyStencilToColor(GL_BACK); break; case DEPTH: copyDepthToColor(GL_BACK); break; } if(takeSnapshot) { takeSnapshot = 0; /* saveSGIImage("snap.rgb", FALSE); */ /* printf("Saved RGBA image in snap.rgba\n"); */ } glutSwapBuffers(); }
void C3D::displayObjects () { //## begin C3D::displayObjects%40E215A503B4.body preserve=yes GLfloat torus_diffuse[] = { 0.7f, 0.7f, 0.0f, 1.0f }; GLfloat cube_diffuse[] = { 0.0f, 0.7f, 0.7f, 1.0f }; GLfloat sphere_diffuse[] = { 0.7f, 0.0f, 0.7f, 1.0f }; GLfloat octa_diffuse[] = { 0.7f, 0.4f, 0.4f, 1.0f }; glPushMatrix (); glTranslatef (0.0, 0.0, -5.0); glRotatef (30.0, 1.0, 0.0, 0.0); glPushMatrix (); glTranslatef (-0.80f, 0.35f, 0.0f); glRotatef (100.0f, 1.0f, 0.0f, 0.0f); glMaterialfv(GL_FRONT, GL_DIFFUSE, torus_diffuse); glutSolidTorus (0.275f, 0.85f, 16, 16); glPopMatrix (); glPushMatrix (); glTranslatef (-0.75, -0.50, 0.0); glRotatef (45.0, 0.0, 0.0, 1.0); glRotatef (45.0, 1.0, 0.0, 0.0); glMaterialfv(GL_FRONT, GL_DIFFUSE, cube_diffuse); glutSolidCube (1.5); glPopMatrix (); glPushMatrix (); glTranslatef (0.75f, 0.60f, 0.0f); glRotatef (30.0, 1.0, 0.0, 0.0); glMaterialfv(GL_FRONT, GL_DIFFUSE, sphere_diffuse); glutSolidSphere (1.0, 16, 16); glPopMatrix (); glPushMatrix (); glTranslatef (0.70f, -0.90f, 0.25f); glMaterialfv(GL_FRONT, GL_DIFFUSE, octa_diffuse); glutSolidOctahedron (); glPopMatrix (); glPopMatrix (); //## end C3D::displayObjects%40E215A503B4.body }
void scene::compileLigneRevolutionLune() { glNewList(ligneRevolutionLune_id, GL_COMPILE); GLfloat gris[] = {0.4313f, 0.4313f, .4313f, 1.f}; GLfloat white[] = {0.f, 0.f, 0.f, 1.f}; GLfloat shininess[] = {0}; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, gris); glMaterialfv(GL_FRONT, GL_SPECULAR, white); glMaterialfv(GL_FRONT, GL_SHININESS, shininess); glRotatef(-90, 1, 0, 0); glutSolidTorus(0.003, 0.45, 50, 50); glRotatef(90, 1, 0, 0); glEndList(); }
void scene::compileLigneSat() { glNewList(ligneSat_id, GL_COMPILE); GLfloat bleu[] = {0.1960f, 0.3921f, 0.5490f, 1.f}; GLfloat gris[] = {0.8f, 0.8f, 0.8f, 1.0f}; GLfloat shininess[] = {50}; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, bleu); glMaterialfv(GL_FRONT, GL_SPECULAR, gris); glMaterialfv(GL_FRONT, GL_SHININESS, shininess); glRotatef(-90, 1, 0, 0); glutSolidTorus(0.003, 1.5, 50, 50); glRotatef(90, 1, 0, 0); glEndList(); }
void renderScene(void) { glClearColor(0.8,0.8,0.9,1.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D,1); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D,2); glPushMatrix(); glRotatef(-20.0,1.0,0.0,0.0); glRotatef(-20.0,0.0,1.0,0.0); //glColor3f(0.5,0.1,0.1); glutSolidTorus(0.4,0.8,128,128); glPopMatrix(); glutSwapBuffers(); //~ sleep(10); }
void Labyrinth::drawLabyrinth() { int dim = size * 2 + 1; for (int i = 0; i < dim; ++i) for (int j = 0; j < dim; ++j) { glPushMatrix(); // Draw walls if (maze[i * dim + j] == WALL) { glColor3f(0.541f, 0.294f, 0.031f); glTranslatef((j - dim / 2) * 3.f, 0.f, (i - dim / 2) * 3.f); glutSolidCube(2.9f); } // Draw portal else if (maze[i * dim + j] == PORTAL) { glColor3f(1.f, 0.f, 0.f); glTranslatef((j - dim / 2) * 3.f, 0.f, (i - dim / 2) * 3.f); // Rotate portal coresponding to the walls if (maze[i * dim + j - 1] == WALL && maze[(i - 1) * dim + j] == WALL && maze[(i + 1) * dim + j] == WALL || // left, up, down walls maze[i * dim + j + 1] == WALL && maze[(i - 1) * dim + j] == WALL && maze[(i + 1) * dim + j] == WALL) // right, up, down walls glRotatef(90, 0.f, 1.f, 0.f); else if (maze[i * dim + j - 1] == WALL && maze[(i - 1) * dim + j] == WALL && maze[i * dim + j + 1] == WALL || // left, up, right walls maze[i * dim + j - 1] == WALL && maze[(i + 1) * dim + j] == WALL && maze[i * dim + j + 1] == WALL) // left, down, right walls ; else if (maze[i * dim + j - 1] == WALL && maze[(i - 1) * dim + j] == WALL) // left, up walls glRotatef(-45, 0.f, 1.f, 0.f); else if (maze[i * dim + j - 1] == WALL && maze[(i + 1) * dim + j] == WALL) // left, down walls glRotatef(45, 0.f, 1.f, 0.f); else if (maze[i * dim + j + 1] == WALL && maze[(i + 1) * dim + j] == WALL) // right, down walls glRotatef(-45, 0.f, 1.f, 0.f); else if (maze[i * dim + j + 1] == WALL && maze[(i - 1) * dim + j] == WALL) // right, up walls glRotatef(45, 0.f, 1.f, 0.f); else if (maze[(i - 1) * dim + j] == WALL && maze[(i - 1) * dim + j] == WALL) // up, down walls glRotatef(90, 0.f, 1.f, 0.f); glutSolidTorus(0.5, 1, 100, 100); } glPopMatrix(); } }
void display(void){ unsigned int i; char *help = "Press 's' to save image or 'q' to quit"; glClearColor(0.3, 0.5, 0.8, 0.); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glRotatef(-60., 2., 0., 1.); glEnable(GL_LIGHTING); glutSolidTorus(0.3, 0.6, 30, 30); glDisable(GL_LIGHTING); glPopMatrix(); glColor3f(1.,1.,1.); glRasterPos2d(-0.9,-0.9); gl2psText(help, "Times-Roman", 24); for (i = 0; i < strlen(help); i++) glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, help[i]); glFlush(); }