int GlutApp::render() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // glLoadIdentity(); // gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glColor3f(1.0, 0.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); cg::vecmath::Vector3f* eye = new cg::vecmath::Vector3f(); renderCamera(*eye); glutSolidTeapot(1.0); // glBegin(GL_QUADS); // // glColor3f(0.5, 0.0, 1.0); // glVertex3f(-2, -2, 0); // glVertex3f(2, -2, 0); // glColor3f(1.0, 0.5, 0.0); // glVertex3f(2, 2, 0); // glVertex3f(-2, 2, 0); // // glEnd(); // swap drawing buffers glutSwapBuffers(); }
/* * Initialize depth buffer, projection matrix, light source, and lighting * model. Do not specify a material property here. */ void init(void) { GLfloat ambient[] = {0.0, 0.0, 0.0, 1.0}; GLfloat diffuse[] = {1.0, 1.0, 1.0, 1.0}; GLfloat specular[] = {1.0, 1.0, 1.0, 1.0}; GLfloat position[] = {0.0, 3.0, 3.0, 0.0}; GLfloat lmodel_ambient[] = {0.2, 0.2, 0.2, 1.0}; GLfloat local_view[] = {0.0}; glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT0, GL_POSITION, position); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); glFrontFace(GL_CW); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_AUTO_NORMAL); glEnable(GL_NORMALIZE); glEnable(GL_DEPTH_TEST); /* be efficient--make teapot display list */ glNewList (TEAPOT_LIST, GL_COMPILE); glutSolidTeapot(1.0); glEndList (); }
void renderRedTeapot(GLfloat x, GLfloat y, GLfloat z) { float mat[4]; glPushMatrix(); glTranslatef(x, y, z); mat[0] = 0.1745; mat[1] = 0.01175; mat[2] = 0.01175; mat[3] = 1.0; glMaterialfv(GL_FRONT, GL_AMBIENT, mat); mat[0] = 0.61424; mat[1] = 0.04136; mat[2] = 0.04136; mat[3] = 1.0; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat); mat[0] = 0.727811; mat[1] = 0.626959; mat[2] = 0.626959; mat[3] = 1.0; glMaterialfv(GL_FRONT, GL_SPECULAR, mat); glMaterialf(GL_FRONT, GL_SHININESS, 60.0); glutSolidTeapot(3.0); glPopMatrix(); }
void drawTeaPot() { setMaterial(colorRed); glTranslatef(0.0f, 0.5f, 0.0f); glutSolidTeapot(1.0f); }
// marker sphere to the left - the transform passed in is the identity in this case void drawFirstSphere(glm::mat4 modelMatrix) { Sphere *sphere1 = new Sphere(); glUniformMatrix4fv(PhongShade.worldSpaceMoveMatrixUnif, 1, GL_FALSE, glm::value_ptr(moveObjLinearInterp(-1.0))); // don't move it //modelMatrix = glm::translate(modelMatrix, glm::vec3(0.0f, 0.0f, 0.0f)); // translate to the left 5 units modelMatrix = glm::translate(modelMatrix, glm::vec3(-5.0f, -0.25f, 0.0f)); modelMatrix = glm::rotate(modelMatrix, 90.0f ,glm::vec3(-1,0,0)); // scale it small - recall that transforms are applied in reverse coding order, so this scale occurs first modelMatrix = glm::scale(modelMatrix, glm::vec3(0.25f, 0.25f, 0.25f)); // now set the transform in the shader glUniformMatrix4fv(PhongShade.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix)); // color glUniform4f(PhongShade.diffuseColorUnif, 1.0f, 0.2f, 0.2f, 1.0f); // low saturation red // couple of other reflectance parameters glUniform4f(PhongShade.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f); glUniform1f(PhongShade.shininessFactorUnif, 20.0f); // tells the shader to draw it glutSolidTeapot(2); //sphere1->DrawUnitSphere(); }
void draw(void) { int i, j, k; glPushMatrix(); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specularcolor); glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, shininess); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, teapotColor); glTranslated(-0., -0.60, 0); glutSolidSphere(0.1, 16, 16); glPopMatrix(); glPushMatrix(); /* ティーポットの反射特性の設定 */ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specularcolor); glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, shininess); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, teapotColor); /* ちょっと上に上がり,前に傾けてティーポットを描く */ //glTranslated(0.0, 0.7, 0.0); //glRotated(-30, 0.0, 0.0, 1.0); glRotatef(angle, 0.0, 1.0, 0.0); glutSolidTeapot(0.5); glPopMatrix(); }
void init(void) { GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat position[] = { 0.0, 3.0, 3.0, 0.0 }; GLfloat lmodel_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; GLfloat local_view[] = { 0.0 }; glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT0, GL_POSITION, position); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); glFrontFace (GL_CW); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_AUTO_NORMAL); glEnable(GL_NORMALIZE); glEnable(GL_DEPTH_TEST); glClearColor(0.0, 0.0, 0.0, 0.0); glClearAccum(0.0, 0.0, 0.0, 0.0); /* make teapot display list */ teapotList = glGenLists(1); glNewList (teapotList, GL_COMPILE); glutSolidTeapot (0.5); glEndList (); }
/* * Move object into position. Use 3rd through 12th parameters to specify the * material property. Draw a teapot. */ static void renderTeapot(GLfloat x, GLfloat y, GLfloat ambr, GLfloat ambg, GLfloat ambb, GLfloat difr, GLfloat difg, GLfloat difb, GLfloat specr, GLfloat specg, GLfloat specb, GLfloat shine) { float mat[4]; glPushMatrix(); glTranslatef(x, y, 0.0); mat[0] = ambr; mat[1] = ambg; mat[2] = ambb; mat[3] = 1.0; glMaterialfv(GL_FRONT, GL_AMBIENT, mat); mat[0] = difr; mat[1] = difg; mat[2] = difb; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat); mat[0] = specr; mat[1] = specg; mat[2] = specb; glMaterialfv(GL_FRONT, GL_SPECULAR, mat); glMaterialf(GL_FRONT, GL_SHININESS, shine * 128.0); glutSolidTeapot(1.0); glPopMatrix(); }
void RenderObjects(void) { float colorBronzeDiff[4] = { 0.8, 0.6, 0.0, 1.0 }; float colorBronzeSpec[4] = { 1.0, 1.0, 0.4, 1.0 }; float colorBlue[4] = { 0.0, 0.2, 1.0, 1.0 }; float colorNone[4] = { 0.0, 0.0, 0.0, 0.0 }; glMatrixMode(GL_MODELVIEW); glPushMatrix(); // Main object (cube) ... transform to its coordinates, and render glRotatef(15, 1, 0, 0); glRotatef(45, 0, 1, 0); glRotatef(g_fTeapotAngle, 0, 0, 1); glMaterialfv(GL_FRONT, GL_DIFFUSE, colorBlue); glMaterialfv(GL_FRONT, GL_SPECULAR, colorNone); glColor4fv(colorBlue); glBindTexture(GL_TEXTURE_2D, TEXTURE_ID_CUBE); DrawCubeWithTextureCoords(1.0); // Child object (teapot) ... relative transform, and render glPushMatrix(); glTranslatef(2, 0, 0); glRotatef(g_fTeapotAngle2, 1, 1, 0); glMaterialfv(GL_FRONT, GL_DIFFUSE, colorBronzeDiff); glMaterialfv(GL_FRONT, GL_SPECULAR, colorBronzeSpec); glMaterialf(GL_FRONT, GL_SHININESS, 50.0); glColor4fv(colorBronzeDiff); glBindTexture(GL_TEXTURE_2D, 0); glutSolidTeapot(0.3); glPopMatrix(); glPopMatrix(); }
void display() { // Clear Screen and Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // Define a viewing transformation gluLookAt( 4,2,0, 0,0,0, 0,1,0); // Push and pop the current matrix stack. // This causes that translations and rotations on this matrix wont influence others. glPushMatrix(); glColor3f(1,0,0); glTranslatef(0,0,0); glRotatef(g_rotation,0,1,0); glRotatef(90,0,1,0); // Draw the teapot glutSolidTeapot(1); glPopMatrix(); g_rotation += g_rotation_speed; glutSwapBuffers(); }
void render(void) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective( /* field of view in degree */ 30.0, /* aspect ratio */ 1.0, /* Z near */ 1.0, /* Z far */ 20.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.0, 0.0, 10.0, /* eye is at (0,0,5) */ 0.0, 0.0, 0.0, /* center is at (0,0,0) */ 0.0, 1.0, 0.); /* up is in postivie Y direction */ glPushMatrix(); glRotatef(angle, 1.0, 0.3, 0.0); switch (shape) { case M_TORUS: glutSolidTorus(0.275, 0.85, 8, 8); break; case M_CUBE: glutSolidCube(1.0); break; case M_SPHERE: glutSolidSphere(1.0, 10, 10); break; case M_ICO: glutSolidIcosahedron(); break; case M_TEAPOT: glutSolidTeapot(1.0); break; } glPopMatrix(); }
void draw_actor( void ) { GLfloat material_Ka[4] = { actor_Ka(0), actor_Ka(1), actor_Ka(2), 1.0 }; GLfloat material_Kd[4] = { actor_Kd(0), actor_Kd(1), actor_Kd(2), 1.0 }; GLfloat material_Ks[4] = { actor_Ks(0), actor_Ks(1), actor_Ks(2), 1.0 }; GLfloat material_Ke[4] = { actor_Ke(0), actor_Ke(1), actor_Ke(2), 1.0 }; GLfloat material_Se = 10; glPushMatrix(); glMaterialfv(GL_FRONT, GL_AMBIENT, material_Ka); glMaterialfv(GL_FRONT, GL_DIFFUSE, material_Kd); glMaterialfv(GL_FRONT, GL_SPECULAR, material_Ks); glMaterialfv(GL_FRONT, GL_EMISSION, material_Ke); glMaterialf(GL_FRONT, GL_SHININESS, material_Se); glLoadMatrixd( actor_transform.arrayOpenGL() ); /* glBegin(GL_TRIANGLES); glVertex3d( 1.0, 0.0, 0.0); glVertex3d(-1.0, 1.0, 0.0); glVertex3d(-1.0,-1.0, 0.0); glEnd(); */ glutSolidTeapot( 1.0 ); glPopMatrix(); }
/* Fonction appelee lorsqu'une entree du menu est selectionnee. */ void drawObject() { glPushMatrix(); /* ** AJOUTER CODE ICI ** ** Ajouter le code afin d'afficher le teapot ** ** utilisez gMaterials[1].diffuse comme couleur (glColor) ** */ switch( CurrentAction ) { case ActionSweep: drawSweepObject(objectResolution, drawNormals); break; case ActionRevolution: drawRevolutionObject(objectResolution, drawNormals); break; case ActionTeapot: glFrontFace( GL_CW ); glColor4fv(gMaterials[1].diffuse); glPushMatrix(); glTranslated(0,-50,0); glutSolidTeapot(50); glPopMatrix(); glFrontFace( GL_CCW ); break; } glPopMatrix(); }
int main(void) { GLFWwindow* window; glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); if (false) { glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); } window = glfwCreateWindow(1024, 768, "OGL", NULL, NULL); if (!window) { glfwTerminate(); exit(EXIT_FAILURE); } glfwMakeContextCurrent(window); glfwSetKeyCallback(window, key_callback); setShaders(); while (!glfwWindowShouldClose(window)) { float ratio; int width, height; glfwGetFramebufferSize(window, &width, &height); ratio = width / (float) height; glViewport(0, 0, width, height); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1, 1, -1, 1, 1, 10); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.f, 5.f, 5.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); GLfloat lightpos[] = {.5, 1., 1., 0.}; glLightfv(GL_LIGHT0, GL_POSITION, lightpos); GLfloat white[] = {0.8f, 0.8f, 0.8f, 1.0f}; GLfloat cyan[] = {0.f, .8f, .8f, 1.f}; glMaterialfv(GL_FRONT, GL_DIFFUSE, cyan); glMaterialfv(GL_FRONT, GL_SPECULAR, white); GLfloat shininess[] = {50}; glMaterialfv(GL_FRONT, GL_SHININESS, shininess); glUseProgram(p); glRotatef((float) glfwGetTime() * 50.f, 0.f, 1.0f, 0.f); glutSolidTeapot(2); //drawCube(); glfwSwapBuffers(window); glfwPollEvents(); } glfwDestroyWindow(window); glfwTerminate(); exit(EXIT_SUCCESS); }
void display() { glViewport(0, 0, 700, 700); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); obj(0, 0, 0.5, 1, 1, 0.04); // three walls obj(0, -0.5, 0, 1, 0.04, 1); obj(-0.5, 0, 0, 0.04, 1, 1); obj(0, -0.3, 0, 0.02, 0.2, 0.02); // four table legs obj(0, -0.3, -0.4, 0.02, 0.2, 0.02); obj(0.4, -0.3, 0, 0.02, 0.2, 0.02); obj(0.4, -0.3, -0.4, 0.02, 0.2, 0.02); obj(0.2, -0.18, -0.2, 0.6, 0.02, 0.6); // table top glRotated(50, 0, 1, 0); glRotated(10, -1, 0, 0); glRotated(11.7, 0, 0, -1); glTranslated(0.3, -0.1, -0.3); glutSolidTeapot(0.09); glFlush(); glLoadIdentity(); }
void drawRotatedTeapot(float rotx, float roty, float rotz) { glRotatef(rotx, 1.0, 0.0, 0.0); glRotatef(roty, 0.0, 1.0, 0.0); glRotatef(rotz, 0.0, 0.0, 1.0); // teapot glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glutSolidTeapot(1.0); // local coordinate axes glDisable(GL_LIGHTING); glLineWidth(2.0); glBegin(GL_LINES); // Red: X-axis glColor3f(1, 0, 0); glVertex3f(0, 0, 0); glVertex3f(2, 0, 0); // Green: Y-axis glColor3f(0, 1, 0); glVertex3f(0, 0, 0); glVertex3f(0, 2, 0); // Blue: Z-axis glColor3f(0, 0, 1); glVertex3f(0, 0, 0); glVertex3f(0, 0, 2); glEnd(); }
void DrawingGlobal::draw_control_point(ControlPoint* cp) { glPushMatrix(); glTranslatef(cp->pt.x,cp->pt.y,cp->pt.z); glutSolidTeapot(.5); glPopMatrix(); }
void renderRedTeapot(GLfloat x, GLfloat y, GLfloat z) { float mat[3]; // Sichern der aktuellen Matrix glPushMatrix(); // Verschieben des Objektes glTranslatef(x, y, z); // Setzen der Materialfarbe mat[0] = 0.1745; mat[1] = 0.01175; mat[2] = 0.01175; glMaterialfv(GL_FRONT, GL_AMBIENT, mat); mat[0] = 0.61424; mat[1] = 0.04136; mat[2] = 0.04136; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat); mat[0] = 0.727811; mat[1] = 0.626959; mat[2] = 0.626959; glMaterialfv (GL_FRONT, GL_SPECULAR, mat); glMaterialf (GL_FRONT, GL_SHININESS, 0.6*128.0); // Zeichnen der Teekanne glutSolidTeapot(1.0); // Verwerfen der Translation glPopMatrix(); }
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -5); glRotatef(rot_x, 1, 0, 0); glRotatef(rot_y, 0, 1, 0); switch(obj) { case 0: glutSolidCube(1); break; case 1: glutSolidSphere(1,48,48); break; case 2: glutSolidTeapot(1); break; } glutSwapBuffers(); }
//coordenadas do centro da maquina void printingMachine(double x, double z){ glPushMatrix(); glTranslated(x,0,z); machine(machineX,machineY,machineZ,machineXaux,machineYaux); glPushMatrix(); glTranslated(-guillotineSupportX,guillotineSupportY,guillotineSupportZ); guillotineSupport(guillotineSupportSide,guillotineSupportHeight); glPopMatrix(); glPushMatrix(); glTranslated(guillotineSupportX,guillotineSupportY,guillotineSupportZ); guillotineSupport(guillotineSupportSide,guillotineSupportHeight); glPopMatrix(); glPushMatrix(); glTranslated(0.0,machineY + teapotSize/2.0,0.0); glFrontFace(GL_CW); glutSolidTeapot(teapotSize); glFrontFace(GL_CCW); glPopMatrix(); glPushMatrix(); glTranslated(0,0,conveyorZ+machineZ); conveyorBelt(conveyorX,conveyorY,conveyorZ); glPopMatrix(); glPopMatrix(); }
void displaySolid(void) { GLfloat mat_ambient[] = {0.7f, 0.7f, 0.7f, 1.0f}; GLfloat mat_diffuse[] = {0.5f, 0.5f, 0.5f, 1.0f}; GLfloat mat_specular[] = {1.0f, 1.0f, 1.0f, 1.0f}; GLfloat mat_shininess[] = {50.0f}; glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); GLfloat lightIntensity[] = {0.7f, 0.7f, 0.7f, 0.7f}; GLfloat light_position[] = {2.0f, 6.0f, 3.0f, 0.0f}; glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightfv(GL_LIGHT0, GL_DIFFUSE, lightIntensity); glMatrixMode(GL_PROJECTION); glLoadIdentity(); double winHt = 1.0; glOrtho(-winHt * 64 / 48.0, winHt * 64 / 48.0, -winHt, winHt, 0.1, 100.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(2.3, 1.3 , 2.0, 0.0, 0.25, 0.0, 0.0, 1.0, 0.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslated(0.4, 0.4, 0.6); glRotated(45, 0, 0, 1); glScaled(0.08, 0.08, 0.08); glPopMatrix(); glPushMatrix(); glTranslated(0.6, 0.38, 0.5); glRotated(30, 0, 1, 0); glutSolidTeapot(0.08); glPopMatrix(); glPushMatrix(); glTranslated(0.25, 0.42, 0.35); glPopMatrix(); glPushMatrix(); glTranslated(0.4, 0, 0.4); table(0.6, 0.02, 0.02, 0.3); glPopMatrix(); wall(0.02); glPushMatrix(); glRotated(90.0, 0.0, 0.0, 1.0); wall(0.02); glPopMatrix(); glPushMatrix(); glRotated(-90.0, 1.0, 0.0, 0.0); wall(0.02); glPopMatrix(); glFlush(); }
void cene_teapot(){ glPushMatrix(); glColor3d(1,0,1); glTranslated(3,-1,-4); glRotated(-20, 0, 5, 0); glutSolidTeapot(1); glPopMatrix(); }
//function to draw teapot using solidteapot function void drawteapot(double thick, double len) { glPushMatrix(); //push the current matrix glTranslated(0.35,0.3,0.5); //multiply current matrix with the translation matrix glScaled(thick/3,len/3,thick/3); //multiply with the scaling matrix glutSolidTeapot(1); // draw the teapot glPopMatrix(); //pop the current matrix }
void display () { glClear(GL_COLOR_BUFFER_BIT); glutSolidTeapot(.5); glFlush(); }
static void hugsprim_glutSolidTeapot_16(HugsStackPtr hugs_root) { HsDouble arg1; arg1 = hugs->getDouble(); glutSolidTeapot(arg1); hugs->returnIO(hugs_root,0); }
void drawTeapot() { glDisable(GL_CULL_FACE); glPushMatrix(); glTranslatef(0, 0.6, 0); glutSolidTeapot(0.4); glPopMatrix(); }
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(); }
void myGlutDisplay( void ) { glClearColor( .9f, .9f, .9f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glFrustum( -xy_aspect*.08, xy_aspect*.08, -.08, .08, .1, 15.0 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glTranslatef( 0.0, 0.0, -1.2f ); glRotatef( rotationY, 0.0, 1.0, 0.0 ); glRotatef( rotationX, 1.0, 0.0, 0.0 ); glScalef( scale, scale, scale ); /*** Now we render object, using the variables 'obj_type', 'segments', and 'wireframe'. These are _live_ variables, which are transparently updated by GLUI ***/ if ( obj_type == 0 ) { if ( wireframe ) glutWireSphere( .6, segments, segments ); else glutSolidSphere( .6, segments, segments ); } else if ( obj_type == 1 ) { if ( wireframe ) glutWireTorus( .2,.5,16,segments ); else glutSolidTorus( .2,.5,16,segments ); } else if ( obj_type == 2 ) { if ( wireframe ) glutWireTeapot( .5 ); else glutSolidTeapot( .5 ); } /* Disable lighting and set up ortho projection to render text */ glDisable( GL_LIGHTING ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluOrtho2D( 0.0, 100.0, 0.0, 100.0 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glColor3ub( 0, 0, 0 ); glRasterPos2i( 10, 10 ); /*** Render the live character array 'text' ***/ for (unsigned int i=0; i<text.length(); ++i) glutBitmapCharacter( GLUT_BITMAP_HELVETICA_18, text[i] ); glEnable( GL_LIGHTING ); glutSwapBuffers(); }
void Teapot::draw() { glFrontFace(GL_CW); float specReflection[] = { 0.3f, 0.3f, 0.3f, 0.7f }; glMaterialfv(GL_FRONT, GL_SPECULAR, specReflection); glMateriali(GL_FRONT, GL_SHININESS, 128); glutSolidTeapot(1.0); }
void teko(){ glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glTranslated(0.6,0.0,-0.6); glScaled(0.4,0.4,0.4); glutSolidTeapot(1); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); }