void display(void) { GLfloat low_ambient[] = { 0.1, 0.1, 0.1, 1.0 }; GLfloat more_ambient[] = { 0.4, 0.4, 0.4, 1.0 }; GLfloat most_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* material has small ambient reflection */ glMaterialfv(GL_FRONT, GL_AMBIENT, low_ambient); glMaterialf(GL_FRONT, GL_SHININESS, 40.0); glPushMatrix (); glTranslatef (0.0, 2.0, 0.0); auxSolidTeapot(1.0); glPopMatrix (); /* material has moderate ambient reflection */ glMaterialfv(GL_FRONT, GL_AMBIENT, more_ambient); glPushMatrix (); glTranslatef (0.0, 0.0, 0.0); auxSolidTeapot(1.0); glPopMatrix (); /* material has large ambient reflection */ glMaterialfv(GL_FRONT, GL_AMBIENT, most_ambient); glPushMatrix (); glTranslatef (0.0, -2.0, 0.0); auxSolidTeapot(1.0); glPopMatrix (); glFlush(); }
void display(void) { GLdouble eqn[4] = {1.0, 0.0, -1.0, 1.0}; GLfloat two_side_on[] = { GL_TRUE }; GLfloat two_side_off[] = { GL_FALSE }; GLfloat mat_diffuse[] = { 0.8, 0.8, 0.8, 1.0 }; GLfloat back_diffuse[] = { 0.8, 0.2, 0.8, 1.0 }; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix (); glClipPlane (GL_CLIP_PLANE0, eqn); /* slice objects */ glEnable (GL_CLIP_PLANE0); glPushMatrix (); glTranslatef (0.0, 2.0, 0.0); auxSolidTeapot(1.0); /* one-sided lighting */ glPopMatrix (); /* two-sided lighting, but same material */ glLightModelf (GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse); glPushMatrix (); glTranslatef (0.0, 0.0, 0.0); auxSolidTeapot(1.0); glPopMatrix (); /* two-sided lighting, two different materials */ glMaterialfv (GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv (GL_BACK, GL_DIFFUSE, back_diffuse); glPushMatrix (); glTranslatef (0.0, -2.0, 0.0); auxSolidTeapot(1.0); glPopMatrix (); glLightModelf (GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); glDisable (GL_CLIP_PLANE0); glPopMatrix (); glFlush(); }
void RenderRedTeapot(GLfloat x,GLfloat y,GLfloat z) { GLfloat mat[3]; //GLfloat mat_shininess[]={50.0}; glPushMatrix(); glTranslatef(x,y,z); mat[0]=0.0;mat[1]=0.0;mat[2]=1.0; glMaterialfv(GL_FRONT,GL_AMBIENT,mat); mat[0]=0.8;mat[1]=0.86;mat[2]=1.0; glMaterialfv(GL_FRONT,GL_DIFFUSE,mat); mat[0]=1.0;mat[1]=1.0;mat[2]=1.0; glMaterialfv(GL_FRONT,GL_SPECULAR,mat); glMaterialf(GL_FRONT,GL_SHININESS,0.6*128.0); auxSolidTeapot(1.0); glPopMatrix(); }
void renderTeapot (GLfloat x, GLfloat y, GLfloat z, 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, z); 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); auxSolidTeapot(0.5); glPopMatrix(); }
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////Draw Primitivs////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// void DrawPrimitivs(void) { //Draw triangle! glPushMatrix(); glLoadIdentity(); glRotated(180,0,1,0); glRotated(30,1,0,0); glTranslated(2,1,0); glBegin(GL_TRIANGLES); glColor3d(1,0,0); glVertex3d(0,0,0); glColor3d(0,1,0); glVertex3d(-2,3,0); glColor3d(0,0,1); glVertex3d(2,4,0); glEnd(); glPopMatrix(); //Draw small teapot glPushMatrix(); glLoadIdentity(); glTranslated(3,3,-5); glRotated(time,1.,1.,1.); glColor3d(0,1,0); auxSolidTeapot(1); time++; glPopMatrix(); //Draw small box glPushMatrix(); glLoadIdentity(); glTranslated(3,-3,-5); glRotated(time,1.,1.,1.); glColor3d(0,0,1); auxSolidBox(2,2,2); glPopMatrix(); }
CEE3DINPROC_API void _stdcall CeE3DSolidTeapot(GLdouble a) { auxSolidTeapot(a); }